class ActionController::MCPServer::Transport
inherits Reference
#
implements the Streamable HTTP transport, statelessly. Each POST is handled on its own, so the requests of a client can be served by any instance of the application.
2026-07-28 requests carry their protocol version and client capabilities in _meta,
earlier versions start with initialize and no session is created
Constants#
META_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities"#
META_SERVER_INFO = "io.modelcontextprotocol/serverInfo"#
META_SUBSCRIPTION = "io.modelcontextprotocol/subscriptionId"#
META_VERSION = "io.modelcontextprotocol/protocolVersion"#
METHOD_HEADER = "Mcp-Method"#
NAME_HEADER = "Mcp-Name"#
NAMED_METHODS = {"tools/call" => "name", "prompts/get" => "name", "resources/read" => "uri"}#
methods that name a tool, prompt or resource in the Mcp-Name header
RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource"#
VERSION_HEADER = "MCP-Protocol-Version"#
Constructors#
.new(route_handler : Router::RouteHandler, path : String = "/mcp", endpoint : Bool = false, composition : Composition = Composition.default)#
endpoint: true serves the controller endpoint mounted at path
Methods#
#close_subscriptions : Nil#
completes every open subscriptions/listen stream, i.e. when shutting down. Clients
listen again, to another instance
#method_not_allowed(context : HTTP::Server::Context) : HTTP::Server::Context#
there are no event streams or sessions, so GET and DELETE aren't supported
#path : String#
the path the transport is mounted at, a template for controller endpoints
#post(context : HTTP::Server::Context) : HTTP::Server::Context#
client to server messages
#resource_metadata(context : HTTP::Server::Context) : HTTP::Server::Context#
OAuth 2.0 protected resource metadata, see MCPServer.resource_metadata