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

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 (also returned by ExMCP.protocol_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 default come from ExMCP's canonical internal version registry, so clients, server transports, and this plug cannot drift.

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.