Retrieves the GraphQL schema from the endpoint. This tool should be used first if you don't have access to the schema as a resource. It uses either the local schema file or performs an introspection query.
Executes GraphQL queries against the configured endpoint. By default, mutations are disabled unless ALLOW_MUTATIONS is set to true.
GraphQL API Connector enables AI models to interact with any GraphQL API through dynamic schema introspection and query execution. This tool bridges the gap between language models and GraphQL endpoints, allowing models to discover available data structures and operations without prior knowledge of the API. With support for custom headers, optional mutation capabilities, and flexible configuration options, this connector makes GraphQL APIs accessible to AI assistants in a secure and controlled manner. The tool automatically handles schema introspection and provides a simple interface for executing queries against any GraphQL endpoint.
GraphQL API Connector allows AI models to interact with GraphQL APIs by providing schema introspection and query execution capabilities. This enables models to discover and use GraphQL APIs dynamically without needing prior knowledge of the specific schema.
You can install the GraphQL API Connector in several ways:
If you're using Claude Desktop, you can install automatically via Smithery:
npx -y @smithery/cli install mcp-graphql --client claude
To manually install the connector, add the following configuration to your client's settings:
{
"mcpServers": {
"mcp-graphql": {
"command": "npx",
"args": ["mcp-graphql"],
"env": {
"ENDPOINT": "http://localhost:3000/graphql"
}
}
}
}
The GraphQL API Connector is configured using environment variables:
| Environment Variable | Description | Default |
| --- | --- | --- |
| ENDPOINT
| GraphQL endpoint URL | http://localhost:4000/graphql
|
| HEADERS
| JSON string containing headers for requests | {}
|
| ALLOW_MUTATIONS
| Enable mutation operations (disabled by default) | false
|
| NAME
| Name of the MCP server | mcp-graphql
|
| SCHEMA
| Path to a local GraphQL schema file (optional) | - |
Basic usage with a local GraphQL server:
ENDPOINT=http://localhost:3000/graphql npx mcp-graphql
Using with custom headers (e.g., for authentication):
ENDPOINT=https://api.example.com/graphql HEADERS='{"Authorization":"Bearer token123"}' npx mcp-graphql
Enabling mutation operations:
ENDPOINT=http://localhost:3000/graphql ALLOW_MUTATIONS=true npx mcp-graphql
Using a local schema file instead of introspection:
ENDPOINT=http://localhost:3000/graphql SCHEMA=./schema.graphql npx mcp-graphql
By default, mutations are disabled as a security measure to prevent an AI model from modifying your database or service data. Consider carefully before enabling mutations in production environments.
If you need a more specific implementation with tighter controls, you may want to create a custom MCP server that limits tool calling to specific query fields and/or variables.
The GraphQL API Connector can also be run as a Docker container. The repository includes a Dockerfile for containerized deployment.