mcp-graphql-bridge
This server bridges any GraphQL API to Claude Code, exposing GraphQL operations as MCP tools for AI interaction.
Auto-generated per-operation tools: On startup, the server introspects your GraphQL schema and registers individual tools for each query (
query__<name>) and mutation (mutation__<name>), giving Claude direct, structured access to every API operation.Generic fallback (
execute_graphql): Run arbitrary GraphQL queries or mutations by providing a full query/mutation string and optional variables.Type exploration (
get_type_details): Look up the fields available on any specific GraphQL type to understand its structure and craft appropriate selection sets.Custom field selection: Per-operation tools accept a
__fieldsargument to specify which fields to return; defaults to scalar fields only if omitted.Bearer token authentication: All API calls are authenticated via a configured bearer token for secure access to protected endpoints.
Flexible setup: Supports a pre-generated
schema-introspection.jsonfor faster startup or when live introspection is disabled. Can be installed via npm, built from source, or run as a Docker container, and integrated at user or project scope in Claude Code.
Allows interaction with any GraphQL API by introspecting its schema and exposing each query and mutation as individual tools, with a generic fallback tool for custom operations and a type explorer.
mcp-graphql-bridge
A generic MCP (Model Context Protocol) server that bridges any GraphQL API to Claude Code. It introspects your GraphQL schema and exposes each query and mutation as an individual tool, letting Claude interact with your API directly.
How it works
On startup the server will:
Look for a
schema-introspection.jsonfile in the working directory (fast, no network call)If not found, run live introspection against
GRAPHQL_INTROSPECTION_URLRegister one tool per query (
query__<name>) and one per mutation (mutation__<name>)Always register a generic
execute_graphqlfallback tool and aget_type_detailsexplorer tool
Related MCP server: GraphQL MCP Server
Requirements
Node.js >= 20
Setup
Step 1: Install
Option A: Install from npm (recommended)
npm install -g mcp-graphql-bridgeOption B: Clone and build from source
git clone https://github.com/murilojrpereira/mcp-graphql-bridge.git
cd mcp-graphql-bridge
npm install
npm run buildStep 2: Configure environment variables
Variable | Required | Description |
| No | Endpoint used for queries and mutations. Defaults to a public demo API (countries.trevorblades.com) if unset — replace with your own for real use. |
| No | Endpoint used for schema introspection. Defaults to |
| No | Bearer token for GraphQL authentication (used for query/mutation execution). Omit for public APIs. |
| No | Bearer token for schema introspection, if it requires different credentials than execution (e.g. a separate schema registry). Defaults to |
| No | Bearer token required by the hosted |
| No | Maximum number of query/mutation tools to register. Queries are prioritized over mutations when truncating. Default |
| No | Set to |
| No | Retries (0–5) for |
For schemas with hundreds of fields (GitHub's GraphQL API has 284 root fields — 32 queries, 252
mutations), GRAPHQL_MAX_TOOLS and GRAPHQL_INCLUDE_MUTATIONS are what keep registration bounded
and predictable. If the cap truncates the schema, stderr logs exactly how many queries/mutations
were registered vs. available.
No configuration is required to try the server — with nothing set, it starts
against the public demo API above and logs that it's doing so. See
docs/architecture.md for the full token model and
why the GraphQL endpoint is fixed per deployment rather than a per-request
parameter.
You can set these in a .env file at the project root:
GRAPHQL_API_URL=https://your-api.example.com/graphql
GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql
GRAPHQL_TOKEN=your-bearer-tokenOr pass them directly via the claude mcp add command (see below).
Step 3: (Optional) Pre-generate schema snapshot
By default the server introspects your schema live on startup — no file needed, and it automatically retries at a shallower query depth if your API rejects the full-depth attempt (some APIs, especially CDN-fronted ones, enforce a query depth limit). Use this step only if your API has introspection disabled entirely in production, or you want faster startup times:
curl -s -X POST https://your-api.example.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-bearer-token" \
-d '{"query":"{ __schema { queryType { fields { name description args { name description defaultValue type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } } type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } } } mutationType { fields { name description args { name description defaultValue type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } } type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } } } } }"}' \
> schema-introspection.jsonIf your API rejects this with a depth/complexity-limit error, shrink the ofType { ... } nesting
(each level resolves one more NonNull/List wrapper — most real-world types need 2-3 levels;
only doubly-wrapped lists like [[Int!]!]! need more).
Adding to Claude Code
Option A: User scope (just for you)
If installed from npm:
claude mcp add --transport stdio \
--env GRAPHQL_API_URL=https://your-api.example.com/graphql \
--env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
--env GRAPHQL_TOKEN=your-bearer-token \
graphql-bridge -- mcp-graphql-bridgeIf cloned from source:
claude mcp add --transport stdio \
--env GRAPHQL_API_URL=https://your-api.example.com/graphql \
--env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
--env GRAPHQL_TOKEN=your-bearer-token \
graphql-bridge -- node /absolute/path/to/mcp-graphql-bridge/dist/index.jsImportant: Make sure to use
mcp-graphql-bridge/dist/index.js(the compiled output), notmcp-graphql-bridge/index.js. The TypeScript source must be built first withnpm run build, and the entry point is in thedist/folder.
Option B: Project scope (shared with your team via .mcp.json)
claude mcp add --transport stdio --scope project \
--env GRAPHQL_API_URL=https://your-api.example.com/graphql \
--env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
--env GRAPHQL_TOKEN=your-bearer-token \
graphql-bridge -- mcp-graphql-bridgeNote: Use absolute paths. All
--envand--transportflags must come before the server name.
Verify the connection
claude mcp listThen in a Claude Code session, run /mcp to see available servers and tools.
Examples
Two worked walkthroughs — a small public schema with no configuration needed, then a large, real enterprise-scale schema requiring auth and tool-count limits.
Example 1: Countries API (small schema, no auth)
This is the zero-config default — nothing to install or configure beyond the server itself.
Add the server with no environment variables at all:
claude mcp add --transport stdio graphql-countries -- mcp-graphql-bridgeRestart Claude Code (or run
/mcpto confirmgraphql-countriesis connected). You should see tools likequery__country,query__countries, andquery__continents.Ask Claude:
Using graphql-countries, find the country with code "BR", then list its continent's other countries.
Claude calls
query__country({ code: "BR", __fields: "{ name continent { code name } }" }), thenquery__continentorquery__countries({ __fields: "{ name }" })filtered by the result.Try an invalid code to see error passthrough:
Look up the country with code "ZZZ".
Returns the GraphQL API's own error text — the bridge passes it through rather than masking it.
Example 2: GitHub GraphQL API (large schema, auth + tool limits)
GitHub's GraphQL API has 284 root fields (32 queries, 252 mutations) — far more than the
GRAPHQL_MAX_TOOLS default of 128, and it needs a token for every request, including
introspection (unlike GitHub's REST API, which allows some anonymous reads).
Add the server, scoped to read-only access:
export GH_TOKEN=ghp_your_personal_access_token # or: source a gitignored .env file first claude mcp add --transport stdio graphql-github \ --env GRAPHQL_API_URL=https://api.github.com/graphql \ --env GRAPHQL_INTROSPECTION_URL=https://api.github.com/graphql \ --env GRAPHQL_TOKEN=$GH_TOKEN \ --env GRAPHQL_INCLUDE_MUTATIONS=false \ graphql-bridge -- mcp-graphql-bridgeGRAPHQL_INCLUDE_MUTATIONS=falseregisters all 32 (read-only) queries and zero mutations — comfortably under the cap, and a meaningfully safer default for an AI agent than exposing all 252 write operations.Ask Claude:
Using graphql-github, look up the repository facebook/react and tell me its star count.
Claude calls
query__repository({ owner: "facebook", name: "react", __fields: "{ name stargazerCount }" }).To also reach mutations, drop
GRAPHQL_INCLUDE_MUTATIONS=falseand raise the cap (GRAPHQL_MAX_TOOLS=400), understanding that this exposes write access to your GitHub account scoped to whatever permissions your token has.
Available tools
Tool | Description |
| One tool per GraphQL query field |
| One tool per GraphQL mutation field |
| Generic fallback — run any query or mutation (mutations rejected if |
| Explore fields of a specific GraphQL type |
All per-operation tools accept a special __fields argument where you can provide a custom GraphQL selection set (e.g. { id name status }). If omitted, only scalar fields are returned.
Per-call auth override: every tool (including execute_graphql) also accepts bearer_token
and custom_headers arguments. If provided, they override GRAPHQL_TOKEN/no-auth for that single
request only, letting Claude switch credentials per call without restarting the server.
Security
The target API is fixed per deployment, never a per-request parameter. Individual tool calls can override credentials (
bearer_token,custom_headers) but never the destination host —GRAPHQL_API_URLis set once at deployment time. A shared server that let callers redirect it to an arbitrary destination would be a Server-Side Request Forgery (SSRF) primitive; this design rules that out by construction.Configured and per-call secrets are redacted from every response before it reaches the calling LLM.
GRAPHQL_INCLUDE_MUTATIONS=falseexcludes every mutation field from registration for a genuinely read-only deployment — a meaningful trust boundary GraphQL's type system already encodes, rather than relying on token scope alone. This is enforced forexecute_graphqltoo: it parses the query and rejects any mutation when this flag is off, rather than only omitting the conveniencemutation__*tools while leaving the generic fallback able to run anything.MCP_AUTH_TOKENgates the HTTP transport's/mcpendpoint for public-routable deployments; requests are capped at 10MB.
See docs/architecture.md for the full design rationale and
SECURITY.md to report a vulnerability.
Docker
Build the image
docker build -t mcp-graphql-bridge .Add to Claude Code via Docker
claude mcp add --transport stdio \
--env GRAPHQL_API_URL=https://your-api.example.com/graphql \
--env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
--env GRAPHQL_TOKEN=your-bearer-token \
graphql-bridge -- docker run -i --rm \
-e GRAPHQL_API_URL -e GRAPHQL_INTROSPECTION_URL -e GRAPHQL_TOKEN \
mcp-graphql-bridgeNote: The
-iflag (no-t) is required — it keeps stdin open for the MCP stdio protocol.
HTTP deployment
For hosted MCP access, run the HTTP transport instead of stdio:
docker build -f Dockerfile.http -t mcp-graphql-bridge-http .
docker run --rm -p 8080:8080 \
-e GRAPHQL_API_URL=https://your-api.example.com/graphql \
-e GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
-e GRAPHQL_TOKEN=your-bearer-token \
mcp-graphql-bridge-httpHealth checks are available at /health; MCP requests are served at /mcp.
For public-routable deployments, set MCP_AUTH_TOKEN and configure clients to send Authorization: Bearer <token> to /mcp.
See docs/deployment.md for AWS, Cloudflare, and other container hosting options.
Development
npm run dev # watch mode: rebuilds and restarts on file changes
npm run build # one-off TypeScript compile
npm start # run the compiled serverTroubleshooting
Error: Cannot find module '.../index.js'
If you see an error like:
Error: Cannot find module '/path/to/mcp-graphql-bridge/index.js'You are pointing to the wrong file. The TypeScript source must be compiled first, and the entry point is in the dist/ folder:
Correct path: /path/to/mcp-graphql-bridge/dist/index.js
Wrong path: /path/to/mcp-graphql-bridge/index.js
Fix:
Ensure you ran
npm run build(creates thedist/folder)Update your MCP configuration to use the full path ending in
/dist/index.js
Schema introspection fails
If the server starts but shows "Schema introspection failed", your GraphQL API may have introspection disabled in production. Use the curl command in step 3 of Setup to pre-generate a schema-introspection.json file.
Tools not appearing in Claude Code
Run
claude mcp listto verify the server is registeredRun
/mcpin a Claude Code session to see available toolsCheck that your GraphQL API's environment variables are set correctly (
GRAPHQL_API_URL,GRAPHQL_INTROSPECTION_URL,GRAPHQL_TOKEN) — these are optional and default to a public demo API, so if tools still aren't appearing with your own API configured, check its credentials and endpoint URLs
Available Tools
2 toolsexecute_graphqlA
Execute any GraphQL query or mutation against the API. Use this when no specific tool exists for your operation.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Full GraphQL query or mutation string including selection set | |
| variables | No | Variables for the operation | |
| bearer_token | No | Bearer token to authenticate this request (overrides GRAPHQL_TOKEN) | |
| custom_headers | No | Additional request headers as key-value pairs, e.g. {"X-Tenant-ID": "abc"} |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description must disclose behavioral traits. It does not mention potential side effects of mutations, authentication requirements (beyond parameter hints), rate limits, or error handling. The description is too minimal to convey safe usage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences pack purpose and usage guidelines with zero waste, frontloading the key action and fallback use.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema; description does not explain return format, errors, or the fact that the endpoint is pre-configured. Despite the complexity of a generic GraphQL executor, the description is incomplete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% (all 4 parameters have descriptions). The description adds no additional parameter semantics. Baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Execute any GraphQL query or mutation against the API', specifying the verb and resource. It distinguishes itself from sibling 'get_type_details' by being a generic executor.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly says 'Use this when no specific tool exists for your operation', providing clear when-to-use guidance. No exclusions, but the instruction is direct.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_type_detailsB
Get fields of a specific GraphQL type to know what to put in __fields
| Name | Required | Description | Default |
|---|---|---|---|
| typeName | Yes | GraphQL type name, e.g. 'Repository', 'User', 'Issue' |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must disclose all behavioral traits. It indicates a read operation, but does not mention error handling (e.g., invalid type name), response structure, or any side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, focused sentence with no extraneous text. It is front-loaded and efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite the tool's simplicity, the description omits output details. The agent does not know whether the response returns field names, types, or full schema; this is critical given no output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema already covers the single parameter with a clear description and examples. The tool description adds no extra meaning beyond prompting usage of '__fields'.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool gets fields of a specific GraphQL type and its purpose in GraphQL introspection. However, it does not differentiate from sibling tool execute_graphql, which may also retrieve type information.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'to know what to put in __fields' implies a use case, but there is no explicit guidance on when to use this tool versus execute_graphql, nor any when-not-to-use advice.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v2.1.0- Changed
execute_graphql2 fields changed- added
Input schema / properties / bearer_tokenAdded value: +{ + "description": "Bearer token to authenticate this request (overrides GRAPHQL_TOKEN)", + "type": "string" +} - added
Input schema / properties / custom_headersAdded value: +{ + "additionalProperties": { + "type": "string" + }, + "description": "Additional request headers as key-value pairs, e.g. {\"X-Tenant-ID\": \"abc\"}", + "type": "object" +}
- Changed
get_type_details1 field changed- changed
Input schema / properties / typeName / descriptionPrevious value: -"GraphQL type name, e.g. 'Machine', 'WorkOrder', 'Shift'"New value: +"GraphQL type name, e.g. 'Repository', 'User', 'Issue'"
2 tool updates
v1.0.1- First observed
execute_graphql - First observed
get_type_details
TDQS
Scored across 2 tools
The two tools serve clearly distinct purposes: executing GraphQL operations vs. retrieving type metadata. No overlap in functionality.
Both tool names follow a consistent verb_noun pattern using snake_case (execute_graphql, get_type_details), making the intent clear and predictable.
For a GraphQL bridge, two tools is minimal but still covers the essential operations of executing queries and exploring types. Slightly under-scoped but reasonable.
The tool surface covers core GraphQL operations (any query/mutation) and type introspection. Minor gaps exist (e.g., no dedicated tool for listing mutations), but the generic execute tool and type details suffice for agents familiar with GraphQL.
Maintenance
Related MCP Connectors
The Grafbase MCP server sits in front of a GraphQL API and exposes an MCP protocol-compliant interface that allows AI agents and LLMs to explore and query GraphQL APIs using natural language. It provides tools to search schemas, introspect types and fields, and execute GraphQL queries while minimizing context bloat by returning only relevant schema subsets, with built-in support for authentication, authorization, and configurable access control.
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
- QuallaaOAuthcom.quallaa
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceA MCP server that exposes GraphQL schema information to LLMs like Claude. This server allows an LLM to explore and understand large GraphQL schemas through a set of specialized tools, without needing to load the whole schema into the context114 npm47MIT
- AlicenseCqualityDmaintenanceA TypeScript server that provides Claude AI with seamless access to any GraphQL API through the Model Context Protocol.66 npm12MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact with GraphQL APIs by providing schema introspection and query execution capabilities.1,006 npm3MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables LLMs to interact with GraphQL APIs by providing schema introspection and query execution capabilities.5 npmMIT