Apollo MCP Demo
Apollo MCP Demo
Dieser Ordner richtet die gleiche Kernarchitektur ein, die Apollo für MCP demonstriert:
eine normale GraphQL-API,
einen Apollo MCP-Server davor,
eine kleine Positivliste von GraphQL-Operationen, die zu MCP-Tools werden.
Diese Version verwendet den eigenständigen Apollo MCP-Server-Container anstelle des rover init --mcp-Assistenten, da er einfacher lokal ohne GraphOS-Anmeldedaten ausgeführt werden kann.
Was gestartet wird
api: ein kleiner Apollo-Server unterhttp://localhost:4001/mcp: Apollo MCP-Server unterhttp://localhost:8000/mcp
Related MCP server: mcp4gql
Architekturdiagramm
flowchart LR
subgraph LocalMachine["Local machine"]
Client["MCP client\nInspector / Codex / Cursor"]
subgraph Docker["docker compose"]
MCP["Apollo MCP Server\n:8000/mcp"]
API["Apollo GraphQL API\n:4001"]
end
Ops["graphql/operations/*.graphql\nApproved operations"]
Schema["graphql/api.graphql\nSchema snapshot"]
end
Client -->|"MCP over Streamable HTTP"| MCP
Ops -->|"tool definitions"| MCP
Schema -->|"schema metadata"| MCP
MCP -->|"GraphQL queries/mutations"| API
API -->|"GraphQL JSON response"| MCP
MCP -->|"MCP tool results"| ClientAusführung
cd C:\Users\muham\Documents\apollo-mcp
npm install
docker compose up --buildUntersuchen Sie in einem zweiten Terminal den MCP-Server:
npx @modelcontextprotocol/inspectorÖffnen Sie dann die ausgegebene Inspector-URL und wählen Sie:
Transporttyp:
Streamable HTTPURL:
http://127.0.0.1:8000/mcp
Klicken Sie auf Connect und dann auf List Tools.
Sie sollten MCP-Tools sehen, die von folgenden abgeleitet sind:
GetBooksGetBookByIdGetBooksByGenre
Optionale Client-Konfiguration
Für MCP-Clients, die mcp-remote verwenden, sieht die lokale Konfigurationsstruktur so aus:
{
"mcpServers": {
"apollo-demo": {
"command": "npx",
"args": [
"mcp-remote",
"http://127.0.0.1:8000/mcp"
]
}
}
}Was tatsächlich passiert
Die GraphQL-API ist weiterhin der eigentliche Datendienst. Sie kennt das Schema, löst Felder auf und gibt JSON für GraphQL-Abfragen zurück.
Der Apollo MCP-Server ersetzt diese API nicht. Er schaltet sich davor und übersetzt genehmigte GraphQL-Operationen in MCP-Tools, die ein KI-Client entdecken und aufrufen kann.
Die wichtigen Dateien sind:
mcp-config.yaml: teilt dem Apollo MCP-Server mit, wo sich der GraphQL-Endpunkt befindet, wo die Schemadatei liegt, wo die erlaubten Operationen gespeichert sind und wie MCP über HTTP bereitgestellt werden soll.
graphql/api.graphql: Schema-Snapshot, der vom Apollo MCP-Server verwendet wird, damit er Tools korrekt beschreiben kann.
graphql/operations/GetBooks.graphql: eine genehmigte Abfrage, die zu einem MCP-Tool wird.
src/server.mjs: die eigentliche Implementierung der GraphQL-API.
docker-compose.yml: führt beide Dienste zusammen in einem lokalen Netzwerk aus.
Der Anforderungsfluss ist:
Ihr MCP-Client verbindet sich mit
http://localhost:8000/mcp.Der Apollo MCP-Server kündigt Tools basierend auf den
.graphql-Operationsdateien an.Der Client ruft eines dieser Tools mit Argumenten auf.
Der Apollo MCP-Server konvertiert diesen Tool-Aufruf zurück in die zugrunde liegende GraphQL-Operation.
Der Apollo MCP-Server sendet diese GraphQL-Anfrage an
http://api:4001/.Die GraphQL-API führt die Abfrage aus und gibt Daten zurück.
Der Apollo MCP-Server gibt das Ergebnis im MCP-Format an den MCP-Client zurück.
Anforderungsflussdiagramm
sequenceDiagram
autonumber
participant C as MCP Client
participant M as Apollo MCP Server
participant O as Operation Files
participant G as GraphQL API
C->>M: Connect to http://localhost:8000/mcp
M->>O: Load approved .graphql operations
O-->>M: GetBooks / GetBookById / GetBooksByGenre
M-->>C: Advertise MCP tools
C->>M: Invoke tool with arguments
M->>M: Convert tool call to GraphQL operation
M->>G: Send GraphQL request to http://api:4001/
G-->>M: Return GraphQL JSON data
M-->>C: Return MCP-formatted tool resultWarum es hier keinen Router gibt
Der Apollo Router ist nützlich, wenn:
Sie einen föderierten Supergraph bereitstellen,
Sie die von Apollo verwaltete GraphOS-Laufzeitumgebung wünschen,
oder Sie GraphQL und MCP in der Apollo-Laufzeitumgebung gebündelt haben möchten.
Für eine einfache lokale Demo mit einer bestehenden GraphQL-API unterstützen die Bereitstellungsdokumente von Apollo die direkte Verwendung des eigenständigen Apollo MCP-Server-Containers für diesen Endpunkt. Genau das verwendet dieses Projekt.
Quellen
Apollo MCP-Server Quickstart: https://www.apollographql.com/docs/apollo-mcp-server/quickstart
Apollo MCP-Server Konfigurationsreferenz: https://www.apollographql.com/docs/apollo-mcp-server/command-reference
Apollo MCP-Server Bereitstellungsdokumente: https://www.apollographql.com/docs/apollo-mcp-server/deploy
Apollo MCP-Server Debugging-Dokumente: https://www.apollographql.com/docs/apollo-mcp-server/debugging
This server cannot be deployed
Maintenance
Related MCP Connectors
The Grafbase MCP server sits in front of a GraphQL API and exposes an MCP protocol-compliant interface that allows AI agents and LLMs to explore and query GraphQL APIs using natural language. It provides tools to search schemas, introspect types and fields, and execute GraphQL queries while minimizing context bloat by returning only relevant schema subsets, with built-in support for authentication, authorization, and configurable access control.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
MCP server that lets AI assistants use all OneSchema features exposed via the public API.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA 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 context83 npm46MIT
- AlicenseAqualityDmaintenanceGraphQL MCP Server that acts as a bridge allowing MCP clients (like Cursor or Claude Desktop) to interact with target GraphQL APIs through standard tools for schema introspection and operation execution.213 npm3MIT
- AlicenseAqualityAmaintenanceA generic MCP (Model Context Protocol) server that bridges any GraphQL API to Claude Code. It introspects your GraphQL schema and exposes each query and mutation as an individual tool, letting Claude interact with your API directly.230 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA generic MCP server that converts .graphql query files into tools for Claude, enabling interaction with any GraphQL API without coding.MIT