An enterprise MCP platform, proven end to end on one box
Four client populations reach two classes of MCP destination through a Kong gateway estate, under a single-issuer token model (Keycloak), sender-constrained tokens (mTLS for workloads, DPoP for workforce), egress DLP, and a vault-backed vendor token broker. Every contested design decision runs as executable acceptance gates — phases 0–7, all green on the last full run (2026-10-01).
Five invariants, never stubbed
Every section of the architecture elaborates one of these; the lab is only useful because each is actually enforced and tested.
One token issuer
Keycloak mints every token the gateway or an MCP server validates. The workforce IdP, the workload identity system, Auth0, and a legacy in-house AS authenticate their populations; none of their tokens reach the plane directly.
PHI stays inside the boundary
The Konnect control plane sees configuration and aggregate telemetry only; vendor clouds receive only DLP-screened, allowlisted tool traffic; audit flows to the customer SIEM.
Stateless MCP from day one
No protocol session. Identity and capabilities ride every request; continuity uses explicit handles like slot_hold_id, so any request can hit any replica.
Governance at two layers
Enterprise-Managed Authorization / IdP policy governs connections — the spec scopes IdP visibility to token issuance (EMA §7.2). Kong ACLs and server scope checks govern tool calls.
Every transitional piece has an exit
The legacy in-house AS sunsets into the workload-identity path + Keycloak; the vendor token broker shrinks vendor-by-vendor as ID-JAG adoption spreads; the workforce IdP's brokered leg upgrades in place to EMA.
Every population, token path, and flow
Solid edges are current state. Dashed labeled edges are the future EMA (ID-JAG) upgrade paths; unlabeled dashed edges feed the audit spine. The egress feed is drawn from the internal-agents node for routing clarity — developer clients reach it through the same private ingress.
The diagram renders at full size — scroll horizontally inside the panel to pan.
Keycloak (realm mcp-plane) is the sole Resource Authorization Server, named in every
server's RFC 9728 Protected Resource Metadata. Tier audiences make cross-tier replay fail
cryptographically; the hub JWT stops at the component that validated it.
Enterprise-Managed Authorization, mapped
The MCP Enterprise-Managed Authorization extension (stable, modelcontextprotocol/ext-auth)
applies the Identity Assertion JWT Authorization Grant (ID-JAG): RFC 8693 token exchange at the IdP,
then an RFC 7523 JWT authorization grant at the Resource Authorization Server. This platform was
designed for that shape before it stabilized.
| EMA role (spec §1.2) | This platform | Status |
|---|---|---|
| MCP Client | Claude Code, the DPoP harness client, the loop agent, and the patient agent are registered in the lab; Codex CLI, VS Code, ChatGPT and partner apps are target-state | In place (lab clients) |
| MCP Server (Resource Server) | First-party servers (scheduling, fhir-clinical) and vendor MCP servers | In place |
| Resource Authorization Server | Keycloak realm mcp-plane, advertised in every server's RFC 9728 PRM | In place |
| IdP Authorization Server | Workforce IdP (e.g., Ping), Auth0 (patients) — brokered today, ID-JAG issuers tomorrow | Awaiting vendor ID-JAG |
| Discovery (spec §6) | urn:ietf:params:oauth:grant-profile:id-jag in authorization_grant_profiles_supported — drives broker sunset criteria | Sunset trigger |
resource = RFC 9728 identifier (spec §4) | Lab uses opaque mcp:// URIs — a documented deviation (issue #13, closed as documented) | Documented deviation |
One canonical JWT, five grant paths
Kong ACLs, server permission logic, and SIEM parsing are written once against one claim vocabulary, regardless of which grant path produced the token.
Always present
iss exact issuer · sub, azp, exp, iat — servers reject a token missing any of them · aud = exactly one tier audience (mcp://tier/*)
plus server URIs (mcp://srv/*) · jti joins every audit record ·
mcp_tier, idp_origin, mcp_contract pins ·
PS256/ES256 only, 5–10 minute lifetimes.
Conditional, enforced both ways
cnf sender-constraint — x5t#S256 (mTLS) on the m2m path and jkt (DPoP, RFC 9449) on the DPoP workforce path, each rejected without its matching binding ·
fhir_patient mandatory on the patient path, forbidden elsewhere — a hard
compartment filter on every FHIR query · act carries delegation chains ·
amr on interactive paths — clinical step-up scopes (MCP_MFA_SCOPES) are refused without mfa
(401 insufficient_user_authentication, RFC 9470) ·
directory PII is forbidden in access tokens.
Phase gates, in order
A phase is done only when tests/phaseN.sh is green. All eight were on the
last full run (2026-10-01, after both hardening passes): all 159 tests across phases 1–7
passed, none skipped (the real-GitHub egress leg included), plus the phase-0 smoke checks.
0 · Skeleton
tests/phase0.sh
Keycloak + Postgres + HAPI FHIR + Grafana stack; ~50 Synthea patients; hub realm from a git-tracked export.
1 · Identity hub
tests/phase1.sh · 72 tests
A fake-Ping Keycloak realm, real Auth0, and a toy homegrown issuer all normalize to contract-conformant JWTs from the single issuer.
2 · Gateway tiers
tests/phase2.sh · 11 tests
Konnect CP + local DPs; cross-tier replay fails in both directions; ACL misses are 403, not 401; DPs keep serving with the CP uplink severed.
3 · First-party MCP
tests/phase3.sh · 12 tests
Generated FHIR server + hand-built stateless scheduling server; speaks MCP 2026-07-28 through the gateway and still serves 2025-era clients; scope step-up via single-shot insufficient_scope challenges, an MFA mark on the clinical step-up token, and JSON-RPC batches refused so no call slips past it; replica kill mid-conversation survives.
4 · Cert-bound m2m
tests/phase4.sh · 9 tests
SPIRE-issued SPIFFE certs; client-x509 at Keycloak; the cnf-check plugin rejects tokens without the presenting cert.
5 · Egress + broker
tests/phase5.sh · 17 tests
Vendor Token Broker over OpenBao custody; DLP blocks planted MRNs and SSNs, JSON-escaped ones included; 20 parallel resolves produce exactly one vendor refresh (single-flight + generation CAS).
6 · Audit spine
tests/phase6.sh · 6 tests
One Loki query keyed by jti walks a vendor call across gateway verdicts, broker resolve, and the vendor action.
7 · Red team
tests/phase7.sh · 32 tests
Cross-tier replay, scope-ceiling probes, broker state replay, RFC 9207 iss tamper and omission, mass-STALE storm, token-in-log grep, URL-form client_id (CIMD) refusal, the broker's no-issuance rule, and DPoP sender-constraint (RFC 9449).
Code ↔ docs consistency review
Three independent review passes (broker vs design doc; servers, plugins, and agent vs claims contract; realm, gateway config, tests, and READMEs vs the doc set) verified the implementation against the documents, July 11, 2026. Verdict: faithful on every security-critical mechanic — single-flight refresh with generation CAS, RFC 9207 iss and iss-omission defense, PKCE S256 with single-use state, PS256/ES256 pinning with contract-exact claims, compartment filtering, mass-STALE paging, fail-closed vault, and the broker no-issuance rule all hold in code as documented.
| Finding | Resolution |
|---|---|
Auth0-origin token missing fhir_patient fell through to workforce handling | Fixed in both servers: required-direction check added alongside the forbidden-direction check (contract §8) |
| Broker doc self-conflict (§4.3 vs §10) and four production-vs-lab deltas undeclared | Doc reconciled; new broker design §16 "Lab implementation deltas" declares them in one place |
Stale xfail language in three test docs contradicted the green phase-7 suite | Corrected — all probes are plain asserts; issues #1/#2 recorded as closed |
Dangling bin entry pointed at a CLI that never existed | Removed from fhir-clinical/package.json |
| Wildcard redirect URIs in the realm (RFC 9700 exact-match) | Fixed — exact /callback registrations, crafted paths refused at the auth endpoint (issue #15 closed 2026-07-16) |
| Scheduling server lacks the Origin/Host rebinding guard fhir-clinical has | Fixed — guard ported verbatim; both servers reject rebound Host / foreign Origin; phase-3 gate green (issue #16 closed 2026-07-16) |
sol-rec*.md external-review scratch files, fully triaged | Removed; every open finding now lives in the issue tracker |
Repository audit — September 30, 2026
A full repository audit (AUDIT.md, a point-in-time record taken before the fixes) re-read the code,
reproduced findings on a fresh clone, and checked every claim in the docs. Its fixes shipped as release 2.0.0
(CHANGELOG.md); a second pass (2.0.1) made every phase start from a clean clone. The security findings:
| Finding | Resolution |
|---|---|
High: wrapping a tool call in a JSON-RPC batch skipped the per-tool scope check, so a token without the step-up scope could call patientEverything | Fixed — batches are refused (-32600) and every tool handler re-checks the policy; a phase-3 probe proves it |
| Medium: egress DLP matched raw bytes only, so a JSON-escaped MRN passed and decoded at the vendor | Fixed — dlp-egress also screens every JSON-decoded string and key, and denies declared-JSON bodies that do not parse; a phase-5 probe proves it |
| Clinical scopes were documented as needing an MFA mark, but nothing enforced it | Fixed — the FHIR server refuses MCP_MFA_SCOPES calls without amr∋mfa (401 insufficient_user_authentication, RFC 9470) |
dpop-check read only the first DPoP header; vendor-token had no explicit handling for DPoP-scheme tokens | Fixed — the gateway sees every DPoP header; vendor-token refuses DPoP-scheme tokens with a clear 401 and malformed broker replies with 502 |
| Servers spoke MCP 2025-11-25 while docs claimed 2026-07-28 (#8) | Fixed — both servers run MCP 2026-07-28 on SDK v2 from one shared resource-server core; verifiers now require every contract-mandatory claim |
| Dependency advisories (npm, PyJWT, starlette); broker 500s on bad input; non-constant-time secret compare in the legacy issuer stand-in | Fixed — advisories cleared and CI fails on new high-severity ones; broker returns 4xx problems without exception text; constant-time compare, non-root image |
| No offline tests; phases 0 and 2–4 failed from a clean clone | Fixed — make test runs 248 offline tests (servers 89, broker 97, Kong plugins 47, kit vectors 15); CI adds lint, CodeQL, Dependabot, and phase 0–1 clean-clone smoke runs |
Where the authority lives
The design documents below live in the project's public source repository; the paths are cited here as provenance. The rendered tours are hosted on this site.
Design authority — source repository
- docs/mcp-e2e-reference-architecture.md — the five invariants, gateway tiers, master diagram, HIPAA mapping, WAF appendix
- docs/mcp-token-claims-contract.md — the canonical JWT every component validates; grant-path profiles; audit vocabulary
- docs/vendor-token-broker-design.md — consent dance, refresh race, vault schema, sunset criteria (all sequence diagrams spec-role aligned)
- docs/prototype-plan.md — fidelity contract, substitution map, phases 0–7
Enterprise rollout kit — source repository
The lab is being packaged into a portable kit a delivery team can take into any enterprise — the lab stays the reference implementation; the kit is what travels.
- kit/blueprints/ — the control catalog (42 controls with stable IDs, enforcing code, proving test), portable token-claims contract, vendor-neutral gateway policy spec, broker portability profile, JSON Schemas, and claim-shape test vectors
- kit/acceptance/ — 58 portable conformance probes a customer runs against their own deployment, parameterized on an environment descriptor; the lab is the framework's own fixture
- kit/adapters/ — hub authorization-server requirements, per-IdP guides (Entra ID, Okta, Ping) in brokered and EMA/ID-JAG shapes, and a gateway capability matrix (Envoy/Istio, Apigee, Azure APIM, AWS API Gateway) — desk-checked until a real second-IdP leg runs the acceptance suite
- kit/compliance/ — the 42 controls mapped to HIPAA Security Rule citations, SOC 2 TSC criteria, and HITRUST assessment domains (public 19-domain level — the CSF license bars requirement-level reproduction), plus a shared-responsibility matrix; evidence-not-certification framing, compliance-SME review pending
- kit/playbook/ — the pilot rollout sequence (stages 0–7, exit criteria = acceptance probe families), a production-choices worksheet derived from the substitution map, and the dry-run protocol — draft until the kit-artifacts-only dry run executes
Rendered tours — on this site
- Product overview · Token lifecycle — the promises for any stakeholder, and every token from birth to expiry
- Overall · Functional · Overall · Technical — the system end to end: journeys, then ports, protocols, and validation matrix
- Modules · Functional · Modules · Technical — what each part does, then source-level module detail
Glossary
- MCP — Model Context Protocol: the open standard AI clients use to discover and call tools on servers
- EMA — Enterprise-Managed Authorization: the MCP extension that lets an enterprise IdP govern which AI clients may connect to which servers
- ID-JAG — Identity Assertion JWT Authorization Grant: the token-exchange profile EMA applies (RFC 8693 exchange at the IdP, then an RFC 7523 grant at the resource authorization server)
- DPoP — Demonstrating Proof of Possession (RFC 9449): each request carries a fresh signature from a client-held key, so a stolen token is useless without the key
- cnf — the JWT confirmation claim binding a token to a key or certificate —
jkton the DPoP path,x5t#S256on the mTLS path - Hub JWT — the Keycloak-issued MCP-plane access token every request carries; "hub" distinguishes it from upstream IdP tokens (which never cross into the plane) and vendor tokens (which exist only past the egress boundary)
- jti — the token's unique ID; the join key that lets one query walk an action across gateway, broker, and server audit records
- PRM — Protected Resource Metadata (RFC 9728): a server's machine-readable statement of which authorization server protects it — how clients discover where to log in
- Step-up — asking for more authorization only when a tool needs it: a 403
insufficient_scopechallenge names the missing scope, and for designated clinical scopes a 401insufficient_user_authentication(RFC 9470) demands a token minted after MFA - Tier wall — the gateway check that a token carries exactly the tier audience (internal or external) of the gateway it arrived at, so cross-tier replay fails
- SPIFFE / SVID — the workload-identity framework and its short-lived X.509 certificates (issued in this lab by SPIRE) — how services authenticate with no secrets
- DLP — data-loss prevention: pattern screening of outbound vendor-bound request bodies (medical record numbers, SSNs) before they leave the boundary
- Vendor Token Broker — the custodian that keeps per-user vendor OAuth grants in a vault and hands the gateway short-lived vendor tokens; it never mints MCP-plane tokens
- Single-flight refresh — when parallel calls find an expired vendor grant, exactly one refresh reaches the vendor; the rest wait and reuse the result (per broker process, CAS-guarded in the vault)
- Konnect CP / DP — Kong's SaaS control plane (configuration and aggregate telemetry only) versus the local data planes that proxy traffic — PHI never reaches the control plane
- Synthea — the synthetic-patient generator behind the lab's FHIR data — no real PHI exists anywhere in the lab