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: For OAuth-related environment variables, see OAuth Configuration Reference.

Storage Providers

MCP loads operations from a configured storage provider. A storage provider must be specified. See Storage Providers for more details on configuring storage providers.

Operation Directory

The router loads all .graphql and .gql files in the directory of a file_system provider:
Then reference this storage provider in your MCP configuration:

Operation Manifest

As an alternative to a directory, set storage.object_path to load the operations from one operation manifest file. The router polls the file and swaps the tools when its revision changes. It does not need a restart. You can use a file_system or an s3 provider. The cdn provider is not supported for MCP.
Keep these points in mind:
  • Change the revision on every edit. If the revision stays the same, the router ignores the edit.
  • At startup, the router does not start if it cannot read, parse, or prepare the manifest’s MCP operations.
  • If the router cannot read or parse a new manifest, it logs a warning and keeps the previous tools.
  • If an operation fails GraphQL parsing or validation, input-schema building or compilation, or scope computation (for example, exceeding max_scope_combinations), the entire candidate manifest is rejected. The router logs an error and keeps the last accepted tools and authorization requirements. A later valid revision can replace them.
  • Graph-config reloads revalidate the last accepted manifest against the new schema, not a newer rejected candidate. An incompatible schema causes the MCP reload to fail.
  • Anonymous operations, duplicate operation names, normalized tool-name collisions, unsupported subscriptions, and mutations excluded by configuration are still skipped rather than registered.
  • Stateless MCP sessions see tool changes on their next tools/list request.
  • On S3, the router sends If-None-Match with the last ETag, so it only downloads a changed manifest. S3-compatible stores that do not support If-None-Match still work, but the router then downloads the manifest on every poll.

Server Discovery

The MCP server implements the server/discover method. This method arrived in MCP protocol version 2026-07-28 as the successor to the initialize handshake. Clients call it to read the supported protocol versions, capabilities, and identity in one stateless request. The discover.instructions option sends natural-language guidance to MCP clients. Use it to tell AI agents how to work with your graph:
The server sends the instructions to every MCP client. This covers clients that connect with server/discover and clients that still use the legacy initialize handshake. The router advertises protocol version 2026-07-28 by default. In session-based mode (session.stateless: false), clients negotiate 2025-11-25 or older.

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).

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