Blog
/
Education

GraphQL Operation Descriptions: How a Spec Update Solved Our MCP Problem

cover
Ahmet Soormally

Ahmet Soormally

min read

TL;DR

The Cosmo MCP Gateway turns trusted GraphQL operations into MCP tools that AI agents can call. MCP tools need descriptions so LLMs can understand what each tool does. Without a standardized approach, teams had to choose between non-standard comments, custom directives, or separate configuration files. The September 2025 GraphQL spec update added official support for operation descriptions. Operations are now self-documenting, portable across all GraphQL tooling, and work with AI systems without custom infrastructure. Available in Cosmo Router v0.262.0.

The Problem

When we built the MCP Gateway for Cosmo, we ran into a documentation problem.

The gateway takes trusted GraphQL operations (the queries and mutations you've approved or curated) and exposes them as MCP tools that AI agents can call. But MCP tools need descriptions. Without them, AI models have to guess what a tool does based on the operation name and schema documentation. While we can generate descriptions from JSON Schema and SDL documentation, that doesn't capture the purpose of the tool as efficiently as a human-written description.

We wrote an internal RFC to solve this. Customers wanted to describe their operations without modifying the GraphQL schema or maintaining separate JSON configuration files.

The obvious answer seemed simple: just add descriptions to the operations themselves.

But GraphQL didn't support that. At least, not officially.

Three Options

The RFC evaluated three approaches. Each had trade-offs.

Option 1: Parse Comments (Like Apollo)

The first option was to parse comments:

1
2
3
4
5
6
7

Apollo does this. They have custom parsers that extract comments and treat them as documentation.

While Apollo's approach worked for their use case, it had limitations. Comments are part of the GraphQL spec grammar, but they're not included in the AST. They're stripped during parsing, which means they're not portable across tools. Different parsers handle them differently, and if you're building infrastructure that needs to be reliable and work across the ecosystem, this creates problems.

We didn't want to go down that path.

Option 2: Add a Custom Directive

The second option was to introduce a custom directive:

1
2
3
4
5
6

This would be spec-compliant. Directives are part of GraphQL, and we could vendor-namespace it.

But it adds complexity. We'd need to parse this custom directive even if it wasn't in the SDL. Every tool in the ecosystem would need to understand it. It's not portable. And it felt like we were working around the problem rather than solving it properly.

Option 3: Extend the Parser to Support Description Strings

The third option was to extend our GraphQL parser to support description strings on operations:

1
2
3
4
5
6
7

This syntax already existed for schema types. It's clean. It's consistent with how GraphQL documents everything else.

But there was a catch: operation descriptions weren't explicitly defined in the GraphQL spec.

They were a de facto standard (widely supported by tools like GraphQL Playground, Apollo Studio, and GraphiQL) but not officially part of the specification.

That made us nervous. We'd be implementing something that wasn't standardized, which could lead to compatibility issues down the line.

The Spec Update

In September 2025, the GraphQL specification was updated.

Operation descriptions became official.

Queries, mutations, subscriptions, and fragments can now have descriptions using the same triple-quoted string syntax as schema types:

1
2
3
4
5
6
7

That description is now part of the GraphQL document AST. It's standardized. It's portable. And it's exactly what we needed.

How It Works in the MCP Gateway

With official support for operation descriptions, the MCP Gateway can now read them directly from the GraphQL AST and expose them as tool descriptions.

When you define an operation like this:

1
2
3
4
5
6
7

The MCP Gateway automatically turns it into a tool:

1
2

No extra configuration. No custom parsing. No directives. Just standard GraphQL.

Impact

GraphQL schemas were self-describing, but operations weren't. You could introspect a schema to understand types, fields, and arguments. Operations required reading code. Now they're self-documenting.

For Developers:
  • Operations are self-documenting, making it easier to build documented backend-for-frontends
  • Documentation can't diverge from implementation
  • Code reviews are clearer
For AI Integration:
  • AI agents use operation descriptions for better tool selection
  • Clear descriptions reduce model errors
  • Operations are discoverable in AI workflows
For Infrastructure:
  • No custom parsers or metadata conventions needed
  • Descriptions work consistently across all GraphQL tools
  • Less custom code to maintain

Fragments Get Descriptions Too

The spec update also covers fragments:

1
2
3
4
5
6

This is particularly useful in federated graphs where fragments might span multiple subgraphs. When the MCP Gateway processes operations that include fragments with descriptions, it carries that context into tool metadata.

If multiple operations use UserFields, the fragment description provides consistent context across all of them.

Available Now in Cosmo Router

Support for operation descriptions is available in Cosmo Router v0.262.0 and later.

To use it:

  1. Add triple-quoted description strings to your operations
  2. Upgrade to Cosmo Router v0.262.0 or later
  3. The MCP Gateway will automatically expose operation descriptions as tool descriptions

No configuration changes required. The router reads descriptions directly from the GraphQL AST and makes them available to all downstream tooling.

Using It

With WunderGraph's MCP Gateway:
  • Operations with descriptions become self-documenting MCP tools
  • No separate documentation files or custom metadata needed
  • AI agents get standardized descriptions for better tool selection
Building GraphQL Tooling:
  • Standard way to document operations without custom conventions
  • Consistent with schema documentation syntax
  • Portable across all GraphQL tools that support the spec

GraphQL operations can now describe themselves. At WunderGraph, we're making sure those descriptions work seamlessly with AI tools.

Get Started

For full MCP integration, see the MCP Gateway Documentation .


Frequently Asked Questions (FAQ)

The spec now allows descriptions on executable definitions (queries, mutations, subscriptions, and fragments) using triple-quoted strings. Previously, descriptions were only available for type definitions in the schema.

Comments aren't part of the GraphQL specification. They get dropped during parsing and validation, so downstream tools like routers, IDEs, and AI systems never see them.

We looked at parsing comments like Apollo does, and adding a custom directive. Both approaches had downsides-comments aren't standardized, and custom directives add complexity and aren't portable.

The MCP Gateway can now read operation descriptions directly from the GraphQL AST and expose them as tool descriptions in MCP, making operations self-documenting without custom parsing or metadata conventions.

Yes. Support for operation descriptions is available in Cosmo Router v0.262.0 and later. The router reads descriptions directly from the GraphQL AST.


Ahmet Soormally

Ahmet Soormally

Principal Solutions Engineer at WunderGraph

Ahmet is a Principal Solutions Engineer at WunderGraph, helping teams adopt Cosmo. He leads technical evaluations, builds prototypes, and runs workshops to accelerate adoption, while improving SDKs, documentation, and onboarding to enhance the developer experience.