MCP Gateway | Secure AI Access to GraphQL | WunderGraph Cosmo - WunderGraph
Give AI models secure, controlled access to your GraphQL API
The Cosmo Router exposes predefined GraphQL operations as MCP tools. AI models discover, read descriptions, and execute through the standardized protocol.
Works with Claude, Cursor, Windsurf, VS Code Copilot, and any MCP-compatible platform.
The problem
AI access to APIs needs guardrails
Exposing your GraphQL schema directly to AI gives them the keys to everything. Building custom integrations per platform multiplies maintenance work.
AI models can execute arbitrary queries against your schema
Without a control layer, AI systems can access any data your schema exposes, including sensitive fields your integration was not designed to reach.
Each AI platform needs its own integration code
Custom REST APIs, platform-specific adapters, and separate documentation for each AI tool create compounding maintenance overhead as more platforms emerge.
Compliance teams cannot audit AI data access
Without operation-level control, there is no definitive list of what data AI systems can request. Compliance sign-off requires that list.
Our solution
Predefined operations as MCP tools
The Cosmo Router implements an MCP server. It loads GraphQL operation files from a directory, validates them against your schema, and exposes them as tools AI models can discover and execute.
How MCP Gateway works
- Write GraphQL operation files. Add docstring descriptions using the September 2025 GraphQL spec. The description becomes the tool description AI models see.
- Enable MCP in the Router config. Point to the operations directory. Optionally exclude mutations for read-only access.
- AI tools connect to the MCP endpoint. They discover available operations as tools with their descriptions and JSON schema inputs.
- AI models call operations with appropriate parameters. The Router validates, executes against your schema, and returns structured data.
- Most client headers forward to the GraphQL execution layer. Use standard header authentication or the built-in OAuth 2.1 support.
Before & After
| Before Cosmo | With Cosmo |
|---|---|
| Custom integration code for each AI platform | Single MCP endpoint works with all MCP-compatible AI tools |
| Risk of AI executing arbitrary, harmful queries | Only predefined, validated operations are exposed by default |
| External documentation required for AI to understand APIs | Self-documenting operations with embedded descriptions |
| Separate AI-safe APIs built alongside real APIs | Same GraphQL API with controlled operation exposure |
Built-in tools
- execute_operation_*— For each operation in your directory, the server generates a corresponding tool with the pattern
execute_operation_<operation_name>. - get_operation_info— Retrieves detailed information about a specific operation including its input schema and execution guidance.
- get_schema— Provides the full GraphQL schema as a string. Only available when
expose_schemais enabled. - execute_graphql— Executes arbitrary queries. Only available when
enable_arbitrary_operationsis enabled.
Capabilities
What MCP Gateway provides
- Predefined operations, self-documenting tools, and granular access control.
- Supports the latest MCP specification with Streamable HTTP transport.
- The Router generates JSON schema for operation variables automatically. AI models understand input requirements without additional documentation.
- Embed rich descriptions in operation files using the September 2025 GraphQL spec. AI models read these as tool descriptions.
- Run the MCP server in stateless mode for horizontal scaling and load balancing.
- Most client headers forward to the GraphQL execution layer. Use header-based authentication or the built-in OAuth 2.1 authorization.
- Set
exclude_mutations: trueto expose only queries. Create a read-only AI access layer without code changes.
FAQ
MCP Gateway questions
- Which AI tools work with MCP Gateway?
- Can AI models execute arbitrary GraphQL queries?
- How do I make operations understandable to AI models?
- Can I prevent AI from running mutations?
- What MCP specification does Cosmo support?
- How do I handle authentication?
Deep dive in the MCP Gateway documentation.