Skip to content

feat: add mcp plugin implementation#1932

Draft
adambenhassen wants to merge 53 commits intomainfrom
adam/mcp-prototype
Draft

feat: add mcp plugin implementation#1932
adambenhassen wants to merge 53 commits intomainfrom
adam/mcp-prototype

Conversation

@adambenhassen
Copy link
Contributor

No description provided.

@adambenhassen adambenhassen marked this pull request as draft February 6, 2026 08:20
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @adambenhassen, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the Model Context Protocol (MCP) integration into the GraphQL Hive Gateway. It enables the gateway to expose its underlying GraphQL operations as discoverable and executable "tools" for AI agents or other MCP-compatible clients. This is achieved through a new useMCP plugin, which handles MCP request routing, tool registration based on GraphQL schema introspection, and execution of GraphQL operations as defined by the protocol.

Highlights

  • Model Context Protocol (MCP) Integration: Introduced a new useMCP plugin within the gateway runtime, enabling the exposure of GraphQL operations as discoverable and executable tools for AI agents or other MCP-compatible clients.
  • Gateway Configuration for MCP: Added MCPConfig to the gateway's CLI configuration, allowing users to easily enable and configure the MCP endpoint and define which GraphQL operations should be exposed as tools.
  • Core MCP Logic Implementation: Developed a dedicated mcp module within the @graphql-hive/gateway-runtime package, encompassing the ToolRegistry, createMCPHandler, createGraphQLExecutor, and schema-converter utilities to manage tool registration, protocol handling, execution, and JSON schema generation from GraphQL types.
  • Example Usage: Included a new example (examples/mcp-example/run.ts) demonstrating how to set up a GraphQL subgraph and a gateway with the useMCP plugin, exposing mock weather API queries as MCP tools.
Changelog
  • examples/mcp-example/run.ts
    • Added a new example demonstrating a GraphQL subgraph and a gateway configured with the new useMCP plugin.
    • The example defines a mock weather API with weather and forecast queries.
    • It configures the useMCP plugin to expose these queries as get_weather and get_forecast tools.
  • packages/gateway/src/cli.ts
    • Imported MCPConfig type.
    • Added an optional mcp property to GatewayCLIBuiltinPluginConfig to allow MCP configuration via the CLI.
  • packages/gateway/src/config.ts
    • Implemented dynamic loading and activation of the useMCP plugin based on the gateway configuration.
  • packages/runtime/package.json
    • Added @modelcontextprotocol/sdk as a new dependency.
  • packages/runtime/src/index.ts
    • Exported useMCP, MCPConfig, and MCPToolConfig to make the MCP plugin publicly accessible.
  • packages/runtime/src/mcp/executor.ts
    • Added createGraphQLExecutor to handle the execution of GraphQL operations for MCP tools, including passing request headers.
  • packages/runtime/src/mcp/index.ts
    • Created an index file to consolidate exports for the new MCP module.
  • packages/runtime/src/mcp/protocol.ts
    • Added createMCPHandler to implement the server-side logic for the Model Context Protocol, handling initialize, tools/list, and tools/call methods.
  • packages/runtime/src/mcp/registry.ts
    • Introduced ToolRegistry to manage and register GraphQL operations as MCP tools, including generating JSON schemas for their inputs.
  • packages/runtime/src/mcp/schema-converter.ts
    • Added utility functions graphqlTypeToJsonSchema and operationToInputSchema to convert GraphQL types and operation variables into JSON Schema format.
  • packages/runtime/src/plugins/useMCP.ts
    • Implemented the useMCP gateway plugin, which sets up the MCP endpoint, manages schema introspection, and integrates the MCP handler and executor.
  • yarn.lock
    • Updated with new dependencies, including @modelcontextprotocol/sdk and its transitive dependencies.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@theguild-bot
Copy link
Collaborator

theguild-bot commented Feb 6, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-hive/gateway 2.5.10-alpha-fe6fd314380b611e2f6571d873a9595463235dc8 npm ↗︎ unpkg ↗︎
@graphql-hive/nestjs 2.0.51-alpha-fe6fd314380b611e2f6571d873a9595463235dc8 npm ↗︎ unpkg ↗︎
@graphql-hive/plugin-mcp 0.1.0-alpha-fe6fd314380b611e2f6571d873a9595463235dc8 npm ↗︎ unpkg ↗︎

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a prototype implementation of the Model Context Protocol (MCP) as a gateway plugin. The changes are extensive, adding the useMCP plugin, supporting logic for protocol handling, schema conversion to JSON Schema, and an example implementation. The overall structure is sound, but there are a few critical issues related to handling asynchronous operations and validating inputs that could lead to runtime errors and unreliable behavior. I've provided specific comments and suggestions to improve the robustness and correctness of the implementation.

@adambenhassen adambenhassen force-pushed the adam/mcp-prototype branch 3 times, most recently from 0490f31 to eb04752 Compare February 12, 2026 17:06
@adambenhassen adambenhassen force-pushed the adam/mcp-prototype branch 6 times, most recently from e100f5e to eea72b4 Compare February 27, 2026 15:16
@adambenhassen adambenhassen changed the title prototype mcp implementation MCP Plugin Implementation Feb 27, 2026
@adambenhassen adambenhassen changed the title MCP Plugin Implementation feat: add mcp plugin implementation Mar 4, 2026
@adambenhassen adambenhassen marked this pull request as ready for review March 11, 2026 15:12
@adambenhassen adambenhassen marked this pull request as draft March 11, 2026 15:59
@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2026

🚀 Snapshot Release (Binary for Linux-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2026

🚀 Snapshot Release (Binary for Linux-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2026

🚀 Snapshot Release (Binary for macOS-ARM64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2026

🚀 Snapshot Release (Bun Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.5.10-alpha-fe6fd314380b611e2f6571d873a9595463235dc8-bun

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2026

🚀 Snapshot Release (Node Docker Image)

The latest changes of this PR are available as image on GitHub Container Registry (based on the declared changesets):

ghcr.io/graphql-hive/gateway:2.5.10-alpha-fe6fd314380b611e2f6571d873a9595463235dc8

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2026

🚀 Snapshot Release (Binary for macOS-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

@theguild-bot
Copy link
Collaborator

theguild-bot commented Mar 11, 2026

🚀 Snapshot Release (Binary for Windows-X64)

The latest changes of this PR are available for download (based on the declared changesets).

Download

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants