Skip to main content

Basic Configuration

To enable MCP in your Cosmo Router, add the following to your config.yaml:

Configuration Options

For OAuth-specific configuration, see OAuth 2.1 Authorization.

Environment Variables

All MCP options can also be set via environment variables: When OAuth is enabled, the following additional environment variables are available:

Storage Providers

MCP loads operations from a configured file system storage provider. This allows you to centralize the configuration of operation sources:
Then reference this storage provider in your MCP configuration:
A storage provider must be specified to load GraphQL operations. See Storage Providers for more details on configuring storage providers.

Session Handling

The MCP server uses the Streamable HTTP transport and maintains per-session state via the Mcp-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:
  1. The Router returns a unique Mcp-Session-Id response header when a session is established
  2. Clients must include that value in subsequent requests as the Mcp-Session-Id request header
  3. Your load balancer or reverse proxy must route requests with the same Mcp-Session-Id to the same instance
For details, see your load balancer or reverse proxy documentation (e.g., F5 NGINX Plus — MCP Session Affinity).
The session.stateless configuration option is reserved for future use. Currently, the MCP server always operates in stateful mode regardless of this setting.

CORS

The MCP server automatically configures CORS to allow cross-origin requests from MCP clients. It sets Access-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.

Full Configuration Example