This enhanced MCP server enables AI clients to securely interact with any GraphQL API through two main tools:
query-graphql: Execute GraphQL queries and mutations (mutations disabled by default, enable viaALLOW_MUTATIONSenvironment variable) with support for variables and dynamic authentication headers passed at runtimeintrospect-schema: Retrieve GraphQL schemas with optional filtering by type names (e.g.,["Query", "User"]) to reduce LLM context noise
Key Features:
Dynamic Authentication: Pass Authorization headers and API keys directly via tool arguments without server restarts
Multiple Schema Sources: Works with live endpoints, local schema files, or remote schema URLs
Robust Error Handling: Fixes common GraphQL variable parsing issues for better interoperability
MCP Compatibility: Drop-in replacement for
mcp-graphqlsupporting Claude Desktop, Cursor, and GlamaFlexible Deployment: Supports npx, Docker, and local Node.js execution
Provides tools for executing GraphQL queries and introspecting schemas against any GraphQL endpoint, with support for dynamic headers, filtered schema introspection, and configurable mutation controls
mcp-graphql-enhanced
An enhanced MCP (Model Context Protocol) server for GraphQL that fixes real-world interoperability issues between LLMs and GraphQL APIs.
Drop-in replacement for
mcp-graphql— with dynamic headers, robust variables parsing, and zero breaking changes.
✨ Key Enhancements
✅ Dynamic headers — pass
Authorization,X-API-Key, etc., via tool arguments (no config restarts)✅ Robust variables parsing — fixes
“Query variables must be a null or an object”error✅ Filtered introspection — request only specific types (e.g.,
typeNames: ["Query", "User"]) to reduce LLM context noise✅ Full MCP compatibility — works with Claude Desktop, Cursor, Glama
✅ Secure by default — mutations disabled unless explicitly enabled
🔍 Filtered Introspection (New!)
Avoid 50k-line schema dumps. Ask for only what you need:
@introspect-schema typeNames ["Query", "User"]
🔍 Debug & Inspect
Use the official MCP Inspector to test your server live:
Environment Variables (Breaking change in 1.0.0)
Note: As of version 1.0.0, command line arguments have been replaced with environment variables.
Environment Variable | Description | Default |
| GraphQL endpoint URL |
|
| JSON string containing headers for requests |
|
| Enable mutation operations (disabled by default) |
|
| Name of the MCP server |
|
| Path to a local GraphQL schema file or URL (optional) | - |
Examples
🖥️ Claude Desktop Configuration Examples
You can connect Claude Desktop to your GraphQL API using either the npx package (recommended for simplicity) or the Docker image (ideal for reproducibility and isolation).
✅ Option 1: Using npx
🐳 Option 2: Using Docker (auto-pull supported)
🧪 Option 3: Using node with local build (for development)
If you’ve cloned the repo and built the project (npm run build → outputs to dist/):
Resources
graphql-schema: The server exposes the GraphQL schema as a resource that clients can access. This is either the local schema file, a schema file hosted at a URL, or based on an introspection query.
Available Tools
The server provides two main tools:
introspect-schema: This tool retrieves the GraphQL schema or a filtered subset (via typeNames). Use this first if you don't have access to the schema as a resource. This uses either the local schema file, a schema file hosted at a URL, or an introspection query. Filtered introspection (typeNames) is only available when using a live GraphQL endpoint (not with SCHEMA file or URL).
query-graphql: Execute GraphQL queries against the endpoint. By default, mutations are disabled unless
ALLOW_MUTATIONSis set totrue.
Security Considerations
Mutations are disabled by default to prevent unintended data changes. Always validate HEADERS and SCHEMA inputs in production. Use HTTPS endpoints and short-lived tokens where possible.
Customize for your own server
This is a very generic implementation where it allows for complete introspection and for your users to do whatever (including mutations). If you need a more specific implementation I'd suggest to just create your own MCP and lock down tool calling for clients to only input specific query fields and/or variables. You can use this as a reference.
Enhanced MCP server for GraphQL with dynamic headers, filtered introspection and full variable support.