Anubis.Protocol (anubis_mcp v1.0.0)

Copy Markdown

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

Summary

Functions

Returns transport modules that support a protocol version.

Returns the fallback protocol version for compatibility.

Returns the set of features supported by a protocol version.

Returns the protocol module for a given version string.

Returns the latest supported protocol version.

Negotiates protocol version between client and server versions.

Returns all supported protocol versions.

Checks if a feature is supported by a protocol version.

Validates client configuration for protocol compatibility.

Validates if a transport is compatible with a protocol version.

Validates if a protocol version is supported.

Types

feature()

@type feature() :: atom()

version()

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

Functions

compatible_transports(version, transport_modules)

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

Returns transport modules that support a protocol version.

fallback_version()

@spec fallback_version() :: version()

Returns the fallback protocol version for compatibility.

get_features(version)

@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(version)

@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()

@spec latest_version() :: version()

Returns the latest supported protocol version.

negotiate_version(client_version, server_version)

@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()

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

Returns all supported protocol versions.

supports_feature?(version, feature)

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

Checks if a feature is supported by a protocol version.

validate_client_config(version, transport_module, capabilities)

@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(version, transport)

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

Validates if a transport is compatible with a protocol version.

validate_version(version)

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

Validates if a protocol version is supported.