Architecture package
docs/ states the intended platform, token contract, vendor-broker rules, and phased lab plan. It is the design authority against which code is reviewed.
A module-by-module explanation of the repository in operational language: who uses each component, what outcome it creates, where data moves, and which controls it demonstrates.
The lab as implemented: client populations, the Keycloak issuer, two Kong tiers, first-party MCP servers, governed vendor egress, and the audit spine.
servers/shared/.The project is organized by operational responsibility. Documentation defines the contract, identity and gateway configuration enforce entry policy, servers expose first-party tools, the broker governs SaaS credentials, and acceptance suites prove selected invariants.
docs/ states the intended platform, token contract, vendor-broker rules, and phased lab plan. It is the design authority against which code is reviewed.
realm/ configures Keycloak as the hub that normalizes upstream identities into one MCP-plane token shape.
deck/ and plugins/ define internal, external, and egress routing plus tier walls, certificate binding, DPoP sender-constraint, DLP, and vendor-token replacement.
servers/ contains the FHIR clinical and scheduling MCP services. They validate hub tokens again and execute tools.
broker/ holds per-user vendor grants in OpenBao, performs consent and refresh, and returns a vendor token only to the gateway plugin.
compose/, agents/, tests/, and .github/ assemble the lab, drive workload identity, and verify phase gates.
Explains the enterprise target: one issuer, customer-controlled PHI boundary, stateless first-party servers, separate connection and tool governance, and explicit migration exits.
Its functional value is decision alignment: security, platform, identity, and compliance reviewers can evaluate the same trust boundaries and operating model.
docs/mcp-e2e-reference-architecture.mdDefines the JWT vocabulary used by gateways, servers, tests, and audit records: effective principal, calling client, tier, resource audiences, scopes, origin IdP, delegation, certificate binding, and optional patient compartment.
It prevents each consumer from inventing its own interpretation of identity.
docs/mcp-token-claims-contract.mdDefines how users connect SaaS accounts without placing personal access tokens on laptops or forwarding MCP hub tokens to vendors. It specifies consent, credential custody, refresh, revocation, failure behavior, and audit.
docs/vendor-token-broker-design.mdTurns the architecture into phases 0–7, each ending in an acceptance gate. It also names every production-to-lab substitution, including synthetic FHIR, SPIRE for workload certificates, OpenBao for vault custody, and Grafana for SIEM-like inspection.
docs/prototype-plan.mdFive upstream identities normalize to one canonical JWT.
realm/mcp-plane.jsonThe central identity configuration. It creates token scopes and mappers, normalized groups, identity-provider links, public PKCE clients, confidential service clients, and the certificate-authenticated loop-agent client.
Functionally, it ensures callers arrive at the MCP plane with consistent identity regardless of how they first authenticated. It also mints sender-constrained interactive tokens: the workforce-dpop client's tokens carry a cnf.jkt key binding, so possession of a token alone is never enough on that path.
realm/fake-ping.jsonA second Keycloak realm standing in for Ping. It provides a workforce identity source whose raw group vocabulary is deliberately different, allowing tests to prove that hub normalization removes upstream-specific names.
A deliberately small legacy client-credentials authorization server. Its tokens are not accepted by the MCP plane; Keycloak exchanges them into hub-issued tokens. This demonstrates the migration pattern for a frozen legacy issuer.
Source: compose/phase1/homegrown-issuer/
Patients authenticate against a real Auth0 tenant — the one leg of the lab that exercises a genuine external IdP rather than a stand-in. The hub brokers the login, and a managed user attribute links each Auth0 identity to its patient record, so customer tokens carry the fhir_patient compartment the clinical server enforces.
Source: realm/mcp-plane.json (auth0 identity provider)
The idempotent setup script adds Keycloak permissions and user-profile behavior that cannot be represented completely by a plain realm import, including legacy token exchange and managed patient-linkage attributes.
Source: compose/phase1/setup-phase1.sh
deck/internal.yaml publishes internal FHIR and scheduling routes, an internal tier-audience wall, certificate-binding and DPoP sender-constraint support, rate limits, and the governed SaaS egress routes.
It is the private entry path for workforce and workload clients.
deck/external.yaml publishes only the curated external FHIR surface. Its independent tier audience and route catalog reduce the blast radius of an internal configuration mistake.
cnf-checkWhen a token contains a certificate thumbprint, this plugin requires the request to arrive over TLS with the matching client certificate. A stolen certificate-bound token therefore cannot be replayed as an ordinary bearer token.
RFC 8705 propertydpop-checkWhen a token carries a cnf.jkt, this plugin requires a matching DPoP proof: the proof key’s thumbprint must equal the claim, and its method, URL, timestamp, and single-use identifier must hold. A sender-constrained token therefore cannot be replayed as an ordinary bearer token. Early rejection at the DP; the MCP server re-checks authoritatively.
dlp-egressReads outbound request bodies before vendor delivery, applies configured patterns — to the raw body and to every decoded JSON string, so escaping a value cannot hide it — blocks matches, and emits the pattern name—not the matched sensitive value—to audit logs. A body that cannot be scanned fails closed.
MRN and SSN lab patternsvendor-tokenCalls the broker with the validated hub JWT, receives the user’s vendor credential, and replaces the upstream Authorization header. The vendor sees its own token rather than the MCP-plane token. A key-bound DPoP token is refused rather than forwarded as a plain bearer token, and a malformed broker reply fails the call.
token isolationEach plugin directory includes a Kong schema describing allowed configuration. Setup scripts register those schemas with the internal Konnect control plane before declarative gateway state is synchronized.
Patient-compartment FHIR reads and stateless scheduling holds.
Exposes five curated read tools over a HAPI FHIR R4 backend: patient read, patient-everything, and searches for observations, conditions, and medication requests.
It performs OAuth bearer validation, filters tool visibility by group, challenges for per-tool scopes, forces customer searches into the token’s patient compartment, caps result count and response size, requires the mfa authentication mark for clinical step-up scopes, refuses batched requests so every tool call gets its own permission check, and audits final outcomes.
servers/fhir-clinical/Exposes find, hold, confirm, and release tools. A hold returns an explicit slot_hold_id; hold state lives in Postgres so either replica can continue the workflow.
The module demonstrates application-level continuity without an MCP session. It is a synthetic scheduling model, not a production booking engine.
servers/scheduling/Both servers publish Protected Resource Metadata and verify JWT signature, issuer, expiration, algorithm, and their configured resource audience using the authorization server’s JWKS — and authoritatively re-verify DPoP proofs on key-bound tokens.
It also rejects tokens missing any contract-mandatory claim, checks Host and Origin headers, and applies a per-client rate limit before any token work, as a second line behind the gateway’s limits.
One workspace package, servers/shared/, used by both servers.
Both servers write one JSON record for each tool decision, including token ID, principal, acting agent, calling client, origin IdP, tier, patient compartment, tool, decision, and timestamp.
OpenBao custody, single-flight refresh, DLP verdicts, and vendor-token isolation.
broker/app/main.pyOwns the HTTP API and state machine: resolve, consent start, OAuth callback, grant listing, grant revocation, admin vendor inspection, proactive refresh, stale-grant detection, and audit.
broker/app/hub.pyIndependently validates the incoming hub JWT before the broker trusts its subject. This prevents the gateway from becoming the broker’s only authentication boundary.
broker/app/config.pyValidates the broker’s configuration at startup, so a missing or malformed setting stops the service instead of surfacing later as a failed request. Bad client input gets a clear 4xx answer, never an internal error.
broker/app/vendors.pyLoads the reviewed vendor registry and implements authorization-server discovery, code exchange, refresh, vendor user lookup, and revocation. GitHub-specific behavior is isolated here.
broker/app/vault_store.pyProvides the OpenBao KV v2 storage adapter, including compare-and-swap writes, metadata deletion, subject listing, and separate read access for vendor client credentials.
broker/registry.jsonThe allowlist of enabled vendors, OAuth endpoints or metadata locations, scope ceilings, user lookup, and revocation strategy. It makes vendor onboarding a reviewed configuration change.
A deterministic vendor authorization server and MCP endpoint. It issues 60-second access tokens, rotates refresh tokens, burns a family on replay, enforces PKCE, supports RFC 9207 issuer identification and RFC 7009 revocation, redirects only to the registered callback, and exposes test counters.
Source: compose/phase5/mock-vendor/
Each phase is a cumulative runnable environment, and each starts from a clean clone with its own example settings file. Phase 0 starts identity, FHIR, Postgres, and observability. Later phases add brokered identity, Kong tiers, MCP servers, certificate-bound workload identity, and governed egress.
The setup scripts create or reuse Konnect control planes, provision DP certificates, synchronize decK state, generate lab PKI, register plugin schemas, provision OpenBao, and deploy SPIRE plus the loop agent.
Runs continuously in k3d. On each iteration it rereads the current SPIFFE certificate, gets a certificate-bound Keycloak token, checks the token thumbprint, then finds, holds, and releases a scheduling slot over mTLS.
It proves secretless workload identity and certificate rotation without a pod restart.
seed-synthea.sh downloads a pinned Synthea build, generates synthetic patients, and posts transaction bundles to HAPI. The committed output is test data, not real PHI.
Grafana Alloy tails phase-5 container logs into Loki. Kong exports traces and plugin logs through OpenTelemetry Collector. Tempo stores traces and Grafana provisions the data sources and audit-tuple dashboard.
The Node servers use multi-stage builds and run as the non-root node user. The broker and loop agent use slim Python images and run as UID 65534. Server images include PRM-based health checks.
Verify baseline token claims and FHIR data, identity normalization across grant paths, tier replay rejection, gateway resilience during control-plane uplink loss, and decK drift.
Verifies role-shaped tool lists, scope step-up, patient-compartment enforcement, and cross-replica scheduling continuity using explicit hold handles.
Verifies zero secrets in the workload manifest, correct certificate-bound token claims, rejection without or with the wrong certificate, successful matching-certificate calls, and live certificate rotation.
Verifies consent, DLP, single-flight refresh, revocation, fail-closed vault behavior, end-to-end audit joins, replay and scope attacks, DPoP sender-constraint probes, RFC 9207 defenses, stale-grant alerts, log-secret absence, and broker non-issuance.
Runs, on every push and pull request: lint, format, and type checks; the offline test suites with coverage (servers, broker, kit vectors, DB-less Kong plugins); image builds; link, shell, and workflow linting; decK and compose validation; and blocking npm and pip audits. CodeQL and Dependabot run alongside. CI also brings up the account-free phase 0 and phase 1 quickstarts from a clean checkout and runs their gates. Phases 2–7 stay manual because they need a Kong Konnect account.
The acceptance clients send the 2026-07-28 envelope and headers, and phase 3 probes server/discover plus the 2025 fallback. An offline suite (make test) runs the servers against the official v2 client. A formal MCP conformance suite is still not part of CI.