Skip to content

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

View source

Methods#

#auth_cache : AuthCache#

View source

#bound : Array(String)#

the path params bound from the URL, for controller endpoints

View source

#close_subscriptions : Nil#

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

View 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

View source

#path : String#

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

View source

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

client to server messages

View source

#protocol : Protocol#

View source

#resource_metadata(context : HTTP::Server::Context) : HTTP::Server::Context#

OAuth 2.0 protected resource metadata, see MCPServer.resource_metadata

View source