graphql-to-mcp
About
Turn any GraphQL API into MCP tools. Auto-introspection, flat schemas.
Details
- Author
- docat0209
- Categories
- Developer Tools, API, Other
Jump to
Setup
Install graphql-to-mcp in your MCP client (Claude Desktop, Cursor, Windsurf, and others).
Repository: https://github.com/docat0209/mcp-graphql
Follow the installation instructions in the repository README, then restart your MCP client.
Turn any GraphQL API into MCP tools — zero config, zero code.
Pointgraphql-to-mcpat 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.
npx graphql-to-mcp https://countries.trevorblades.com/graphql
Or add to Claude Desktop / Cursor config:
{ "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.
- Zero config— just provide a GraphQL endpoint URL
- Auto-introspection— discovers all queries and mutations automatically
- Flat parameter schemas— nestedinputobjects 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-cachefor faster startup
- Mutation safety— auto-detect destructive mutations (delete,remove, etc.) and warn or block them
# Public API (no auth) npx graphql-to-mcp https://countries.trevorblades.com/graphql # With bearer token npx graphql-to-mcp https://api.github.com/graphql --bearer ghp_xxxxx # With API key npx graphql-to-mcp https://api.example.com/graphql --api-key "X-API-Key:your-key:header" # Filter operations npx 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 restarts npx 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
{ "mcpServers": { "github": { "command": "npx", "args": [ "-y", "graphql-to-mcp", "https://api.github.com/graphql", "--bearer", "ghp_xxxxx", "--prefix", "github" ] } } }
import { createServer } from "graphql-to-mcp"; const server = await createServer({ endpoint: "https://api.example.com/graphql", auth: { type: "bearer", token: "xxx" }, include: ["getUser", "listUsers"], });
- Introspect— Fetches the GraphQL schema via introspection query
- Flatten— NestedInputObjecttypes are flattened into simple key-value parameters (e.g.,input.name→input_name)
- Generate— Each query/mutation becomes an MCP tool with a flat JSON Schema
- Execute— When an LLM calls a tool, the flat args are reconstructed into proper GraphQL variables and sent to your endpoint
LLMs are significantly better at filling flat key-value parameters than deeply nested JSON objects. By flatteningInputObjecttypes, we get:
- Higher accuracy in parameter filling
- Fewer hallucinated nested structures
- Better compatibility across different LLM providers
GraphQL APIs can return large payloads that overwhelm LLM context windows.graphql-to-mcpautomatically:
- Slices arraysto 20 items (with metadata showing total count)
- Prunes depthbeyond 5 levels (with object/array summaries)
- Hard truncatesat 50K characters as a safety net
Introspection queries can be slow on large schemas. Use--schema-cacheto save the introspection result locally:
# First run: introspects and saves to cache npx 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 changes npx 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.
By default,graphql-to-mcpdetects 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).
# Safe mode: only expose read queries + non-destructive mutations npx 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
Pair withmcp-openapito give Claude access to both REST and GraphQL APIs:
{ "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"] } } }
- mcp-openapi— Same zero-config approach for REST/OpenAPI APIs
This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.
Integrates Galley's GraphQL API with MCP clients. It automatically introspects the GraphQL schema for seamless use with tools like Claude and VS Code.
A strongly-typed MCP server that provides seamless access to any GraphQL API.
One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.
The MCP server for Bitrix24 provides AI assistants with structured access to the Bitrix24 API. It delivers up-to-date method descriptions, parameters, and valid values, allowing assistants to work with precise data instead of guesswork. This reduces code errors and accelerates Bitrix24 integration development.
MCP to read the Codex crypto data API so agents can write GraphQL queries.
Tool platform by IBM to build, test and deploy tools for any data source
One remote MCP server for 500+ production APIs — Stripe, HubSpot, Postgres, Gmail, and more. OAuth and API key auth, credential management, and a CLI.
An MCP server for interacting with the Postman API, requiring an API key.
Arbitrary code execution and tool-use platform for LLMs by Riza
A command-line tool for interacting with Shopify's Admin GraphQL API, Functions, and Polaris Web Components.
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.





