Builds and validates MCP _meta objects.
MCP 2026-07-28 moves protocol version and client capabilities into every request. This module owns those reserved fields and the common metadata key grammar so outbound and inbound paths cannot drift.
Summary
Functions
Builds the metadata required on a modern request.
Returns the reserved per-request client-capabilities key.
Parses a _meta object according to its message kind.
Parses optional notification metadata.
Parses and validates metadata on a modern request.
Parses optional result metadata.
Returns the reserved request protocol-version key.
Returns whether a key's prefix is reserved for MCP protocol use.
Returns whether a metadata key follows the MCP key grammar.
Validates the keys of a metadata object.
Types
Functions
@spec build_request_meta(map(), String.t(), map(), keyword()) :: {:ok, map()} | {:error, validation_error()}
Builds the metadata required on a modern request.
Caller metadata is preserved after key validation. ExMCP always overwrites
protocolVersion, clientCapabilities, and clientInfo with the connection
values supplied here. Optional W3C trace-context fields may be supplied via
:trace_context.
@spec client_capabilities_key() :: String.t()
Returns the reserved per-request client-capabilities key.
@spec parse(map() | nil, kind()) :: {:ok, map()} | {:error, validation_error()}
Parses a _meta object according to its message kind.
@spec parse_notification_meta(map() | nil) :: {:ok, map()} | {:error, validation_error()}
Parses optional notification metadata.
@spec parse_request_meta(map()) :: {:ok, map()} | {:error, validation_error()}
Parses and validates metadata on a modern request.
@spec parse_result_meta(map() | nil) :: {:ok, map()} | {:error, validation_error()}
Parses optional result metadata.
@spec protocol_version_key() :: String.t()
Returns the reserved request protocol-version key.
Returns whether a key's prefix is reserved for MCP protocol use.
Returns whether a metadata key follows the MCP key grammar.
@spec validate(map()) :: :ok | {:error, validation_error()}
Validates the keys of a metadata object.