Basic Configuration
To enable MCP in your Cosmo Router, add the following to yourconfig.yaml:
Configuration Options
For OAuth-specific configuration, see OAuth 2.1 Authorization.
Environment Variables
All MCP options can also be set via environment variables:
For OAuth-related environment variables, see OAuth Configuration Reference.
Storage Providers
MCP loads operations from a configured storage provider. Currently, only thefile_system provider is supported:
Session Handling
The MCP server uses the Streamable HTTP transport and maintains per-session state via theMcp-Session-Id header. When deploying multiple Router instances, you need sticky sessions to ensure all requests for a session reach the same instance.
To configure sticky sessions:
- The Router returns a unique
Mcp-Session-Idresponse header when a session is established - Clients must include that value in subsequent requests as the
Mcp-Session-Idrequest header - Your load balancer or reverse proxy must route requests with the same
Mcp-Session-Idto the same instance
CORS
The MCP server automatically configures CORS to allow cross-origin requests from MCP clients. It setsAccess-Control-Allow-Origin: * and allows the required MCP headers (Mcp-Protocol-Version, Mcp-Session-Id, Authorization, Last-Event-ID). The Mcp-Session-Id and WWW-Authenticate headers are exposed in responses. If you have additional CORS headers configured on the router, they are merged with the MCP-specific headers.