class

ActionController::MCPServer::Transport

Inherits Reference < Object

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"
SERVER_CARD_PATH = "/server-card"
SERVER_CARD_TYPE = "application/mcp-server-card+json"
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

Source

Instance methods

auth_cache
Source
bound

the path params bound from the URL, for controller endpoints

Source
close_subscriptions

completes every open subscriptions/listen stream, i.e. when shutting down. Clients listen again, to another instance

Source
method_not_allowed(context : HTTP::Server::Context) : HTTP::Server::Context

there are no event streams or sessions, so GET and DELETE aren't supported

Source
path

the path the transport is mounted at, a template for controller endpoints

Source
post(context : HTTP::Server::Context) : HTTP::Server::Context

client to server messages

Source
protocol
Source
resource_metadata(context : HTTP::Server::Context) : HTTP::Server::Context

OAuth 2.0 protected resource metadata, see MCPServer.resource_metadata

Source
server_card(context : HTTP::Server::Context) : HTTP::Server::Context

the server's Server Card, public and cacheable so browser based clients and registries can fetch it before connecting. OPTIONS answers CORS preflight requests

Source

Nested types