Skip to content

feat: mcp server support in the router - #1786

Merged
StarpTech merged 41 commits into
mainfrom
dustin/eng-6881-mcp-support-in-the-router
Apr 18, 2025
Merged

feat: mcp server support in the router#1786
StarpTech merged 41 commits into
mainfrom
dustin/eng-6881-mcp-support-in-the-router

Conversation

@StarpTech

@StarpTech StarpTech commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

Motivation and Context

This PR adds the Model Context Protocol (MCP) server implementation to the Cosmo Router, enabling seamless integration between GraphQL APIs and AI models like Claude, ChatGPT, and other LLMs.

Key Features

  • MCP Server Implementation: Adds a dedicated MCP server implementation in the router
  • Persisted Operations Integration: Leverages existing persisted operations to expose secure GraphQL operations to AI models
  • Configurable Settings:
    • Enable/disable MCP server
    • Control port settings
    • Option to exclude mutations
    • Control schema exposure
    • Configure arbitrary operations execution
  • Comprehensive Test Coverage: Added tests for all MCP functionality

How It Works

The MCP server exposes GraphQL operations as AI-callable tools, allowing AI models to:

  1. Discover available operations
  2. Understand input requirements through JSON schemas
  3. Execute operations with appropriate parameters
  4. Process returned data in natural language responses

Use Cases

  • AI chatbots that query application data
  • Voice assistants integrated with business systems
  • Autonomous agents making data-informed decisions
  • AI-powered data analysis and content generation

Security Considerations

  • Respects existing authentication mechanisms
  • Built on persisted operations for controlled access
  • Optional flags to control mutation operations and schema exposure

Related PRs

Engine wundergraph/graphql-go-tools#1124
Docs wundergraph/cosmo-docs#48
Website https://github.com/wundergraph/website/pull/529

Checklist

@StarpTech
StarpTech marked this pull request as ready for review April 15, 2025 21:26
Comment thread router-tests/go.mod Outdated
Comment thread router-tests/testenv/testenv.go
Comment thread router-tests/testenv/testenv.go Outdated
Comment thread router/core/graph_server.go Outdated
Comment thread router/go.mod Outdated
Comment thread router/pkg/mcpserver/server.go Outdated
Comment thread router/pkg/mcpserver/server.go Outdated
Comment thread router/pkg/mcpserver/server.go
Comment thread router/pkg/mcpserver/strings.go Outdated
Comment thread router/pkg/schemaloader/loader.go Outdated
@StarpTech
StarpTech requested a review from jensneuse April 16, 2025 10:40
@github-actions

github-actions Bot commented Apr 17, 2025

Copy link
Copy Markdown

Router image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-f271d3719acbc2820b5885b424e182b320c50c97

@StarpTech
StarpTech merged commit 3bd8a5e into main Apr 18, 2025
@StarpTech
StarpTech deleted the dustin/eng-6881-mcp-support-in-the-router branch April 18, 2025 11:29
@victoriris

Copy link
Copy Markdown

Hi @StarpTech, is the mcp gateway already supported in the router setup with docker-compose?
Ran a local experiment, but even after seeing it start in the logs and exposing the port the service does not handle HTTP requests to it

@StarpTech

Copy link
Copy Markdown
Contributor Author

Hi @victoriris, to what exact setup are you referring to?

@victoriris

Copy link
Copy Markdown

@StarpTech I tried with the local docker examples + the MCP settings from the docs:

  1. router-only and exposing the default MCP port: https://cosmo-docs.wundergraph.com/router/download-and-install#docker
  2. full example, adding same mcp values to router config https://github.com/wundergraph/cosmo/blob/main/docker-compose.full.yml

Got both cases to run and load the operations, but the connection gets refused for the port 5025

@StarpTech

Copy link
Copy Markdown
Contributor Author

Hi @victoriris, this has been addressed in #1825. After this, you can set mcp.server.listen_addr to 0.0.0.0:5025 to make it work with docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants