# apollographql/apollo-mcp-server architecture

> Architecture diagram of the GitHub repository apollographql/apollo-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/apollographql/apollo-mcp-server
- Repository: https://github.com/apollographql/apollo-mcp-server

## Overview

1. This is a Rust workspace centered on an Apollo MCP Server binary. The server’s job is to translate a configured GraphQL surface into MCP tools/resources that an LLM client can call. The repo is split into a runtime-facing server crate plus supporting libraries for schema indexing, registry syncing, and Rhai scripting.

2. The main entrypoint is `crates/apollo-mcp-server`, which contains the executable (`main.rs`) and most of the application logic. Its startup path is modeled as a state machine under `server/states`, moving through configuration, schema setup, operation setup, telemetry setup, and finally the running state.

3. The core request flow is: MCP client connects to the server, the server exposes tool definitions, the client invokes a tool, and the server executes the corresponding GraphQL operation against the configured backend. The important boundary is between MCP-facing tool metadata and backend GraphQL execution.

4. GraphQL operation handling lives under `operations/`. This layer owns operation parsing, raw operation representation, execution, source selection, mutation behavior, private-field filtering, and schema walking. It is the main adapter between a GraphQL document set and the MCP tool surface.

5. Schema intelligence is a separate concern. The server has introspection and schema-walking modules that derive output shapes, validate tool definitions, and generate searchable/introspectable views of schemas. The `apollo-schema-index` crate provides reusable schema traversal/search primitives for this purpose.

6. Schema and operation inputs can come from multiple sources. The `runtime/schema_source.rs`, `runtime/schemas.rs`, and related modules suggest support for local schemas, GraphOS/Uplink-backed schemas, and introspection-based schema resolution. Likewise, `runtime/operation_source.rs` and the `operations` modules indicate support for local operation files and persisted-query manifests.

7. There is a dedicated GraphOS/Uplink integration path. The `apollo-mcp-registry` crate contains GraphQL documents, pollers, and event models for schema streams and persisted query manifests, plus a `platform_api` layer. This crate is the remote-control plane for syncing registry metadata from Apollo services.

8. Authentication and policy enforcement are explicit subsystems. Under `auth/` the server includes protected-resource handling, token validation, and `WWW-Authenticate` support. `cors.rs`, `host_validation.rs`, and `headers.rs` define the HTTP-facing security boundary around who can talk to the server and from where.

9. Observability is first-class. `runtime/telemetry.rs`, `meter.rs`, and `runtime/logging/` handle logging and metrics, while `runtime/filtering_exporter.rs` and the OTLP-related tests show support for exporting telemetry to external collectors. A separate `health.rs` module exposes liveness/readiness-style health checks.

10. The repo also supports runtime customization through Rhai scripts in `apollo-mcp-rhai`. That crate exposes startup and operation-execution checkpoints plus helper functions for env, HTTP, JSON, regex, and hashing. Architecturally, this is an extension layer that can influence behavior without changing the core server.

11. User-facing packaging is handled by the `apps/` and `prompts/` areas in the server crate. These modules define MCP app manifests, resources, and tools, and also load prompt files that can be shipped alongside tool definitions. This is how higher-level “application bundles” are represented in the server.

12. The repository includes concrete deployment and validation boundaries: `examples/` for sample configurations, `e2e/` for end-to-end scenarios, `docs/` for the published architecture and usage model, and GitHub workflows/Dockerfile for release and container packaging. Those pieces are not runtime subsystems, but they show how the server is built, tested, and distributed.

Main entry points: [`crates/apollo-mcp-server/src/server/states.rs`](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/server/states.rs) (Server States), [`crates/apollo-mcp-server/src/runtime.rs`](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime.rs) (Runtime), [`crates/apollo-mcp-registry/src/lib.rs`](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/lib.rs) (Registry Sync), [`crates/apollo-mcp-server/src/operations.rs`](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/operations.rs) (Operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Apollo MCP Server"]
  node_main(("Main<br/>binary entrypoint<br/>[main.rs]"))
  node_server_state["Server States<br/>startup state machine<br/>[states.rs]"]
  node_runtime["Runtime<br/>config assembly<br/>[runtime.rs]"]
  node_schema_source["Schema Source<br/>schema resolution<br/>[schema_source.rs]"]
  node_schemas["Schemas<br/>schema model<br/>[schemas.rs]"]
  node_operation_source["Operation Source<br/>operation resolution"]
  node_operations["Operations<br/>graphql adapter<br/>[operations.rs]"]
  node_schema_walker["Schema Walker<br/>schema shaping<br/>[schema_walker.rs]"]
  node_introspection["Introspection<br/>tool generation<br/>[introspection.rs]"]
  node_apps["Apps<br/>app manifests<br/>[mod.rs]"]
  node_prompts["Prompts<br/>prompt loading<br/>[mod.rs]"]
  node_auth["Auth<br/>access control<br/>[auth.rs]"]
  node_http_security["HTTP Security<br/>request boundary<br/>[cors.rs]"]
  node_telemetry["Telemetry<br/>observability<br/>[telemetry.rs]"]
  node_health(("Health<br/>[health.rs]"))
end

subgraph group_registry["Registry Sync"]
  node_registry_crate["Registry Sync<br/>remote control plane<br/>[lib.rs]"]
  node_uplink["Uplink<br/>schema stream<br/>[uplink.rs]"]
  node_pq_manifest["PQ Manifest<br/>manifest sync<br/>[manifest_poller.rs]"]
  node_platform_api["Platform API<br/>graphql client<br/>[platform_api.rs]"]
end

subgraph group_rhai["Rhai Extensibility"]
  node_rhai_engine["Rhai Engine<br/>script runtime<br/>[engine.rs]"]
end

subgraph group_schema["Schema Index"]
  node_schema_index["Schema Index<br/>traversal library<br/>[lib.rs]"]
end

subgraph group_packaging["Packaging & Examples"]
  node_docs_examples["Docs & Examples<br/>usage assets<br/>[index.mdx]"]
end

node_main -->|"boot"| node_server_state
node_server_state -->|"assemble"| node_runtime
node_runtime -->|"resolve schema"| node_schema_source
node_runtime -->|"resolve ops"| node_operation_source
node_schema_source -->|"load"| node_schemas
node_operation_source -->|"feed docs"| node_operations
node_schemas -->|"shape tools"| node_operations
node_operations -->|"derive output"| node_schema_walker
node_schema_walker -->|"traverse"| node_schema_index
node_operations -->|"expose"| node_introspection
node_introspection -->|"search"| node_schema_index
node_apps -->|"bundle"| node_prompts
node_auth -->|"guard"| node_http_security
node_server_state -->|"enforce"| node_auth
node_server_state -->|"instrument"| node_telemetry
node_server_state -->|"serve"| node_health
node_runtime -->|"hook scripts"| node_rhai_engine
node_rhai_engine -->|"customize exec"| node_operations
node_registry_crate -->|"sync schema"| node_uplink
node_registry_crate -->|"sync manifests"| node_pq_manifest
node_registry_crate -->|"query API"| node_platform_api
node_runtime -->|"remote source"| node_registry_crate
node_docs_examples -->|"describe"| node_apps
node_docs_examples -->|"document"| node_rhai_engine
node_docs_examples -->|"illustrate"| node_registry_crate

click node_main "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/main.rs"
click node_server_state "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/server/states.rs"
click node_runtime "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime.rs"
click node_schema_source "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/schema_source.rs"
click node_schemas "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/schemas.rs"
click node_operation_source "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/operation_source.rs"
click node_operations "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/operations.rs"
click node_schema_walker "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/operations/schema_walker.rs"
click node_introspection "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/introspection.rs"
click node_apps "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/apps/mod.rs"
click node_prompts "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/prompts/mod.rs"
click node_auth "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/auth.rs"
click node_http_security "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/cors.rs"
click node_telemetry "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/telemetry.rs"
click node_health "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/health.rs"
click node_registry_crate "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/lib.rs"
click node_uplink "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/uplink.rs"
click node_pq_manifest "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/uplink/persisted_queries/manifest_poller.rs"
click node_platform_api "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/platform_api.rs"
click node_rhai_engine "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-rhai/src/engine.rs"
click node_schema_index "https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-schema-index/src/lib.rs"
click node_docs_examples "https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/index.mdx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_server_state,node_runtime,node_schema_source,node_schemas,node_operation_source,node_operations,node_schema_walker,node_introspection,node_apps,node_prompts,node_auth,node_http_security,node_telemetry,node_health toneBlue
class node_registry_crate,node_uplink,node_pq_manifest,node_platform_api toneAmber
class node_rhai_engine toneMint
class node_schema_index toneRose
class node_docs_examples toneIndigo
```

## Components

### Apollo MCP Server

Runtime-facing MCP server crate and its internal subsystems.

- [Main](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/main.rs): binary entrypoint · Executable entrypoint and startup wiring. · `crates/apollo-mcp-server/src/main.rs`
- [Server States](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/server/states.rs): startup state machine · Coordinates configuration, schema setup, operations setup, telemetry, and running. · `crates/apollo-mcp-server/src/server/states.rs`
- [Runtime](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime.rs): config assembly · Builds the effective runtime from config, endpoint, schema, operation, and override inputs. · `crates/apollo-mcp-server/src/runtime.rs`
- [Schema Source](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/schema_source.rs): schema resolution · Selects and loads schemas from local, introspection, or GraphOS-backed sources. · `crates/apollo-mcp-server/src/runtime/schema_source.rs`
- [Schemas](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/schemas.rs): schema model · Holds schema representations used by the server and operation layers. · `crates/apollo-mcp-server/src/runtime/schemas.rs`
- [Operation Source](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/operation_source.rs): operation resolution · Loads operation documents from files or persisted-query manifests. · `crates/apollo-mcp-server/src/runtime/operation_source.rs`
- [Operations](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/operations.rs): graphql adapter · Maps GraphQL documents into MCP tool behavior and execution. · `crates/apollo-mcp-server/src/operations.rs`
- [Schema Walker](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/operations/schema_walker.rs): schema shaping · Derives tool-friendly output shapes and walks GraphQL types. · `crates/apollo-mcp-server/src/operations/schema_walker.rs`
- [Introspection](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/introspection.rs): tool generation · Builds search, validate, execute, and introspection tools from schema data. · `crates/apollo-mcp-server/src/introspection.rs`
- [Apps](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/apps/mod.rs): app manifests · Represents MCP app bundles, manifests, resources, and tools. · `crates/apollo-mcp-server/src/apps/mod.rs`
- [Prompts](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/prompts/mod.rs): prompt loading · Loads prompt files shipped alongside app and tool definitions. · `crates/apollo-mcp-server/src/prompts/mod.rs`
- [Auth](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/auth.rs): access control · Protected-resource handling, token validation, and auth challenges. · `crates/apollo-mcp-server/src/auth.rs`
- [HTTP Security](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/cors.rs): request boundary · CORS, host validation, and header handling for inbound requests. · `crates/apollo-mcp-server/src/cors.rs`
- [Telemetry](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/runtime/telemetry.rs): observability · Logging, metrics, sampling, and exporter setup. · `crates/apollo-mcp-server/src/runtime/telemetry.rs`
- [Health](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-server/src/health.rs): health checks · Liveness/readiness-style endpoint support. · `crates/apollo-mcp-server/src/health.rs`

### Registry Sync

Remote GraphOS/Uplink integration for schemas and persisted queries.

- [Registry Sync](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/lib.rs): remote control plane · Apollo registry integration for schema streams and persisted query manifests. · `crates/apollo-mcp-registry/src/lib.rs`
- [Uplink](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/uplink.rs): schema stream · Polls and consumes GraphOS schema stream events. · `crates/apollo-mcp-registry/src/uplink.rs`
- [PQ Manifest](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/uplink/persisted_queries/manifest_poller.rs): manifest sync · Fetches and tracks persisted-query manifests from Apollo services. · `crates/apollo-mcp-registry/src/uplink/persisted_queries/manifest_poller.rs`
- [Platform API](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-registry/src/platform_api.rs): graphql client · GraphQL documents and event models for registry-side APIs. · `crates/apollo-mcp-registry/src/platform_api.rs`

### Rhai Extensibility

Script runtime used to customize startup and operation execution.

- [Rhai Engine](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-mcp-rhai/src/engine.rs): script runtime · Script engine and checkpoint orchestration for startup and execution hooks. · `crates/apollo-mcp-rhai/src/engine.rs`

### Schema Index

Reusable schema traversal and search primitives.

- [Schema Index](https://github.com/apollographql/apollo-mcp-server/blob/main/crates/apollo-schema-index/src/lib.rs): traversal library · Reusable schema traversal and search primitives. · `crates/apollo-schema-index/src/lib.rs`

### Packaging & Examples

Documentation, examples, and validation/deployment assets.

- [Docs & Examples](https://github.com/apollographql/apollo-mcp-server/blob/main/docs/source/index.mdx): usage assets · Architecture docs, examples, and end-to-end scenarios that exercise the server. · `docs/source/index.mdx`

## Connections

- Main → Server States: boot · Executable enters the server startup state machine.
- Server States → Runtime: assemble · State machine builds the effective runtime configuration.
- Runtime → Schema Source: resolve schema · Runtime selects the active schema source.
- Runtime → Operation Source: resolve ops · Runtime selects the active operation source.
- Schema Source → Schemas: load · Schema source populates runtime schema models.
- Operation Source → Operations: feed docs · Operation documents are adapted into runnable operations.
- Schemas → Operations: shape tools · Schemas constrain tool generation and execution shapes.
- Operations → Schema Walker: derive output · Operation layer uses schema walking to produce tool outputs.
- Schema Walker → Schema Index: traverse · Walker delegates traversal/search primitives to the shared schema index crate.
- Operations → Introspection: expose · Operations and schema data are surfaced as MCP introspection tools.
- Introspection → Schema Index: search · Introspection tools rely on schema indexing for lookup.
- Apps → Prompts: bundle · App manifests can include prompt resources.
- Auth → HTTP Security: guard · Inbound request security boundary complements auth checks.
- Server States → Auth: enforce · Startup config wires authentication into the server.
- Server States → Telemetry: instrument · Telemetry is configured during startup.
- Server States → Health: serve · Health endpoints are brought up with the server.
- Runtime → Rhai Engine: hook scripts · Runtime can attach Rhai checkpoints and helpers.
- Rhai Engine → Operations: customize exec · Scripts can influence GraphQL operation execution.
- Registry Sync → Uplink: sync schema · Registry crate manages schema stream polling.
- Registry Sync → PQ Manifest: sync manifests · Registry crate manages persisted-query manifest polling.
- Registry Sync → Platform API: query API · Registry crate uses GraphQL platform documents.
- Runtime → Registry Sync: remote source · Runtime can source schema and operation metadata from Apollo services.
- Docs & Examples → Apps: describe · Docs explain app manifests and resource structure.
- Docs & Examples → Rhai Engine: document · Docs cover Rhai lifecycle and functions.
- Docs & Examples → Registry Sync: illustrate · Examples and docs cover registry sync and persisted queries.
