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.
README
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_URL - Register one tool per query (
query__<name>) and one per mutation (mutation__<name>) - Always register a generic
execute_graphqlfallback tool and aget_type_detailsexplorer tool
Requirements
- Node.js >= 18
Setup
Step 1: Install
Option A: Install from npm (recommended)
npm install -g mcp-graphql-bridge
Option B: Clone and build from source
git clone https://github.com/murilopereira/mcp-graphql-bridge.git
cd mcp-graphql-bridge
npm install
npm run build
Step 2: Configure environment variables
| Variable | Required | Description |
|---|---|---|
GRAPHQL_API_URL |
Yes | Endpoint used for queries and mutations |
GRAPHQL_INTROSPECTION_URL |
Yes | Endpoint used for schema introspection (can be the same as above) |
GRAPHQL_TOKEN |
Yes | Bearer token for authentication |
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-token
Or 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. Use this step only if your API has introspection disabled 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 } } } } } type { 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 } } } } } type { kind name ofType { kind name ofType { kind name } } } } } } }"}' \
> schema-introspection.json
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-bridge
If 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.js
Important: 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-bridge
Note: Use absolute paths. All
--envand--transportflags must come before the server name.
Verify the connection
claude mcp list
Then in a Claude Code session, run /mcp to see available servers and tools.
Available tools
| Tool | Description |
|---|---|
query__<name> |
One tool per GraphQL query field |
mutation__<name> |
One tool per GraphQL mutation field |
execute_graphql |
Generic fallback — run any query or mutation |
get_type_details |
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.
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-bridge
Note: The
-iflag (no-t) is required — it keeps stdin open for the MCP stdio protocol.
Development
npm run dev # watch mode: rebuilds and restarts on file changes
npm run build # one-off TypeScript compile
npm start # run the compiled server
Troubleshooting
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 registered - Run
/mcpin a Claude Code session to see available tools - Check that all required environment variables are set (
GRAPHQL_API_URL,GRAPHQL_INTROSPECTION_URL,GRAPHQL_TOKEN)
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。