Skip to main content
Glama
murilojrpereira

mcp-graphql-bridge

mcp-graphql-bridge

npm version CI License: MIT Node.js >= 18

Ein generischer MCP-Server (Model Context Protocol), der jede GraphQL-API mit Claude Code verbindet. Er untersucht Ihr GraphQL-Schema und stellt jede Query und Mutation als einzelnes Tool bereit, sodass Claude direkt mit Ihrer API interagieren kann.

Funktionsweise

Beim Start führt der Server folgende Schritte aus:

  1. Er sucht nach einer schema-introspection.json-Datei im Arbeitsverzeichnis (schnell, kein Netzwerkaufruf)

  2. Falls nicht gefunden, führt er eine Live-Introspektion gegen die GRAPHQL_INTROSPECTION_URL durch

  3. Er registriert ein Tool pro Query (query__<name>) und eines pro Mutation (mutation__<name>)

  4. Er registriert immer ein generisches execute_graphql-Fallback-Tool und ein get_type_details-Explorer-Tool

Related MCP server: GraphQL MCP Server

Anforderungen

  • Node.js >= 18

Einrichtung

Schritt 1: Installation

Option A: Installation über npm (empfohlen)

npm install -g mcp-graphql-bridge

Option B: Klonen und Build aus dem Quellcode

git clone https://github.com/murilopereira/mcp-graphql-bridge.git
cd mcp-graphql-bridge
npm install
npm run build

Schritt 2: Umgebungsvariablen konfigurieren

Variable

Erforderlich

Beschreibung

GRAPHQL_API_URL

Ja

Endpunkt für Queries und Mutationen

GRAPHQL_INTROSPECTION_URL

Ja

Endpunkt für die Schema-Introspektion (kann derselbe wie oben sein)

GRAPHQL_TOKEN

Ja

Bearer-Token für die Authentifizierung

Sie können diese in einer .env-Datei im Projektstammverzeichnis festlegen:

GRAPHQL_API_URL=https://your-api.example.com/graphql
GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql
GRAPHQL_TOKEN=your-bearer-token

Oder übergeben Sie sie direkt über den Befehl claude mcp add (siehe unten).

Schritt 3: (Optional) Schema-Snapshot vorab generieren

Standardmäßig untersucht der Server Ihr Schema live beim Start – es ist keine Datei erforderlich. Verwenden Sie diesen Schritt nur, wenn Ihre API die Introspektion in der Produktion deaktiviert hat oder Sie schnellere Startzeiten wünschen:

curl -s -X POST https://your-api.example.com/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-bearer-token" \
  -d '{"query":"{ __schema { queryType { fields { name description args { name description defaultValue type { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } type { kind name ofType { kind name ofType { kind name } } } } } mutationType { fields { name description args { name description defaultValue type { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } type { kind name ofType { kind name ofType { kind name } } } } } } }"}' \
  > schema-introspection.json

Zu Claude Code hinzufügen

Option A: Benutzerbereich (nur für Sie)

Bei Installation über npm:

claude mcp add --transport stdio \
  --env GRAPHQL_API_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_TOKEN=your-bearer-token \
  graphql-bridge -- mcp-graphql-bridge

Bei Klonen aus dem Quellcode:

claude mcp add --transport stdio \
  --env GRAPHQL_API_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_TOKEN=your-bearer-token \
  graphql-bridge -- node /absolute/path/to/mcp-graphql-bridge/dist/index.js

Wichtig: Stellen Sie sicher, dass Sie mcp-graphql-bridge/dist/index.js (die kompilierte Ausgabe) verwenden, nicht mcp-graphql-bridge/index.js. Der TypeScript-Quellcode muss zuerst mit npm run build erstellt werden, und der Einstiegspunkt befindet sich im dist/-Ordner.

Option B: Projektbereich (für Ihr Team freigegeben über .mcp.json)

claude mcp add --transport stdio --scope project \
  --env GRAPHQL_API_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_TOKEN=your-bearer-token \
  graphql-bridge -- mcp-graphql-bridge

Hinweis: Verwenden Sie absolute Pfade. Alle --env- und --transport-Flags müssen vor dem Servernamen stehen.

Verbindung überprüfen

claude mcp list

Führen Sie dann in einer Claude Code-Sitzung /mcp aus, um die verfügbaren Server und Tools anzuzeigen.

Verfügbare Tools

Tool

Beschreibung

query__<name>

Ein Tool pro GraphQL-Query-Feld

mutation__<name>

Ein Tool pro GraphQL-Mutationsfeld

execute_graphql

Generisches Fallback – führt jede Query oder Mutation aus

get_type_details

Felder eines bestimmten GraphQL-Typs erkunden

Alle pro-Operation-Tools akzeptieren ein spezielles __fields-Argument, in dem Sie ein benutzerdefiniertes GraphQL-Auswahlset angeben können (z. B. { id name status }). Wenn es weggelassen wird, werden nur skalare Felder zurückgegeben.

Docker

Image erstellen

docker build -t mcp-graphql-bridge .

Zu Claude Code über Docker hinzufügen

claude mcp add --transport stdio \
  --env GRAPHQL_API_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_INTROSPECTION_URL=https://your-api.example.com/graphql \
  --env GRAPHQL_TOKEN=your-bearer-token \
  graphql-bridge -- docker run -i --rm \
  -e GRAPHQL_API_URL -e GRAPHQL_INTROSPECTION_URL -e GRAPHQL_TOKEN \
  mcp-graphql-bridge

Hinweis: Das -i-Flag (ohne -t) ist erforderlich – es hält stdin für das MCP-stdio-Protokoll offen.

Entwicklung

npm run dev   # watch mode: rebuilds and restarts on file changes
npm run build # one-off TypeScript compile
npm start     # run the compiled server

Fehlerbehebung

Fehler: Cannot find module '.../index.js'

Wenn Sie eine Fehlermeldung wie diese sehen:

Error: Cannot find module '/path/to/mcp-graphql-bridge/index.js'

Sie verweisen auf die falsche Datei. Der TypeScript-Quellcode muss zuerst kompiliert werden, und der Einstiegspunkt befindet sich im dist/-Ordner:

Korrekter Pfad: /path/to/mcp-graphql-bridge/dist/index.js Falscher Pfad: /path/to/mcp-graphql-bridge/index.js

Lösung:

  1. Stellen Sie sicher, dass Sie npm run build ausgeführt haben (erstellt den dist/-Ordner)

  2. Aktualisieren Sie Ihre MCP-Konfiguration, um den vollständigen Pfad mit Endung /dist/index.js zu verwenden

Schema-Introspektion schlägt fehl

Wenn der Server startet, aber "Schema introspection failed" anzeigt, hat Ihre GraphQL-API möglicherweise die Introspektion in der Produktion deaktiviert. Verwenden Sie den curl-Befehl in Schritt 3 der Einrichtung, um eine schema-introspection.json-Datei vorab zu generieren.

Tools erscheinen nicht in Claude Code

  1. Führen Sie claude mcp list aus, um zu überprüfen, ob der Server registriert ist

  2. Führen Sie /mcp in einer Claude Code-Sitzung aus, um die verfügbaren Tools anzuzeigen

  3. Überprüfen Sie, ob alle erforderlichen Umgebungsvariablen gesetzt sind (GRAPHQL_API_URL, GRAPHQL_INTROSPECTION_URL, GRAPHQL_TOKEN)

Available Tools

2 tools
execute_graphqlA

Execute any GraphQL query or mutation against the API. Use this when no specific tool exists for your operation.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesFull GraphQL query or mutation string including selection set
variablesNoVariables for the operation
bearer_tokenNoBearer token to authenticate this request (overrides GRAPHQL_TOKEN)
custom_headersNoAdditional request headers as key-value pairs, e.g. {"X-Tenant-ID": "abc"}

TDQS

A3.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description must disclose behavioral traits. It does not mention potential side effects of mutations, authentication requirements (beyond parameter hints), rate limits, or error handling. The description is too minimal to convey safe usage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences pack purpose and usage guidelines with zero waste, frontloading the key action and fallback use.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema; description does not explain return format, errors, or the fact that the endpoint is pre-configured. Despite the complexity of a generic GraphQL executor, the description is incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (all 4 parameters have descriptions). The description adds no additional parameter semantics. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Execute any GraphQL query or mutation against the API', specifying the verb and resource. It distinguishes itself from sibling 'get_type_details' by being a generic executor.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says 'Use this when no specific tool exists for your operation', providing clear when-to-use guidance. No exclusions, but the instruction is direct.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_type_detailsB

Get fields of a specific GraphQL type to know what to put in __fields

ParametersJSON Schema
NameRequiredDescriptionDefault
typeNameYesGraphQL type name, e.g. 'Repository', 'User', 'Issue'

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose all behavioral traits. It indicates a read operation, but does not mention error handling (e.g., invalid type name), response structure, or any side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, focused sentence with no extraneous text. It is front-loaded and efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite the tool's simplicity, the description omits output details. The agent does not know whether the response returns field names, types, or full schema; this is critical given no output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema already covers the single parameter with a clear description and examples. The tool description adds no extra meaning beyond prompting usage of '__fields'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool gets fields of a specific GraphQL type and its purpose in GraphQL introspection. However, it does not differentiate from sibling tool execute_graphql, which may also retrieve type information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'to know what to put in __fields' implies a use case, but there is no explicit guidance on when to use this tool versus execute_graphql, nor any when-not-to-use advice.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv2.1.0
    • Changedexecute_graphql2 fields changed
      • addedInput schema / properties / bearer_token
        Added value: +{
        +  "description": "Bearer token to authenticate this request (overrides GRAPHQL_TOKEN)",
        +  "type": "string"
        +}
      • addedInput schema / properties / custom_headers
        Added value: +{
        +  "additionalProperties": {
        +    "type": "string"
        +  },
        +  "description": "Additional request headers as key-value pairs, e.g. {\"X-Tenant-ID\": \"abc\"}",
        +  "type": "object"
        +}
    • Changedget_type_details1 field changed
      • changedInput schema / properties / typeName / description
        Previous value: -"GraphQL type name, e.g. 'Machine', 'WorkOrder', 'Shift'"New value: +"GraphQL type name, e.g. 'Repository', 'User', 'Issue'"
  2. 2 tool updatesv1.0.1
    • First observedexecute_graphql
    • First observedget_type_details

TDQS

A3.9/5.0

Scored across 2 tools

Disambiguation5/5

The two tools serve clearly distinct purposes: executing GraphQL operations vs. retrieving type metadata. No overlap in functionality.

Naming Consistency5/5

Both tool names follow a consistent verb_noun pattern using snake_case (execute_graphql, get_type_details), making the intent clear and predictable.

Tool Count4/5

For a GraphQL bridge, two tools is minimal but still covers the essential operations of executing queries and exploring types. Slightly under-scoped but reasonable.

Completeness4/5

The tool surface covers core GraphQL operations (any query/mutation) and type introspection. Minor gaps exist (e.g., no dedicated tool for listing mutations), but the generic execute tool and type details suffice for agents familiar with GraphQL.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    F
    maintenance
    A MCP server that exposes GraphQL schema information to LLMs like Claude. This server allows an LLM to explore and understand large GraphQL schemas through a set of specialized tools, without needing to load the whole schema into the context
    23 npm
    46
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables LLMs to interact with GraphQL APIs by providing schema introspection and query execution capabilities.
    889 npm
    3
    MIT