Urchin.Protocol (Urchin v0.2.0)

Copy Markdown View Source

Protocol-level constants and version negotiation for the Model Context Protocol.

This library implements the 2025-11-25 revision. Older revisions are listed as acceptable negotiation targets so that the server can interoperate with clients that have not yet upgraded.

Summary

Functions

The protocol version assumed for HTTP requests that omit the MCP-Protocol-Version header (transport backwards-compatibility rule).

The JSON-RPC version string used by all messages.

The latest protocol revision implemented by this library.

Negotiates a protocol version from the client's requested version.

Returns true when version is a revision this server can speak.

All protocol revisions this server can negotiate, newest first.

Functions

default_negotiated_version()

@spec default_negotiated_version() :: String.t()

The protocol version assumed for HTTP requests that omit the MCP-Protocol-Version header (transport backwards-compatibility rule).

jsonrpc_version()

@spec jsonrpc_version() :: String.t()

The JSON-RPC version string used by all messages.

latest_version()

@spec latest_version() :: String.t()

The latest protocol revision implemented by this library.

negotiate(requested)

@spec negotiate(String.t()) :: String.t()

Negotiates a protocol version from the client's requested version.

If the requested version is supported, it is echoed back. Otherwise the server's latest version is returned, leaving it to the client to decide whether it can proceed (per the lifecycle spec, the client disconnects if it cannot).

supported?(version)

@spec supported?(String.t()) :: boolean()

Returns true when version is a revision this server can speak.

supported_versions()

@spec supported_versions() :: [String.t()]

All protocol revisions this server can negotiate, newest first.