
Mcp Graphql Bridge
io.github.murilojrpereira由 GitHub 帳號 murilojrpereira 發布v2.1.0更新於 Oct 24, 2026
Bridges any GraphQL API to Claude Code — auto-generates MCP tools via schema introspection.
概覽
透過內省 GraphQL 結構描述,將每個查詢與變更暴露為獨立的 MCP 工具,把任意 GraphQL API 接上助理。
- 可以做什麼
- 啟動時會內省 GraphQL 結構描述(或讀取本機的 schema-introspection.json),為每個查詢註冊一個工具(query ),為每個變更註冊一個工具(mutation ),並固定註冊通用的 execute_graphql 備援工具與 get_type_details 探索工具。各操作工具支援 __fields 選取集,以及每次呼叫可傳入的 bearer_token 與 custom_headers 覆寫參數。工具註冊數量可設上限,也可停用變更。
- 適用情境
- 當助理需要讀取或寫入某個特定 GraphQL API 時使用,特別適合欄位眾多、逐一手寫查詢不便的大型結構描述。可用於對公開示範 API 的零設定試用,也可用於需要驗證的企業 API。
- 執行需求
- 需要 Node.js >= 20 與 npm 套件 mcp-graphql-bridge(或從原始碼建置),以本機 stdio 程序執行。GRAPHQL_API_URL 與 GRAPHQL_INTROSPECTION_URL 指定端點,預設指向公開示範 API;GRAPHQL_TOKEN 與 GRAPHQL_INTROSPECTION_TOKEN 提供 Bearer 憑證。選用:GRAPHQL_MAX_TOOLS、GRAPHQL_INCLUDE_MUTATIONS、GRAPHQL_MAX_RETRIES,以及 HTTP 傳輸所需的 MCP_AUTH_TOKEN。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mcp Graphql Bridge,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-graphql-bridge
[npm version] [CI] [License: MIT] [Node.js >= 20]
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 >= 20
Setup
Step 1: Install
Option A: Install from npm (recommended)
Option B: Clone and build from source
Step 2: Configure environment variables
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:
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, 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:
If 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:
If cloned from source:
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)
Note: Use absolute paths. All
--envand--transportflags must come before the server name.
Verify the connection
Then in a Claude Code session, run /mcp to see available servers and tools.
MCP Registry
This server is published to the official MCP Registry as
io.github.murilojrpereira/mcp-graphql-bridge, so MCP clients that browse the registry can discover
and install it from there.
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:
-
Restart 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:
GRAPHQL_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
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
Add to Claude Code via Docker
Note: 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:
Health 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
See CONTRIBUTING.md for contribution guidelines and the maintainer release process.
Troubleshooting
Error: Cannot find module '.../index.js'
If you see an error like:
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 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
來源:README.md,提交 5eafd78
工具
0版本歷史
1- v2.1.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分