Skip to main content
This tutorial walks you through enabling MCP on the Cosmo Router, creating your first GraphQL operation, and connecting an AI tool to test it.

Prerequisites

  • A running Cosmo Router with a configured GraphQL schema (see Router Introduction)
  • An AI tool that supports MCP (Claude Desktop, Cursor, Windsurf, VS Code, or similar)

Step 1: Create an Operations Directory

Create a directory to store the GraphQL operations that will be exposed to AI models:

Step 2: Add Your First Operation

Create a file operations/getUsers.graphql with a named GraphQL operation. The description string becomes the tool description that AI models see:
Replace the operation above with a query that matches your actual GraphQL schema. The operation must be valid against your schema.

Step 3: Configure the Router

Add the MCP configuration to your config.yaml:
Setting exclude_mutations: true is a good starting point. You can enable mutations later once you’re comfortable with the setup.

Step 4: Start the Router

Start (or restart) your Cosmo Router. You should see a log message indicating the MCP server is listening:

Step 5: Connect Your AI Tool

Choose your AI tool and add the MCP server configuration:
Go to Settings > Tools & Integrations > MCP Servers and add:
Requires Cursor v0.48.0+ for Streamable HTTP support.

Step 6: Test It

In your AI tool, try a prompt like:
The AI model should discover your GetUsers operation (exposed as execute_operation_get_users) and be able to describe it. Then try:
The AI model will call the execute_operation_get_users tool and return the results.

What’s Next?

Create More Operations

Learn how to write effective operations with descriptions, handle mutations, and organize your operations directory.

Full Configuration

Explore all configuration options including session handling, storage providers, and advanced settings.

Secure with OAuth

Add OAuth 2.1 authorization with JWT validation and multi-level scope enforcement.

IDE Setup

Detailed setup guides for each AI tool, including header forwarding and authentication.