# `Urchin.Protocol`
[🔗](https://github.com/urth-inc/urchin/blob/v0.4.0/lib/urchin/protocol.ex#L1)

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.

# `default_negotiated_version`

```elixir
@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`

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

The JSON-RPC version string used by all messages.

# `latest_version`

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

The latest protocol revision implemented by this library.

# `negotiate`

```elixir
@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?`

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

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

# `supported_versions`

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

All protocol revisions this server can negotiate, newest first.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
