Graphql

io.github.Docat0209由 GitHub 帳號 Docat0209 發布v0.1.4更新於 Oct 27, 2026

Turn any GraphQL API into MCP tools. Zero config, zero code.

已驗證STDIO僅桌面資料庫開發者工具

概覽

AI 產生的概覽

透過內省 GraphQL 端點的結構定義,把每個查詢與變更自動變成 MCP 工具,讓助理直接呼叫。

可以做什麼
  • 透過內省探索 GraphQL 端點的查詢與變更,並把每個操作公開為獨立工具
  • 以扁平化的簡單參數呼叫查詢與變更,不需巢狀輸入物件
  • 用包含/排除規則與工具名稱前綴限制要公開哪些操作
  • 自動裁切陣列、限制巢狀深度與總長度,控制過大的回應
  • 將內省結構定義快取到本機以加快啟動,並可強制重新整理
  • 標示或封鎖 delete、remove、drop、purge 等破壞性變更
適用情境
適合讓助理直接使用某個 GraphQL API 而不必自行撰寫伺服器,例如公開的國家資訊 API 或需要權杖的 GitHub GraphQL API。適用於以讀取為主的探索,搭配安全設定也可進行受控的變更操作。
執行需求
透過 npx(Node.js)在本機以 stdio 程序執行,另有 SSE 傳輸選項。需要 GraphQL 端點網址及連線該端點的網路。驗證為選用,以命令列參數傳入:Bearer 權杖、API 金鑰(放在標頭或查詢參數)或自訂標頭。
安裝前請注意
Bearer 權杖與 API 金鑰以命令列參數提供,可能留在 shell 歷史紀錄或客戶端設定檔中。變更操作會公開為工具,可能修改或刪除資料;預設模式只會提出警告,建議改用安全模式排除破壞性操作。工具呼叫會把資料傳送到所設定的第三方端點,選用的結構定義快取檔會在本機保存端點網址。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Graphql,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

graphql-to-mcp

[npm version] [npm downloads] [License: MIT]

Turn any GraphQL API into MCP tools — zero config, zero code.

Point graphql-to-mcp at a GraphQL endpoint and it auto-generates one MCP tool per query/mutation via introspection. Works with Claude Desktop, Cursor, Windsurf, and any MCP client.

Quick Start

Try it now — no install needed:

bash
npx graphql-to-mcp https://countries.trevorblades.com/graphql

Or add to Claude Desktop / Cursor config:

json
{  "mcpServers": {    "countries": {      "command": "npx",      "args": ["-y", "graphql-to-mcp", "https://countries.trevorblades.com/graphql"]    }  }}

That's it. Claude can now query countries, continents, and languages.

Features

  • Zero config — just provide a GraphQL endpoint URL
  • Auto-introspection — discovers all queries and mutations automatically
  • Flat parameter schemas — nested input objects are flattened for better LLM accuracy
  • Smart truncation — large responses are intelligently pruned (array slicing + depth limiting)
  • Auth support — Bearer tokens, API keys (header or query)
  • Retry logic — automatic retries on 429/5xx with exponential backoff
  • Include/exclude filters — expose only the operations you want
  • Schema caching — skip re-introspection with --schema-cache for faster startup
  • Mutation safety — auto-detect destructive mutations (delete*, remove*, etc.) and warn or block them

Usage

CLI

bash
# Public API (no auth)npx graphql-to-mcp https://countries.trevorblades.com/graphql
# With bearer tokennpx graphql-to-mcp https://api.github.com/graphql --bearer ghp_xxxxx
# With API keynpx graphql-to-mcp https://api.example.com/graphql --api-key "X-API-Key:your-key:header"
# Filter operationsnpx graphql-to-mcp https://api.example.com/graphql --include "get*" --exclude "internal*"
# With prefix (avoid name collisions when using multiple APIs)npx graphql-to-mcp https://api.example.com/graphql --prefix myapi
# Cache schema locally for faster restartsnpx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json
# Force re-introspection (ignore cache)npx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json --force-refresh
# Block destructive mutations (delete*, remove*, etc.)npx graphql-to-mcp https://api.example.com/graphql --mutation-safety safe

Claude Desktop / Cursor Config

json
{  "mcpServers": {    "github": {      "command": "npx",      "args": [        "-y", "graphql-to-mcp",        "https://api.github.com/graphql",        "--bearer", "ghp_xxxxx",        "--prefix", "github"      ]    }  }}

Programmatic

typescript
import { createServer } from "graphql-to-mcp";
const server = await createServer({  endpoint: "https://api.example.com/graphql",  auth: { type: "bearer", token: "xxx" },  include: ["getUser", "listUsers"],});

How It Works

  1. Introspect — Fetches the GraphQL schema via introspection query
  2. Flatten — Nested InputObject types are flattened into simple key-value parameters (e.g., input.name → input_name)
  3. Generate — Each query/mutation becomes an MCP tool with a flat JSON Schema
  4. Execute — When an LLM calls a tool, the flat args are reconstructed into proper GraphQL variables and sent to your endpoint

Why Flat Schemas?

LLMs are significantly better at filling flat key-value parameters than deeply nested JSON objects. By flattening InputObject types, we get:

  • Higher accuracy in parameter filling
  • Fewer hallucinated nested structures
  • Better compatibility across different LLM providers

Options

OptionDescriptionDefault
--bearer <token>Bearer token auth—
--api-key <name:value:in>API key auth—
-H, --header <name:value>Custom header (repeatable)—
--include <pattern>Include only matching operationsall
--exclude <pattern>Exclude matching operationsnone
--prefix <name>Tool name prefix—
--timeout <ms>Request timeout30000
--max-retries <n>Retry on 429/5xx3
--transport <stdio|sse>MCP transportstdio
--schema-cache <path>Save/load introspection cache—
--force-refreshIgnore cache, re-introspectfalse
--mutation-safety <mode>warn | safe | unrestrictedwarn

Smart Truncation

GraphQL APIs can return large payloads that overwhelm LLM context windows. graphql-to-mcp automatically:

  • Slices arrays to 20 items (with metadata showing total count)
  • Prunes depth beyond 5 levels (with object/array summaries)
  • Hard truncates at 50K characters as a safety net

Schema Caching

Introspection queries can be slow on large schemas. Use --schema-cache to save the introspection result locally:

bash
# First run: introspects and saves to cachenpx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json
# Subsequent runs: loads from cache (instant startup)npx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json
# Force re-introspection when the API schema changesnpx graphql-to-mcp https://api.example.com/graphql --schema-cache ./schema.json --force-refresh

The cache file stores the endpoint URL and timestamp. If you point at a different endpoint, it automatically re-introspects.

Mutation Safety

By default, graphql-to-mcp detects destructive mutations and adds warnings to their descriptions. This helps LLMs understand the risk before executing them.

Detected patterns: delete*, remove*, drop*, clear*, truncate*, destroy*, purge*, reset* (case-insensitive).

ModeBehavior
warn (default)Adds "DESTRUCTIVE:" prefix to dangerous mutation descriptions
safeCompletely excludes dangerous mutations from the tool list
unrestrictedNo filtering or warnings (previous behavior)
bash
# Safe mode: only expose read queries + non-destructive mutationsnpx graphql-to-mcp https://api.example.com/graphql --mutation-safety safe
# Unrestricted: expose everything (use with caution)npx graphql-to-mcp https://api.example.com/graphql --mutation-safety unrestricted

Use with REST APIs Too

Pair with mcp-openapi to give Claude access to both REST and GraphQL APIs:

json
{  "mcpServers": {    "github-graphql": {      "command": "npx",      "args": ["-y", "graphql-to-mcp", "https://api.github.com/graphql", "--bearer", "ghp_xxx", "--prefix", "gh"]    },    "petstore-rest": {      "command": "npx",      "args": ["-y", "mcp-openapi", "https://petstore3.swagger.io/api/v3/openapi.json"]    }  }}

Related

  • mcp-openapi — Same zero-config approach for REST/OpenAPI APIs

License

MIT

來源:README.md,提交 3c6934d

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.4最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分