Skip to main content

GraphQL-MCP

PyPI version Python versions License: MIT

📚 Documentation | 📦 PyPI | 🔧 GitHub


Instantly expose any GraphQL API as MCP tools for AI agents and LLMs.

GraphQL MCP works with any Python GraphQL library—Strawberry, Ariadne, Graphene, graphql-core, or graphql-api. If you already have a GraphQL API, you can expose it as MCP tools in minutes.

Features

  • ✅ Universal Compatibility - Works with any GraphQL library that produces a graphql-core schema
  • 🚀 Automatic Tool Generation - GraphQL queries and mutations become MCP tools instantly
  • 🔌 Remote GraphQL Support - Connect to any existing GraphQL endpoint
  • 🎯 Type-Safe - Preserves GraphQL types and documentation
  • 🔧 Built-in Inspector - Web interface for testing MCP tools
  • 📡 Multiple Transports - HTTP, SSE, and streamable-HTTP support

Installation

pip install graphql-mcp

Quick Start

With Strawberry (Popular)

Already using Strawberry? Expose it as MCP tools:

import strawberry
from graphql_mcp.server import GraphQLMCP
import uvicorn

@strawberry.type
class Query:
    @strawberry.field
    def hello(self, name: str = "World") -> str:
        return f"Hello, {name}!"

schema = strawberry.Schema(query=Query)

# Expose as MCP tools
server = GraphQLMCP(schema=schema._schema, name="My API")
app = server.http_app()

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8002)

That's it! Your Strawberry GraphQL API is now available as MCP tools.

With Ariadne

Using Ariadne? Same simple integration:

from ariadne import make_executable_schema, QueryType
from graphql_mcp.server import GraphQLMCP

type_defs = """
    type Query {
        hello(name: String = "World"): String!
    }
"""

query = QueryType()

@query.field("hello")
def resolve_hello(_, info, name="World"):
    return f"Hello, {name}!"

schema = make_executable_schema(type_defs, query)

# Expose as MCP tools
server = GraphQLMCP(schema=schema, name="My API")
app = server.http_app()

With Graphene

Graphene user? Works seamlessly:

import graphene
from graphql_mcp.server import GraphQLMCP

class Query(graphene.ObjectType):
    hello = graphene.String(name=graphene.String(default_value="World"))

    def resolve_hello(self, info, name):
        return f"Hello, {name}!"

schema = graphene.Schema(query=Query)

# Expose as MCP tools
server = GraphQLMCP(schema=schema.graphql_schema, name="My API")
app = server.http_app()

With graphql-api (Recommended)

For new projects, we recommend graphql-api for its decorator-based approach:

from graphql_api import GraphQLAPI, field
from graphql_mcp.server import GraphQLMCP

class API:
    @field
    def hello(self, name: str = "World") -> str:
        return f"Hello, {name}!"

api = GraphQLAPI(root_type=API)
server = GraphQLMCP.from_api(api)
app = server.http_app()

Remote GraphQL APIs

Already have a GraphQL API running? Connect to it directly:

from graphql_mcp.server import GraphQLMCP

# Connect to any GraphQL endpoint
server = GraphQLMCP.from_remote_url(
    url="https://api.github.com/graphql",
    bearer_token="your_token",
    name="GitHub API"
)

app = server.http_app()

Works with:

  • GitHub GraphQL API
  • Shopify GraphQL API
  • Hasura
  • Any public or private GraphQL endpoint

Documentation

Visit the official documentation for comprehensive guides, examples, and API reference.

Key Topics

How It Works

GraphQL MCP automatically:

  • Analyzes your GraphQL schema
  • Generates MCP tools from queries and mutations
  • Maps GraphQL types to MCP tool schemas
  • Converts naming to snake_case (e.g., addBook → add_book)
  • Preserves all documentation and type information

MCP Inspector

Built-in web interface for testing and debugging MCP tools:

MCP Inspector Interface

Enable with graphql_http=True to access the inspector in your browser. See the MCP Inspector documentation for details.

Compatibility

GraphQL MCP works with any Python GraphQL library that produces a graphql-core schema:

  • ✅ Strawberry - Modern, type-hint based GraphQL
  • ✅ Ariadne - Schema-first GraphQL
  • ✅ Graphene - Code-first GraphQL
  • ✅ graphql-api - Decorator-based GraphQL (recommended)
  • ✅ graphql-core - Reference implementation
  • ✅ Any GraphQL library using graphql-core schemas

Ecosystem Integration

Configuration

# Full configuration example
server = GraphQLMCP(
    schema=your_schema,
    name="My API",
    graphql_http=True,          # Enable GraphQL HTTP endpoint
    allow_mutations=True,       # Allow mutation tools
)

# Serve with custom configuration
app = server.http_app(
    transport="streamable-http",  # or "http" or "sse"
    stateless_http=True,         # Don't maintain client state
)

See the documentation for advanced configuration, authentication, and deployment guides.

License

MIT License - see LICENSE file for details.

Metadata

Release files for graphql-mcp 1.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graphql-mcp 1.7.0
File Size Uploaded Provenance Actions
graphql_mcp-1.7.0.tar.gz 347.6 kB Without provenance Details for graphql_mcp-1.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for graphql-mcp 1.7.0
File Interpreter ABI Platform Actions
graphql_mcp-1.7.0-py3-none-any.whl Python 3 none any Details for graphql_mcp-1.7.0-py3-none-any.whl

Total release size: 386.1 kB

Release files / graphql_mcp-1.7.0.tar.gz

Download URL graphql_mcp-1.7.0.tar.gz
Size 347.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5bf60113ba48aa5c5621abc6aa9bdd4490961b739b836e863ababb7876b8cceb
BLAKE2b-256 checksum
How to use checksums
364a4e37c48c9c657362586e50998eff67d1f6198654a13ed174c7d719ae439c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / graphql_mcp-1.7.0-py3-none-any.whl

Download URL graphql_mcp-1.7.0-py3-none-any.whl
Size 38.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8cf0fd76c766193aa90b9eac899868039a6f393e7ef876d4a54fe7fda948237
BLAKE2b-256 checksum
How to use checksums
7cf3d88154ce21bd17bc38fd2edda646f81fc10ae4ac93cf4b27ee172836a8db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for graphql-mcp 1.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.7.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page