Use Cosmo MCP to Work with GraphQL Federation Without Leaving Your IDE

Working with GraphQL Federation can involve a lot of jumping between tools. You may need to examine your schema in one tab, validate queries in another, and run CLI commands in the terminal. Cosmo MCP helps streamline this process by allowing you to work directly in your IDE. You won’t need to leave your editor to validate a query or configure your router. Everything is brought together in one environment, allowing you to stay focused on the task at hand. What Cosmo MCP Does MCP stands for Model Context Protocol. It’s a layer built into the Cosmo CLI that lets your IDE communicate with it over stdio. There’s nothing extra to install or manage. Everything runs locally, just like it would if you were manually running the CLI from the terminal. What makes it useful is that your IDE can now request and respond to structured output from the CLI. When you describe what you’re trying to do, the model can use the same tools you already use to validate queries, check composition, and edit schemas. How to Set It Up To get started, you need to get an API key from Cosmo Studio. Once you have that, you can set up your IDE to launch the CLI in MCP mode. The configuration might look like: { "mcpServers": { "cosmo": { "command": "npx wgc", "args": ["mcp"], "env": { "COSMO_API_KEY": "cosmo_" } } } } When this is in place, the editor can communicate with the CLI through Agent Mode and run federation-aware workflows. Exploring the Schema in Your Editor If you’ve ever paused development to open up a schema explorer or search GraphiQL for a field name, this part of Cosmo MCP will feel familiar. You can describe what you’re trying to query, for example, adding a department field to an employee query, and the model will look up the relevant type, modify the query, and make sure it’s valid with the verify_query_against_remote_schema tool. Proposing Schema Changes Schema updates in a federated system aren’t always straightforward. You need to know where a type is defined, figure out which Subgraph owns it, and then confirm that your changes aren’t going to break anything. Cosmo MCP simplifies this through the schema_change_proposal_workflow. When you describe a change, like adding a new field to an existing type, the CLI will identify the relevant Subgraph, apply the proposed update, and run composition and validation checks. Once complete, you can review the diff and see what changed before committing anything. This makes schema changes more accessible and safer to perform, even if you’re still getting comfortable with Federation concepts. Starting with a “Dream Query” Sometimes it’s easier to write the query you want and let the tooling figure out what’s missing. That’s what the dream query workflow supports. Start by writing a query that doesn’t currently work. The CLI will check against the Supergraph schema and return validation errors. Then, based on those results, it proposes schema changes that would make the query valid. This workflow is helpful for developers who may not be familiar with the full structure of the schema or the ownership rules behind it. It allows schema evolution to follow real usage patterns instead of planning everything. Validating Router Configuration Another area where Cosmo MCP is helpful is router configuration. When you need to adjust headers, set up CORS, or something more advanced, introducing small errors can happen easily. With Cosmo MCP, the model can load the router’s JSON Schema to understand what values are valid. Then it builds a configuration block, validates it with verify_router_config, and returns a detailed error message if anything goes wrong. And if necessary, it will adjust the configuration and try again. There’s also a tool for searching the full Cosmo documentation directly. If your question is broader, such as how rate limiting works, the model can retrieve specific sections and include them in the response. Try It for Yourself Cosmo MCP brings Federation workflows into the place where most developers already spend their time: the editor. Whether you're updating a schema, validating a query, or configuring the router, you can do it without breaking your flow. If you want more examples or a detailed breakdown of each workflow, check out the original post with full context: Read the full technical post here

Apr 18, 2025 - 20:02
 0
Use Cosmo MCP to Work with GraphQL Federation Without Leaving Your IDE

Working with GraphQL Federation can involve a lot of jumping between tools. You may need to examine your schema in one tab, validate queries in another, and run CLI commands in the terminal.
Cosmo MCP helps streamline this process by allowing you to work directly in your IDE. You won’t need to leave your editor to validate a query or configure your router. Everything is brought together in one environment, allowing you to stay focused on the task at hand.

What Cosmo MCP Does

MCP stands for Model Context Protocol. It’s a layer built into the Cosmo CLI that lets your IDE communicate with it over stdio. There’s nothing extra to install or manage. Everything runs locally, just like it would if you were manually running the CLI from the terminal.

What makes it useful is that your IDE can now request and respond to structured output from the CLI. When you describe what you’re trying to do, the model can use the same tools you already use to validate queries, check composition, and edit schemas.

How to Set It Up

To get started, you need to get an API key from Cosmo Studio. Once you have that, you can set up your IDE to launch the CLI in MCP mode. The configuration might look like:

{
  "mcpServers": {
    "cosmo": {
      "command": "npx wgc",
      "args": ["mcp"],
      "env": {
        "COSMO_API_KEY": "cosmo_"
      }
    }
  }
}

When this is in place, the editor can communicate with the CLI through Agent Mode and run federation-aware workflows.

Exploring the Schema in Your Editor

If you’ve ever paused development to open up a schema explorer or search GraphiQL for a field name, this part of Cosmo MCP will feel familiar. You can describe what you’re trying to query, for example, adding a department field to an employee query, and the model will look up the relevant type, modify the query, and make sure it’s valid with the verify_query_against_remote_schema tool.

Proposing Schema Changes

Schema updates in a federated system aren’t always straightforward. You need to know where a type is defined, figure out which Subgraph owns it, and then confirm that your changes aren’t going to break anything. Cosmo MCP simplifies this through the schema_change_proposal_workflow.

When you describe a change, like adding a new field to an existing type, the CLI will identify the relevant Subgraph, apply the proposed update, and run composition and validation checks. Once complete, you can review the diff and see what changed before committing anything.

This makes schema changes more accessible and safer to perform, even if you’re still getting comfortable with Federation concepts.

Starting with a “Dream Query”

Sometimes it’s easier to write the query you want and let the tooling figure out what’s missing. That’s what the dream query workflow supports. Start by writing a query that doesn’t currently work. The CLI will check against the Supergraph schema and return validation errors. Then, based on those results, it proposes schema changes that would make the query valid.

This workflow is helpful for developers who may not be familiar with the full structure of the schema or the ownership rules behind it. It allows schema evolution to follow real usage patterns instead of planning everything.

Validating Router Configuration

Another area where Cosmo MCP is helpful is router configuration. When you need to adjust headers, set up CORS, or something more advanced, introducing small errors can happen easily.

With Cosmo MCP, the model can load the router’s JSON Schema to understand what values are valid. Then it builds a configuration block, validates it with verify_router_config, and returns a detailed error message if anything goes wrong. And if necessary, it will adjust the configuration and try again.

There’s also a tool for searching the full Cosmo documentation directly. If your question is broader, such as how rate limiting works, the model can retrieve specific sections and include them in the response.

Try It for Yourself

Cosmo MCP brings Federation workflows into the place where most developers already spend their time: the editor. Whether you're updating a schema, validating a query, or configuring the router, you can do it without breaking your flow.

If you want more examples or a detailed breakdown of each workflow, check out the original post with full context:

Read the full technical post here