# `Anubis.Protocol`

MCP protocol version management.

Provides version validation, negotiation, feature detection, and transport
compatibility checking. Delegates version-specific logic to modules under
`Anubis.Protocol.*` via `Anubis.Protocol.Registry`.

## Adding a new protocol version

1. Create a new module under `lib/anubis/protocol/` implementing `Anubis.Protocol.Behaviour`
2. Register it in `Anubis.Protocol.Registry`

# `feature`

```elixir
@type feature() :: atom()
```

# `version`

```elixir
@type version() :: String.t()
```

# `compatible_transports`

```elixir
@spec compatible_transports(version(), [module()]) :: [module()]
```

Returns transport modules that support a protocol version.

# `fallback_version`

```elixir
@spec fallback_version() :: version()
```

Returns the fallback protocol version for compatibility.

# `get_features`

```elixir
@spec get_features(version()) :: [feature()]
```

Returns the set of features supported by a protocol version.

Delegates to the version module's `supported_features/0` callback.

# `get_module`

```elixir
@spec get_module(version()) :: {:ok, module()} | :error
```

Returns the protocol module for a given version string.

## Examples

    iex> Anubis.Protocol.get_module("2025-06-18")
    {:ok, Anubis.Protocol.V2025_06_18}

# `latest_version`

```elixir
@spec latest_version() :: version()
```

Returns the latest supported protocol version.

# `negotiate_version`

```elixir
@spec negotiate_version(version(), version()) ::
  {:ok, version()} | {:error, Anubis.MCP.Error.t()}
```

Negotiates protocol version between client and server versions.

Returns the best compatible version or an error if incompatible.

# `supported_versions`

```elixir
@spec supported_versions() :: [version()]
```

Returns all supported protocol versions.

# `supports_feature?`

```elixir
@spec supports_feature?(version(), feature()) :: boolean()
```

Checks if a feature is supported by a protocol version.

# `validate_client_config`

```elixir
@spec validate_client_config(version(), module(), map()) ::
  :ok | {:error, Anubis.MCP.Error.t()}
```

Validates client configuration for protocol compatibility.

This function checks if the client configuration is compatible with
the specified protocol version, including transport and capabilities.

# `validate_transport`

```elixir
@spec validate_transport(version(), module()) :: :ok | {:error, Anubis.MCP.Error.t()}
```

Validates if a transport is compatible with a protocol version.

# `validate_version`

```elixir
@spec validate_version(version()) :: :ok | {:error, Anubis.MCP.Error.t()}
```

Validates if a protocol version is supported.

---

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