ExMCP.Plugs.ProtocolVersion (ex_mcp v1.0.0-rc.5)

Copy Markdown View Source

Plug for validating and extracting the MCP-Protocol-Version header.

This plug ensures that incoming HTTP requests carry a protocol version the server actually supports.

Behavior

  • If no header is present, the configured default (ExMCP.Internal.VersionRegistry.preferred_version/0) is assumed
  • If an unsupported version is provided, returns 400 Bad Request
  • Adds the validated version to conn.assigns[:mcp_version]

The supported list and the default both come from ExMCP.Internal.VersionRegistry, which is the single source of truth for protocol versions across the client, the server transports, and this plug.

Usage

plug ExMCP.Plugs.ProtocolVersion

Summary

Functions

Get the default protocol version.

Get the list of supported protocol versions.

Functions

default_version()

@spec default_version() :: String.t()

Get the default protocol version.

supported_versions()

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

Get the list of supported protocol versions.