Apollo GraphQL Federation v2 to MCP Server & llms.txt Compiler (2026 Guide)
Apollo GraphQL Federation v2 to MCP Server & llms.txt Compiler (2026 Guide)
Scan Your Website AI-Readiness Inline (0–100)
Enter your domain to inspect live /llms.txt, ACP/UCP & MCP 2026-07-28 blockers right here on this page—and unlock your compiled 7-file bundle + git apply .patch in 1 click.
embed.js)
âś“ Zero CWV / SEO speed impact
âś“ Works on Shopify, WordPress, Webflow & Next.js
title: "Apollo GraphQL Federation v2 to MCP Server & llms.txt Compiler (2026 Guide)"
slug: "/guides/apollo-graphql-federation-v2-subgraph-to-mcp-server-llms-txt"
lp_id: "LP29"
sprint: "Sprint #9 (v3.5)"
published_at: "2026-11-19"
target_keyword: "Apollo GraphQL Federation v2 to MCP Server & llms.txt Compiler (2026 Guide)"
secondary_keywords:
- "Apollo Federation v2 MCP server"
- "compile _entities @key subgraph to stateless MCP 2026-07-28"
- "GraphQL supergraph SEP-2127 server card"
- "Apollo subgraph llms.txt v2 compiler"
- "Chrome Lighthouse ard.json GraphQL API"
Apollo GraphQL Federation v2 to MCP Server & llms.txt Compiler (2026 Guide)
Exposing an enterprise GraphQL supergraph to AI agents in late 2026 presents an architectural trap: raw subgraph schemas contain internal router mechanics that should never reach an LLM tool-calling context, while running stateful sidecar bridges per subgraph multiplies infrastructure and token overhead. Platform teams running Apollo Federation 2 need a deterministic build step that strips internal entity plumbing and emits standards-compliant agent discovery manifests in seconds.
SpecPulse AI (curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json) compiles federated GraphQL SDL—across standalone .graphql subgraph files, supergraph compositions, OpenAPI 3.0–3.2 specs, and Markdown docs—into 5 production-ready AI agent artifacts in under 5 seconds:
- Stateless MCP
2026-07-28Tool Manifest (mcp-server.json): Aligned with the Model Context Protocol2026-07-28Specification using JSON Schema2020-12, RFC 8707 OAuth 2.0 Resource Indicators, and RFC 8941 Structured Field ValuesIdempotency-Keywrite-replay guards on every GraphQLMutation. - MCP
SEP-2127Server Card (/.well-known/mcp-server.json): Pre-connection HTTP discovery metadata compliant with SEP-2127: MCP Server Cards, advertising remote Streamable HTTP endpoints andsupportedProtocolVersionswhile deliberately omitting static primitive lists for zero-trust runtime safety. - Token-Budgeted
/llms.txtv2 (<= 50KB): A compact, deterministic domain map passing the Chrome Lighthousellms.txtAudit without blowing up agent context windows on 400-type supergraphs. - Chrome Lighthouse 13.5+
/.well-known/ard.json(v0.91): Validated against the official Chrome Lighthouseard.jsonAudit (Pass = 1.00) with domain-anchoredurn:air:<publisher>:<namespace>:<name>URNs and2–5indexedrepresentativeQueriesper resource. - AAIF Agent Skills (
/.well-known/skills/index.json+<slug>/SKILL.md): Portable multi-step graph query workflows conforming to the Linux Foundation's Agentic AI Foundation (AAIF) open Agent Skills Specification (< 500lines per skill).
# Try Free Instantly (up to 3 federated operations, zero signup required)
curl -fsSL https://specpulse.dev/api/v1/scan?url=https://yourdomain.com
curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json
--subgraph ./subgraphs/orders/schema.graphql \
--subgraph ./subgraphs/inventory/schema.graphql \
--router-url https://graph.example.com/graphql \
--out ./public
Why Raw Federation v2 Subgraphs Break LLM Tool Calling & Leak Internal Topology
Under the Apollo Federation Subgraph Specification, every Federation 2 subgraph automatically injects synthetic root fields, unions, scalars, and composition directives so the router can plan distributed execution:
- Hidden Enhanced Introspection Survives
introspection: false: Even when a team disables standard GraphQL__schemaintrospection in production, Federation subgraphs still exposeQuery._service { sdl: String! }so routers can retrieve raw SDL—including internal directives—unless explicitly stripped or firewalled at the gateway, as documented in the Apollo Subgraph Enhanced Introspection Reference. Query._entities(representations: [_Any!]!): [_Entity]!Hallucination Loops: When naive schema-to-MCP converters ingest raw subgraph files, they expose_entitiesand the unvalidated_AnyJSON scalar as callable LLM tools. Coding agents repeatedly hallucinate malformed{"__typename": "...", ...}representations or attempt to call non-resolvable entity stubs (@key(fields: "id", resolvable: false)), triggering downstream__resolveReferenceN+1 storms.- Directive Leakage (
@inaccessible,@external,@requires,@override): Fields marked@inaccessiblein Apollo Federation Directives are intentionally hidden from the public supergraph contract during staged migrations or internal microservice joins. Feeding raw subgraph SDL directly to an agent leaks internal field names, deprecated microservice boundaries (@override(from: "legacy-billing")), and authorization scopes (@requiresScopes,@policy).
SpecPulse v3.5 solves this at build time with a deterministic Federation v2 AST Pruner & Entity Join Resolver before a single token reaches the compiler.
Architecture Comparison: SpecPulse v3.5 vs. Runtime MCP Bridges & DIY Scripts
| Capability | SpecPulse AI v3.5 (curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json) | Apollo MCP Server v2 | Naive GraphQL Introspection-to-MCP Scripts |
|---|---|---|---|
| Primary Execution Model | Deterministic 5-second build-time compiler emitting static + stateless edge artifacts (MCP 2026-07-28) | Runtime GraphQL-to-MCP server process deployed via Rover CLI or cloud containers (Apollo MCP Server Docs) | Ad-hoc runtime __schema introspection wrapper over stateful SSE/stdio |
Federation v2 @key / _entities Handling | Resolves @key entity joins across subgraphs into unified supergraph tools; strips _entities, _service, _Any, and resolvable: false stubs (Subgraph Spec) | Operates against composed GraphOS persisted queries, operation .graphql files, or router introspection (Apollo MCP Server Docs) | Leaks raw Query._entities and Query._service { sdl } directly into LLM tool schemas |
@inaccessible & @requiresScopes Enforcement | Prunes @inaccessible AST nodes pre-LLM and maps @authenticated / @requiresScopes to RFC 8707 & RFC 9728 OAuth metadata | Relies on GraphOS Operation Collections and downstream router policy enforcement (Apollo Directives) | Zero directive awareness; exposes internal fields to unprivileged agents |
| Mutation Write-Replay Protection | Auto-injects RFC 8941 Structured Field Idempotency-Key header requirements on every GraphQL Mutation tool | Manual header forwarding via YAML config or Rhai lifecycle scripts (Apollo MCP Server Docs) | None—agent retries duplicate orders, refunds, or mutations |
Domain Discovery Suite (SEP-2127 + ard.json + llms.txt + SKILL.md) | Generates all 5 artifacts simultaneously (mcp-server.json, SEP-2127, Lighthouse ard.json v0.91, Lighthouse llms.txt, AAIF SKILL.md) | MCP transport & MCP Apps focus; does not emit Lighthouse ard.json v0.91, /llms.txt v2, or AAIF SKILL.md | Single non-standard tools.json dump |
| 50-Operation Compilation Cost | $0.144/run ($0.148 2-pool lock) cold / $0.0034/run ($0.0043 90/10 lock) PR diff via RFC 8785 JCS prefix + asymmetric batching | Container compute + GraphOS plan + live LLM introspection tokens per session | $1.25–$3.39/run unbatched frontier LLM calls |
> Architectural Synergy: Teams already running Apollo MCP Server v2 in production use SpecPulse v3.5 in CI/CD to auto-compile their curated .graphql operation collections and subgraph schemas into /.well-known/ard.json (v0.91), /.well-known/mcp-server.json (SEP-2127), /llms.txt v2 (<= 50KB), and AAIF SKILL.md playbooks so external registries and Chrome Lighthouse 13.5+ discover their Apollo endpoint with a 1.00 Pass score.
Step-by-Step Tutorial: Compiling Two Federated Subgraphs Without Exposing Internal Resolvers
Suppose your commerce platform splits Order and Product across two Apollo Server @apollo/subgraph microservices using Federation v2.3 directives.
Step 1: Inspect Your Raw Federation v2 Subgraph Schemas
Notice how subgraphs/orders/schema.graphql uses @key, @requiresScopes, @inaccessible, and an unresolvable User entity stub (resolvable: false), while subgraphs/inventory/schema.graphql extends Product with @external and @requires:
# subgraphs/orders/schema.graphql
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.3"
import: ["@key", "@inaccessible", "@authenticated", "@requiresScopes"]
)
type Query {
"Fetch a customer order with line items and fulfillment status."
orderById(id: ID!): Order @authenticated
}
type Mutation {
"Create a confirmed checkout order and capture payment authorization."
createOrder(input: CreateOrderInput!): OrderPayload!
@authenticated
@requiresScopes(scopes: [["orders:write"]])
}
type Order @key(fields: "id") {
id: ID!
status: OrderStatus!
totalCents: Int!
items: [Product!]!
internalFraudScore: Float! @inaccessible
buyer: User!
}
type Product @key(fields: "upc") {
upc: String!
quantity: Int!
}
# Reference stub resolved exclusively by the Accounts subgraph
type User @key(fields: "id", resolvable: false) {
id: ID!
}
input CreateOrderInput {
cartId: ID!
currency: String! = "USD"
shippingPostalCode: String!
}
enum OrderStatus {
PENDING
CONFIRMED
SHIPPED
}
type OrderPayload {
order: Order
userErrors: [String!]!
}
# subgraphs/inventory/schema.graphql
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.3"
import: ["@key", "@external", "@requires", "@shareable", "@inaccessible"]
)
type Product @key(fields: "upc") {
upc: String!
name: String! @shareable
weightGrams: Int! @external
inStock: Boolean!
"Calculated shipping estimate using external weightGrams from Catalog subgraph."
estimatedShippingCents: Int! @requires(fields: "weightGrams")
warehouseBinCode: String @inaccessible
}
If an engineering script dumps these subgraphs straight into an MCP tool generator, internalFraudScore, warehouseBinCode, weightGrams @external, Query._entities, and Query._service all leak into the prompt or generated schema.
Step 2: Run the SpecPulse v3.5 Federation Compiler
Execute curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json in local or CI mode. SpecPulse merges @key(fields: "upc") entity extensions across subgraphs, strips @inaccessible and @external-only fields, discards Query._service / Query._entities / resolvable: false stubs, canonicalizes the composed AST with RFC 8785 JSON Canonicalization Scheme (JCS), and emits all 5 artifacts:
curl -fsSL https://specpulse.dev/api/v1/scan?url=https://yourdomain.com
curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json
--subgraph ./subgraphs/orders/schema.graphql \
--subgraph ./subgraphs/inventory/schema.graphql \
--router-url https://api.acmecommerce.example/graphql \
--oauth-resource https://api.acmecommerce.example/graphql \
--publisher acmecommerce \
--namespace commerce-graph \
--out ./dist/agent-artifacts
Step 3: Inspect the Generated Stateless MCP 2026-07-28 Schema (mcp-server.json)
Following the MCP 2026-07-28 Tools Specification and SEP-2575 Stateless MCP, every HTTP POST carries MCP-Protocol-Version: 2026-07-28 with zero server-side Mcp-Session-Id state. Notice three critical safety guarantees in the compiled create_order mutation tool below:
internalFraudScoreandwarehouseBinCode(@inaccessible) are completely absent from the selection set andoutputSchema.@requiresScopes(scopes: [["orders:write"]])compiles directly into an RFC 8707 OAuth 2.0resourcebinding paired with RFC 9728 Protected Resource Metadata so tokens minted for another service are rejected.- Because
createOrderis a GraphQLMutation, SpecPulse injects a mandatory RFC 8941 Structured FieldIdempotency-KeyByte Sequence / String header guard to prevent duplicate payment captures on agent retries:
Step 4: Inspect the SEP-2127 Server Card & Chrome Lighthouse ard.json (v0.91)
Per SEP-2127: MCP Server Cards, public discovery cards must exclude primitive definitions (tools, resources, prompts) so clients never rely on static public JSON for access-control decisions and instead validate tools/list at runtime with the authenticated user's token. SpecPulse writes a strict SEP-2127 card at /.well-known/mcp-server.json (and /mcp/server-card) alongside a 1.00-scoring Chrome Lighthouse ard.json (v0.91) manifest:
// /.well-known/mcp-server.json (SEP-2127 Final Extensions Track Compliant)
{
"name": "io.acmecommerce/commerce-supergraph",
"title": "Acme Commerce Federated Supergraph MCP",
"version": "3.5.0",
"description": "Stateless MCP 2026-07-28 gateway for federated Order and Inventory GraphQL operations with RFC 8707 OAuth resource binding.",
"websiteUrl": "https://api.acmecommerce.example/docs",
"transports": [
{
"type": "streamable-http",
"url": "https://api.acmecommerce.example/mcp",
"supportedProtocolVersions": ["2026-07-28"],
"headers": {
"MCP-Protocol-Version": "2026-07-28",
"Authorization": "Bearer ${OAUTH_ACCESS_TOKEN}"
}
}
]
}
// /.well-known/ard.json (Passes Chrome Lighthouse 13.5+ ARD v0.91 Suite with Score = 1.00)
{
"entries": [
{
"identifier": "urn:air:acmecommerce:commerce-graph:mcp-gateway",
"displayName": "Acme Commerce Federated Supergraph MCP Server",
"type": "application/mcp-server-card+json",
"url": "https://api.acmecommerce.example/.well-known/mcp-server.json",
"capabilities": ["order_by_id", "create_order"],
"representativeQueries": [
"Look up order fulfillment status and live item stock by order ID",
"Submit a confirmed checkout cart with idempotent payment authorization",
"Calculate federated product shipping estimates across inventory warehouses"
],
"trustManifest": {
"identity": "did:web:api.acmecommerce.example"
}
},
{
"identifier": "urn:air:acmecommerce:commerce-graph:checkout-skill",
"displayName": "Acme Federated Checkout & Order Triage Skill",
"type": "application/agent-skill+markdown",
"url": "https://api.acmecommerce.example/.well-known/skills/commerce-checkout/SKILL.md",
"representativeQueries": [
"Verify cart inventory stock before executing an idempotent order mutation",
"Triage userErrors returned from federated GraphQL checkout mutations"
]
}
]
}
Notice how /.well-known/ard.json avoids every Chrome Lighthouse ard.json best-practice warning that drops scores from 1.00 to 0.90 or 0.00: it uses application/mcp-server-card+json (not the deprecated application/mcp-server+json), omits the deprecated top-level collections array, defines urn:air:<publisher>:<namespace>:<name> identifiers, sets url without conflicting inline data, and populates 2–5 representativeQueries strings per entry.
Step 5: Token-Budgeted /llms.txt v2 (<= 50KB) & AAIF SKILL.md
Enterprise supergraphs routinely exceed 1.5 MB of raw SDL—far too large for rapid domain indexing. SpecPulse's topological ranker compresses your supergraph contract into a deterministic <= 50KB /llms.txt v2 index (satisfying the Chrome Lighthouse llms.txt check) while emitting modular < 500-line workflow guides in /.well-known/skills/<slug>/SKILL.md per the AAIF Agent Skills Specification:
# Acme Commerce Supergraph API (/llms.txt v2 — 11.4 KB / 50.0 KB Budget)
> Stateless MCP 2026-07-28 & Federated GraphQL Supergraph for Order Lookup, Live Inventory Availability, and Idempotent Checkout Execution.
## Discovery & Agent Manifests
- [ARD v0.91 Resource Catalog](https://api.acmecommerce.example/.well-known/ard.json): Domain-anchored URN index for MCP servers and AAIF skills.
- [SEP-2127 MCP Server Card](https://api.acmecommerce.example/.well-known/mcp-server.json): Streamable HTTP connection metadata (`MCP-Protocol-Version: 2026-07-28`).
- [Stateless MCP Tool Schemas](https://api.acmecommerce.example/mcp-server.json): JSON Schema 2020-12 contracts with RFC 8707 OAuth resource indicators.
- [AAIF Agent Skills Index](https://api.acmecommerce.example/.well-known/skills/index.json): Portable multi-step GraphQL execution playbooks.
## Public Supergraph Operations (Internal @inaccessible & _entities Stripped)
- `query orderById(id: ID!): Order` — Requires `Bearer` token (`@authenticated`). Joins `Order` with live `Product.inStock` and `Product.estimatedShippingCents`.
- `mutation createOrder(input: CreateOrderInput!): OrderPayload!` — Requires OAuth scope `orders:write` (`resource=https://api.acmecommerce.example/graphql`) + RFC 8941 `Idempotency-Key` header.
Security Checklist for Federated GraphQL Agent Gateways
Before shipping any GraphQL-backed MCP endpoint to external coding agents or internal enterprise copilots, enforce these five controls (automated out of the box by curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json):
- Block
Query._service&Query._entitiesat the Public Edge: Ensure public routers reject external_service { sdl }queries even when standard GraphQL introspection is turned off, matching the security guidance in the Apollo Federation Subgraph Specification. - Prune
@inaccessible,@external, andresolvable: falseTypes Pre-Compilation: Validate your subgraph directives against Apollo Federation Directives so staged migration fields never enter/llms.txtorinputSchemadescriptions. - Bind Every OAuth Token with RFC 8707 Resource Indicators: Require
resource=<canonical-graphql-uri>during token exchange per RFC 8707 and publish RFC 9728 Protected Resource Metadata so bearer tokens stolen from adjacent tools cannot execute supergraph mutations. - Enforce RFC 8941
Idempotency-KeyHeaders on All Mutations: Autonomous agents retry tool calls on network timeouts; typingIdempotency-Keyas an RFC 8941 Structured String eliminates duplicate mutations at the edge in< 5ms. - Keep Primitive Schemas Out of
SEP-2127Discovery Cards: Serve public connection metadata at/.well-known/mcp-server.jsonper SEP-2127 and gatetools/listbehind authenticated stateless2026-07-28POST requests.
Pricing & Instant CLI Quickstart (v3.5)
Compile your first federated subgraph locally in 5 seconds—no credit card or cloud login required on the Free Tier—and scale seamlessly from single-repo GraphQL APIs to multi-team enterprise supergraphs.
| Plan | Price | Included Capacity & Federation v3.5 Capabilities | Best For | Instant CLI Activation |
|---|---|---|---|---|
| Free Tier | $0 | Up to 3 endpoints / GraphQL operations, all 5 artifacts (/llms.txt v2, ard.json v0.91, Stateless MCP 2026-07-28, SEP-2127, AAIF SKILL.md), local @inaccessible & _entities leak audit | Individual developers testing Federation v2 -> MCP compilation | curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json |
| Single-Run Credit Pack | $10 one-time (never expires) | Powers 72 full 50-operation cold rebuilds ($0.144/run ($0.148 2-pool lock)) or 2,600+ incremental PR diffs ($0.0034/run ($0.0043 90/10 lock)); zero recurring subscription | Quarterly API launches, agency handoffs, or one-off supergraph migrations | curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json |
| Pro Monthly | $29/mo | Up to 250 operations/endpoints, automated GitHub Actions PR diff bot + specpulse-badge.svg, asymmetric 8-EP/5-EP Gemini cost guard | Production SaaS & GraphQL API teams shipping weekly schema updates | curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json |
| Pro Annual | $290/yr (2 months free — save $58/yr) | Everything in Pro Monthly + priority 5-min warm KV cohort routing and annual invoice lock | High-velocity startups standardizing on MCP 2026-07-28 & Lighthouse 13.5+ | curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json |
| Team Monthly | $99/mo | Unlimited multi-subgraph supergraphs & OpenAPI 3.0–3.2 repos, @requiresScopes / RFC 8707 policy gates, sp_t_<56_hex> tenant isolation, Slack/Linear breaking-diff alerts | Multi-squad GraphQL platform engineering & API governance teams | curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json |
| Team Annual | $990/yr (2 months free — save $198/yr) | Everything in Team Monthly + org-wide GitHub required status check templates & dedicated schema migration audit logs | Enterprise platform orgs governing 10+ federated subgraphs | curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json |
# 1. Audit your Apollo Federation v2 subgraphs for _entities / @inaccessible leaks in 5 seconds (Free)
curl -fsSL https://specpulse.dev/api/v1/scan?url=https://yourdomain.com
curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json
# 2. Compile all 5 AI-agent artifacts and verify Chrome Lighthouse ARD v0.91 = 1.00 Pass
curl -fsSL https://specpulse.dev/api/v1/scan?url=https://yourdomain.com
curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json
# 3. Activate Pro Annual ($290/yr — 2 months free) or a $10 Single-Run Credit Pack straight from terminal
curl -fsSL https://specpulse.dev/api/v1/scan?url=https://yourdomain.com
curl -fsSL https://specpulse.dev/cli.mjs -o specpulse.mjs && node specpulse.mjs ./openapi.json
Stop Losing AI Search Buyers to Competitors — Go Live in 60 Seconds
No sales demos, zero lock-in, instant 1-click cancellation • Save 2 months on Annual plans (Pro $290/yr · Agency $2,990/yr)
<script src="https://specpulse.dev/embed.js" data-site="your-domain-com" defer></script>