graphql-to-mcp
Allows interaction with the GitHub GraphQL API, enabling AI agents to perform queries and mutations on GitHub data, such as repositories, issues, and pull requests.
Automatically transforms any GraphQL API into MCP tools by introspecting the endpoint and generating tools for all available queries and mutations.
graphql-to-mcp
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:
npx graphql-to-mcp https://countries.trevorblades.com/graphqlOr 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.
Related MCP server: mcp-openapi
Features
Zero config — just provide a GraphQL endpoint URL
Auto-introspection — discovers all queries and mutations automatically
Flat parameter schemas — nested
inputobjects are flattened for better LLM accuracySmart 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 startupMutation safety — auto-detect destructive mutations (
delete*,remove*, etc.) and warn or block them
Usage
CLI
# 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 safeClaude Desktop / Cursor Config
{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y", "graphql-to-mcp",
"https://api.github.com/graphql",
"--bearer", "ghp_xxxxx",
"--prefix", "github"
]
}
}
}Programmatic
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
Introspect — Fetches the GraphQL schema via introspection query
Flatten — Nested
InputObjecttypes 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
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
Option | Description | Default |
| Bearer token auth | — |
| API key auth | — |
| Custom header (repeatable) | — |
| Include only matching operations | all |
| Exclude matching operations | none |
| Tool name prefix | — |
| Request timeout | 30000 |
| Retry on 429/5xx | 3 |
| MCP transport | stdio |
| Save/load introspection cache | — |
| Ignore cache, re-introspect | false |
|
| warn |
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:
# 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-refreshThe 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).
Mode | Behavior |
| Adds "DESTRUCTIVE:" prefix to dangerous mutation descriptions |
| Completely excludes dangerous mutations from the tool list |
| No filtering or warnings (previous behavior) |
# 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 unrestrictedUse with REST APIs Too
Pair with mcp-openapi to 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"]
}
}
}Related
mcp-openapi — Same zero-config approach for REST/OpenAPI APIs
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceA bridge that exposes any GraphQL API as tools consumable by Large Language Models via the Model Context Protocol (MCP), automatically discovering and translating API capabilities with zero maintenance required.Last updated2312GPL 3.0
- Alicense-qualityDmaintenanceTurn any OpenAPI/Swagger spec into MCP tools. Zero config, zero code. Supports Swagger 2.0, OpenAPI 3.x, Bearer/API-key/OAuth2 auth, flat parameter schemas for better LLM accuracy, and smart response truncation.Last updated1003MIT
- Alicense-qualityDmaintenanceAutomatically generates MCP tools from any GraphQL API by introspecting its schema, supporting queries, mutations, and authentication.Last updated5GPL 3.0
- Alicense-qualityDmaintenanceAutomatically discovers and exposes any GraphQL API as MCP tools with zero configuration.Last updatedMIT
Related MCP Connectors
Hosted MCP endpoint with realistic fake data for prototyping agents. 12 tools, no setup.
Free public MCP for AI agents — 193 tools, 44 workflows. No API key.
Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Docat0209/mcp-graphql'
If you have feedback or need assistance with the MCP directory API, please join our Discord server