Skip to main content

Dynamic MCP server that auto-generates tools from any GraphQL API schema

Project description

GraphQL MCP Server

Python License MCP

A dynamic Model Context Protocol (MCP) server that automatically discovers and generates tools from any GraphQL API schema. Point it at any GraphQL endpoint and it instantly exposes every query and mutation as an MCP tool — zero manual configuration.


Installation

pip install graphql-mcp-server

Configuration

There are four ways to configure the server. They are applied in priority order — higher entries win:

Priority Method Best for
1 CLI arguments One-off runs, testing
2 Environment variables Docker, CI/CD, shell scripts
3 .env file Local development
4 Defaults Nothing required by default

Method 1 — CLI Arguments

graphql-mcp-server --endpoint https://api.example.com/graphql --token mytoken

All available flags:

--endpoint URL       GraphQL API endpoint (required if not set via env)
--token TOKEN        API access token for authentication
--mode stdio|http    Server mode (default: stdio)
--port PORT          HTTP port, only used in http mode (default: 8080)
--host HOST          HTTP host, only used in http mode (default: 0.0.0.0)
--log-level LEVEL    Logging level: DEBUG, INFO, WARNING, ERROR (default: INFO)
--env-file PATH      Path to a custom .env file
--version            Show version and exit

Method 2 — Environment Variables

export GRAPHQL_ENDPOINT=https://api.example.com/graphql
export API_ACCESS_TOKEN=your_token_here
export MCP_MODE=stdio

graphql-mcp-server

Method 3 — .env File

Create a .env file in your working directory:

GRAPHQL_ENDPOINT=https://api.example.com/graphql
API_ACCESS_TOKEN=your_token_here
MCP_MODE=stdio
LOG_LEVEL=INFO

Then just run:

graphql-mcp-server

Method 4 — Claude Desktop Config (most common for MCP use)

No .env file needed. Pass everything via the env block in claude_desktop_config.json:

{
  "mcpServers": {
    "graphql": {
      "command": "graphql-mcp-server",
      "env": {
        "GRAPHQL_ENDPOINT": "https://api.example.com/graphql",
        "API_ACCESS_TOKEN": "your_token_here",
        "MCP_MODE": "stdio",
        "ENABLE_HTTP_ENDPOINT": "false"
      }
    }
  }
}

Claude Desktop injects the env block values directly into the process — this is the standard MCP pattern.


Environment Variable Reference

Variable Required Default Description
GRAPHQL_ENDPOINT Yes GraphQL API URL
API_ACCESS_TOKEN No Bearer token for auth
MCP_MODE No stdio stdio or http
ENABLE_HTTP_ENDPOINT No true Enable HTTP health/metrics endpoints
MCP_SERVER_PORT No 8080 HTTP server port
MCP_SERVER_HOST No 0.0.0.0 HTTP server host
LOG_LEVEL No INFO Logging verbosity
QUERY_TIMEOUT No 30 Request timeout in seconds
SCHEMA_CACHE_TTL No 3600 Schema cache TTL in seconds

Operating Modes

MCP Mode (stdio) — for Claude Desktop, Cursor, MCP clients

graphql-mcp-server --endpoint https://api.example.com/graphql --mode stdio

Communicates via stdin/stdout. No HTTP server is started. This is the default.

HTTP Mode — for Docker, Kubernetes, server deployments

graphql-mcp-server --endpoint https://api.example.com/graphql --mode http --port 8080

Starts an HTTP server with health and metrics endpoints:

  • GET /health — health check
  • GET /metrics — server metrics
  • GET /schema — schema summary
  • GET /tools — all generated tools

Docker

docker build -t graphql-mcp-server .

docker run -p 8080:8080 \
  -e GRAPHQL_ENDPOINT=https://api.example.com/graphql \
  -e API_ACCESS_TOKEN=your_token \
  -e MCP_MODE=http \
  graphql-mcp-server

Or with Docker Compose:

cp .env.example .env   # fill in your values
docker-compose up

Key Features

  • Zero config queries — auto-introspects any GraphQL schema and generates MCP tools
  • Dual mode — stdio for MCP clients, HTTP for server deployments
  • Flexible config — CLI args, env vars, .env file, or Claude Desktop env block
  • Production ready — Docker, Kubernetes, AWS ECS, Google Cloud Run compatible
  • Self-documentinglist_available_queries, get_schema_info, get_query_signature tools built in

Troubleshooting

[ERROR] GraphQL endpoint not configured

Set GRAPHQL_ENDPOINT via any method above. The most common fix:

graphql-mcp-server --endpoint https://your-api.com/graphql

Port already in use

Change the port:

graphql-mcp-server --mode http --port 9090

Docker container exits immediately

Make sure you're using HTTP mode:

docker run -e MCP_MODE=http -e GRAPHQL_ENDPOINT=... graphql-mcp-server

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphql_mcp_server-1.0.2.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphql_mcp_server-1.0.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file graphql_mcp_server-1.0.2.tar.gz.

File metadata

  • Download URL: graphql_mcp_server-1.0.2.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for graphql_mcp_server-1.0.2.tar.gz
Algorithm Hash digest
SHA256 946576f2435f7ae8778dc5205d02a4a4753e1720e3bb666b81ab38edd2eff663
MD5 dcba6da2f859e93de88f223d84a83fb4
BLAKE2b-256 f03ea1ee509e632940f367bb00a7e44d116fa41402c57459597b8571728cbd70

See more details on using hashes here.

File details

Details for the file graphql_mcp_server-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for graphql_mcp_server-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 256cdde4a24bee3dbc153d8d673392c9662f2d1161c4bd9e3ac1ea278b24b6c5
MD5 8909dbb03785ff6f4ebd478c30ef2e30
BLAKE2b-256 e8b99e267febbf4b1074ff9222e81b8f99b31ac3176b4208042e9f7346da1883

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page