mcp-gateway-to-graphql
A utility layer enabling Model Context Protocol (MCP) consumers to interface with backend services exposing a GraphQL interface, featuring schema introspection capabilities and secure authenticated invocation of queries/mutations.
Author

jorgeraad
Quick Info
Actions
Tags
mcp-gateway-to-graphql - GraphQL Bridge for MCP Framework
This artifact is a Node.js/TypeScript runtime environment engineered to adhere to the Model Context Protocol (MCP). It functions as an intermediary component, permitting MCP-compliant clients (such as specialized code editors) to interact with an arbitrary, external GraphQL endpoint.
Core Functionality
- MCP Compliance: Fully implements the
Serverabstraction as defined within@modelcontextprotocol/sdk. - Transport Mechanism: Relies on standard input/output streams (
stdio) for bidirectional communication with the consuming client. - HTTP Client: Utilizes
axiosfor dispatching network operations towards the configured GraphQL Uniform Resource Locator (URL). - Exposed Capabilities: Offers the following distinct procedural interfaces to connected MCP clients:
introspectGraphQLSchema: Retrieves the structural definition (schema) of the remote GraphQL service via introspection queries.executeGraphQLOperation: Facilitates the transmission of user-defined GraphQL operations (queries or mutations) to the service, accepting parameters for the operation text, associated variables map, and an optional named operation identifier.
Operational Parameters
The execution environment mandates the setting of several system environment variables:
GRAPHQL_ENDPOINT: The absolute network address (URL) pointing to the service's GraphQL entry point.AUTH_TOKEN: An optional credential, formatted as a bearer token, to be included in theAuthorization: Bearer <token>request header for protected endpoints.
Client Integration Guide
To successfully engage the capabilities offered by this server within environments like Cursor or Claude Desktop, configuration of the execution command (typically via npx) is necessary.
Cursor Integration Steps
- Navigate to Cursor's MCP Configuration Panel (Menu Path: Cursor > Settings > Cursor Settings > MCP).
- Select the option to establish a new global MCP endpoint.
- Integrate the following configuration structure into Cursor's settings file:
json
{
"mcpServers": {
"mcp4gql": {
"command": "npx",
"type": "stdio",
"args": ["-y", "mcp4gql"],
"env": {
"GRAPHQL_ENDPOINT": "YOUR_GRAPHQL_ENDPOINT_URL",
"AUTH_TOKEN": "YOUR_OPTIONAL_AUTH_TOKEN"
}
}
}
}
Claude Desktop Integration Steps
- Access the settings interface within Claude Desktop (Menu Path: Claude > Settings).
- Navigate to the Developer Settings section and select 'Edit Config'.
-
Append the subsequent configuration block to your settings object:
json { "mcpServers": { "mcp4gql": { "command": "npx", "args": ["-y", "mcp4gql"], "env": { "GRAPHQL_ENDPOINT": "YOUR_GRAPHQL_ENDPOINT_URL", "AUTH_TOKEN": "YOUR_OPTIONAL_AUTH_TOKEN" } } } }
Upon successful setup, the MCP consumer should recognize and be able to invoke both introspectGraphQLSchema and executeGraphQLOperation. Ensure that the necessary environment variables (GRAPHQL_ENDPOINT and, if applicable, AUTH_TOKEN) are correctly propagated to the server instance during startup for establishing connectivity to the target API.
