Gateway: MCP Server
Expose your GraphQL API to AI agents as MCP tools and resources with the Hive Gateway MCP plugin.
The Model Context Protocol (MCP) is the standard AI agents use
to discover and call external tools. With the @graphql-hive/plugin-mcp plugin, Hive Gateway
becomes an MCP server: you pick the GraphQL operations you want to expose, and each one becomes a
tool that agents can list and execute, complete with typed input and output schemas derived from
your supergraph.
The gateway takes care of loading the schema, generating input and output schemas, validating
arguments and formatting responses. You only define which operations become tools. The plugin
implements the initialize, tools/list, tools/call, resources/list, resources/read and
resources/templates/list MCP methods.
Installation
The package ships both CommonJS and ESM builds and needs graphql as a peer dependency.
Langfuse is an optional peer dependency, only needed when you use the
built-in Langfuse description provider.
Quick start
Register the plugin with the operations you want to expose. The simplest tool is an inline query.
Then start the gateway as usual, for example with hive-gateway supergraph.
The MCP endpoint is served at /mcp next to your GraphQL endpoint. Change it with the path
option.
Define tools with directives
Instead of listing tools in the configuration, you can annotate named operations in .graphql files
with the @mcpTool directive and point the plugin at them:
Every operation carrying @mcpTool is registered as a tool automatically. Operations without the
directive stay available as sources for tools declared in the configuration. All operations must be
named; anonymous operations are not supported. The Tools page covers the
@mcpDescription and @mcpHeader directives as well.
Define tools in YAML or JSON
The configuration object is plain data, so it can live in a YAML or JSON file that you load and pass
to useMCP:
Try it out
MCP speaks JSON-RPC over HTTP, so curl is enough to check the server:
Point any MCP client (an IDE assistant, an agent framework, or the MCP Inspector) at
http://localhost:4000/mcp to use the tools interactively.
Next steps
- Tools: tool sources, directives, input and output shaping, hooks and annotations.
- Resources and dynamic operations: serve documents alongside your tools and load operations from an external source at runtime.
- Description providers: manage tool and field descriptions in Langfuse or your own service.
- Configuration reference: every option of the plugin.
- Runnable examples in the Hive Gateway repository.