Anubis. Protocol. Behaviour behaviour
(anubis_mcp v1.14.0)
Copy Markdown
Dialect contract that each MCP protocol version module must implement.
Each protocol version (e.g., 2024-11-05, 2025-03-26, 2025-06-18) implements
this behaviour to isolate version-specific logic. A version module owns
everything about its version: params and result schemas, full message
schemas, capability shaping, feature flags, transport rules, and the era
the version belongs to. Adding or removing a version means adding or
removing one module plus one entry in Anubis.Protocol.Registry.
Eras
Versions group into eras with structurally different session semantics:
:legacy— session-oriented versions with theinitializehandshake (all versions up to and including 2025-11-25):stateless— per-request versions without protocol-level sessions (2026-07-28 onward)
Version differences
- 2024-11-05: Initial spec, SSE transport, basic tools/resources/prompts
- 2025-03-26: Added Streamable HTTP, JSON-RPC batching, authorization framework, tool annotations
- 2025-06-18: Removed batching, added structured tool output, elicitation, resource_link type
- 2025-11-25: Added tasks (
tasks/get,tasks/result,tasks/list,tasks/cancel)
Summary
Types
Transport-level rules that vary per protocol version.
Callbacks
Returns the era this version belongs to (:legacy or :stateless).
Full {:multi, :method, branches} Peri schema for notification messages.
All notification methods supported by this version.
Peri schema for validating notification params by method for this version.
Progress notification params schema for this version.
Full {:multi, :method, branches} Peri schema for request messages.
All request methods supported by this version.
Peri schema for validating request params by method for this version.
Peri schema for validating a request's result by method for this version.
Shapes a server's declared capabilities for advertisement in this version.
List of features/capabilities this protocol version supports.
Checks if a feature is supported by this protocol version.
Transport-level rules in effect for this protocol version.
Returns the version string this module implements (e.g., '2025-03-26').
Types
@type era() :: :legacy | :stateless
@type feature() :: atom()
@type message() :: map()
@type method() :: String.t()
@type params() :: map()
Transport-level rules that vary per protocol version.
:batching— whether JSON-RPC batch arrays are part of the version:protocol_version_header— whether HTTP clients MUST send the negotiated version on theMCP-Protocol-Versionheader after initialize
@type version() :: String.t()
Callbacks
@callback era() :: era()
Returns the era this version belongs to (:legacy or :stateless).
@callback notification_message_schema() :: term()
Full {:multi, :method, branches} Peri schema for notification messages.
Includes the JSON-RPC envelope (jsonrpc, method, params) around each method's params schema.
@callback notification_methods() :: [method()]
All notification methods supported by this version.
Peri schema for validating notification params by method for this version.
@callback progress_params_schema() :: map()
Progress notification params schema for this version.
@callback request_message_schema() :: term()
Full {:multi, :method, branches} Peri schema for request messages.
Includes the JSON-RPC envelope (jsonrpc, method, params, id) around each method's params schema. This is the single source of truth for request validation and encoding in this version.
@callback request_methods() :: [method()]
All request methods supported by this version.
Peri schema for validating request params by method for this version.
Peri schema for validating a request's result by method for this version.
Returns nil for methods whose result this version does not model;
callers fall back to accepting any result.
Shapes a server's declared capabilities for advertisement in this version.
Takes the capabilities map declared by the server module and returns the subset this protocol version can advertise. Capabilities introduced by later versions are dropped so a negotiated session never advertises features its version does not model.
@callback supported_features() :: [feature()]
List of features/capabilities this protocol version supports.
Checks if a feature is supported by this protocol version.
@callback transport_rules() :: transport_rules()
Transport-level rules in effect for this protocol version.
@callback version() :: version()
Returns the version string this module implements (e.g., '2025-03-26').