mikhailgarber/stateful-graphql-mcp
If you are the rightful owner of stateful-graphql-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server that provides tools to interact with GraphQL endpoints.
GraphQL MCP Server
A Model Context Protocol (MCP) server that provides tools to interact with GraphQL endpoints. This server allows Claude Desktop to introspect GraphQL schemas and execute queries/mutations against any GraphQL API.
Features
- GraphQL Introspection: Discover available types, queries, and mutations in a GraphQL schema
- Query/Mutation Execution: Execute GraphQL queries and mutations with variables support
- Environment-based Configuration: Configure GraphQL endpoint and headers via environment variables
- Claude Desktop Integration: Ready to use with Claude Desktop
Tools Provided
1. graphql_introspect
Introspects the GraphQL schema to discover available types, queries, and mutations.
Parameters: None
Returns: The GraphQL schema in SDL format plus raw introspection data
2. graphql_execute
Executes GraphQL queries and mutations against the configured endpoint.
Parameters:
query(required): The GraphQL query or mutation to executevariables(optional): Variables to pass to the GraphQL query/mutation
Returns: The JSON response from the GraphQL endpoint
Setup
- Install dependencies:
npm install
- Build the project:
npm run build
- Create a
.envfile with your GraphQL configuration:
cp .env.example .env
- Edit
.envwith your GraphQL endpoint and headers:
GRAPHQL_ENDPOINT=https://your-graphql-api.com/graphql
GRAPHQL_HEADERS={"Authorization": "Bearer your-token", "Content-Type": "application/json"}
Claude Desktop Configuration
Add this server to your Claude Desktop configuration file:
macOS
~/Library/Application Support/Claude/claude_desktop_config.json
Windows
%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"graphql": {
"command": "node",
"args": ["/path/to/your/project/dist/index.js"],
"env": {
"GRAPHQL_ENDPOINT": "https://your-graphql-api.com/graphql",
"GRAPHQL_HEADERS": "{\"Authorization\": \"Bearer your-token\", \"Content-Type\": \"application/json\"}"
}
}
}
}
Development
Run in development mode:
npm run dev
Environment Variables
GRAPHQL_ENDPOINT: The URL of your GraphQL endpoint (required)GRAPHQL_HEADERS: JSON string containing headers to send with requests (optional)
Example Usage
Once configured with Claude Desktop, you can:
-
Introspect a schema:
- Ask Claude: "Can you introspect the GraphQL schema to see what's available?"
-
Execute queries:
- Ask Claude: "Can you run a query to get all users?"
- Claude will use the
graphql_executetool with an appropriate query
-
Execute mutations:
- Ask Claude: "Can you create a new user with name 'John' and email 'john@example.com'?"
- Claude will construct and execute the appropriate mutation
License
MIT