GraphQL Bridge
STDIONode.js/TypeScript server implementing MCP protocol to bridge clients with GraphQL APIs.
Node.js/TypeScript server implementing MCP protocol to bridge clients with GraphQL APIs.
This project is a Node.js/TypeScript server that implements the Model Context Protocol (MCP). It acts as a bridge, allowing MCP clients (like Cursor) to interact with a target GraphQL API.
Server
class from @modelcontextprotocol/sdk
.axios
to send requests to the configured GraphQL endpoint.introspectGraphQLSchema
: Fetches the target GraphQL API schema using introspection.executeGraphQLOperation
: Executes arbitrary GraphQL queries or mutations against the target API, taking query
, optional variables
, and optional operationName
as input.The server requires the following environment variables:
GRAPHQL_ENDPOINT
: The URL of the target GraphQL API.AUTH_TOKEN
: A bearer token for an optional Authorization: Bearer <token>
header for authenticating with the GraphQL API.To allow clients like Cursor or Claude Desktop to use the tools provided by this server, you need to configure them to run the npx
command.
Go to Cursor MCP Settings (Cursor > Settings > Cursor Settings > MCP)
Go to + Add new global MCP server
Add the following to your Cursor MCP configuration:
{ "mcpServers": { "mcp4gql": { "command": "npx", "type": "stdio", "args": ["-y", "mcp4gql"], "env": { "GRAPHQL_ENDPOINT": "YOUR_GRAPHQL_ENDPOINT_URL", "AUTH_TOKEN": "YOUR_OPTIONAL_AUTH_TOKEN" } } } }
Open Claude Desktop settings (Claude > Settings).
Go to Developer > Edit Config.
Add to the config:
{ "mcpServers": { "mcp4gql": { "command": "npx", "args": ["-y", "mcp4gql"], "env": { "GRAPHQL_ENDPOINT": "YOUR_GRAPHQL_ENDPOINT_URL", "AUTH_TOKEN": "YOUR_OPTIONAL_AUTH_TOKEN" } } } }
Once configured, the MCP client should be able to list and call the introspectGraphQLSchema
and executeGraphQLOperation
tools provided by this server when relevant. Remember to set the required environment variables (GRAPHQL_ENDPOINT
and optionally AUTH_TOKEN
) in the configuration so the server can connect to your API.