MCP Healthcare Reference
Modules · FunctionalModules · TechnicalOverall · FunctionalOverall · Technical
Verified system guide · Overall technical view

Architecture, protocols, state, and controls

A cross-module technical model of the running lab (the phase 5 compose stack plus the phase 6 audit spine): processes and ports, trust boundaries, token paths, request sequences, persistence, failure behavior, audit joins, and the precise delta to the upcoming MCP specification.

Lab topology: client populations, the Keycloak issuer, two Kong gateway tiers, first-party MCP servers, governed vendor egress, and the audit spine

The lab as implemented: client populations, the Keycloak issuer, two Kong tiers, first-party MCP servers, governed vendor egress, and the audit spine.

Runtime architecture

Clients

Workforce PKCE client
DPoP-bound workforce client
Patient PKCE client
mTLS loop agent
Test clients

→
Identity + gateway

Keycloak hub
Kong internal DP
Kong external DP
cnf · dpop · DLP · vendor-token plugins

→
Destinations

FHIR MCP → HAPI
Scheduling MCP → Postgres
Broker → OpenBao
Vendor MCP

Control plane

Two Konnect hybrid control planes are created and configured through API/decK. Local Kong data planes establish mTLS uplinks through an Nginx alias proxy and cache configuration for disconnected operation.

Data plane

Requests stay on local Docker/k3d paths except real Konnect control traffic and optional real Auth0/GitHub integrations. HAPI data is synthetic. Kong first-party routes forward to container ports; egress routes forward only to registered vendor service URLs.

Application state

MCP transport sessions are disabled. FHIR calls are request-local. Scheduling continuity is a UUID handle in Postgres. Broker grants are versioned OpenBao entries, while consent transactions and single-flight locks are process-local memory.

Evidence plane

Services emit JSON audit lines. Alloy ships Docker logs to Loki. Kong exports OTel logs/traces through Collector to Loki/Tempo. Grafana queries by token ID or hub JTI.

Lab endpoints and ports

Host portComponentPurposeSecurity posture in lab
3000Grafanadashboardslocal admin credential
3100 / 3200Loki / Tempologs / traces APIsno auth, local lab
4317 / 4318OTel CollectorOTLP gRPC / HTTPcompose-network and host exposed
7001homegrown issuerlegacy token issuerHTTP, static lab client
8080Keycloakpublic lab issuer and browser flowsHTTP development mode
8081HAPI FHIRsynthetic R4 backenddirect host access for tests
8100Kong internalworkforce/internal MCP and egressHTTP bearer path
8143Kong internal TLScertificate-bound agent pathlab-CA TLS + client cert inspection
8200Kong externalcurated patient/partner surfaceHTTP bearer path
8210OpenBaodev Vault APIdev root token; broker uses scoped token
8300brokerconsent and grant APIHTTP; hub JWT on protected routes
8310mockhubmock OAuth AS and vendor MCPHTTP test service
8443Keycloak TLSmTLS client credentialslab-CA TLS; requests client cert
Note what is absent: the first-party MCP servers expose no host ports at all — they are reachable only through the gateway tiers. These ports describe the Phase 5 Compose lab. Production target URLs in the architecture are HTTPS and privately/publicly exposed according to tier; the committed Compose configuration is not a production network policy.

Token model and validation matrix

{
  "iss": "hub issuer",
  "sub": "effective principal",
  "aud": ["one tier audience", "one or more server resources"],
  "azp": "calling client or agent",
  "exp": 0, "iat": 0, "jti": "opaque join key",
  "mcp_contract": "1.0",
  "mcp_tier": "internal | external",
  "idp_origin": "ping | athenz | homegrown | keycloak | auth0",
  "scope": "space-delimited scopes",
  "act": {"sub": "acting workload"},
  "cnf": {"x5t#S256 | jkt": "certificate or DPoP key thumbprint"},
  "fhir_patient": "conditional patient ID",
  "groups": ["normalized roles"]
}
ValidationKong tier wall / OIDCMCP serversBroker
JWT signatureOIDC only on selected routes; pre-function itself parses unverifiedyes, remote JWKSyes, remote JWKS
AlgorithmOIDC configuration-dependentPS256 / ES256PS256 / ES256
Issuer / expirationOIDC routesyesyes + 30s leeway
Tier audienceinternal/external wallexactly one tier-shaped audience, but no tier-claim matchinternal audience + one tier-shaped audience
Server resource audiencefirst-party routes defer to serverconfigured audiencenot applicable
Mandatory contract claimsroute-specificrequires sub/azp/exp/iat/jti plus contract/tier checks (since 2026-09-30)requires exp/iat/sub/jti plus contract/tier checks
Certificate bindingcnf-check at internal DPnot recheckedlab substitution; hub bearer revalidation
DPoP sender-constraintdpop-check early rejection at internal DP; proof-replay cache fails closed (503) if the shared dict is missing or an insert errorsre-checked via requireDpop against cnf.jktnot applicable
Tool scopecoarse route policyHTTP-layer challenge plus a re-check in every tool handler; JSON-RPC batches refusedvendor scope ceiling and grant coverage
MFA (amr)not checkedmfa required for MCP_MFA_SCOPES (FHIR step-up); 401 insufficient_user_authenticationnot applicable
Patient compartmentdeferredenforced; Auth0-origin tokens without a non-empty claim are rejectednot applicable

End-to-end request sequences

Workforce clinical call

Client
Authorization code + PKCE via Keycloak, optionally brokered to fake Ping/Auth0. Receives a hub access token.
Internal Kong
Global tier pre-function requires mcp://tier/internal. The claim-driven sender-constraint plugins (cnf-check, dpop-check) pass plain bearer tokens untouched and enforce only when the token carries a binding. Rate limit applies. First-party route forwards to FHIR server.
FHIR server
A Host/Origin guard and a per-client rate limit (MCP_RATE_LIMIT_PER_MIN, default 600) run before any token work. A DPoP scheme shim then normalizes any DPoP auth header before bearer middleware verifies signature/issuer/expiry/resource audience; when the token carries cnf.jkt, requireDpop re-validates the proof. JSON-RPC batch arrays are refused. For tools/call, required scope (and amr∋mfa for MFA-gated scopes) is checked at the HTTP layer and again inside the tool handler. Tool list is group-shaped.
Authorization hook
When a patient claim exists, by-ID equality or forced search parameter is applied.
HAPI
Receives a bounded GET request. Response is capped and converted to MCP text content. Final status determines audit allow/deny.

Certificate-bound scheduling call

SPIRE helper
Writes short-lived SVID certificate/key into shared volume and rotates them.
Loop agent
Reads certificate, requests Keycloak client credentials over mTLS, validates the token’s x5t against the same certificate.
Kong :8143
Requests the client certificate. cnf-check compares leaf SHA-256 thumbprint to token claim before forwarding.
Scheduling
Revalidates token and scope, then uses Postgres for the hold. Explicit slot_hold_id carries continuity between calls/replicas.

Governed vendor call

Internal Kong
OIDC validates the egress resource audience. DLP scans the raw body and every JSON-decoded string and key (so escapes cannot hide a match; a declared-JSON body that does not parse is denied) and records allow/deny.
vendor-token
Refuses a DPoP-scheme token (401; the broker does not check proofs). Otherwise calls broker resolve with hub Authorization plus vendor, subject, JTI, TTL, and required scopes; an unreachable broker or a malformed reply is a 502.
Broker
Revalidates hub JWT; reads OpenBao; returns token, consent URL, re-consent URL, or a closed failure. Refresh is single-flight per process and CAS-protected in OpenBao.
Kong
Replaces the hub Authorization header with the vendor access token.
Vendor
Receives screened MCP body and its own credential only.
Governed egress: DLP screening at the gateway, broker resolve from vault custody, vendor token swap

OpenBao custody, single-flight refresh, DLP verdicts, and vendor-token isolation.

State ownership and failure behavior

StateOwnerDurabilityFailure behavior
Keycloak users, clients, grantsPostgresCompose volumeidentity unavailable if Keycloak/Postgres down
FHIR synthetic recordsHAPI/PostgresCompose volumetool returns upstream error; audit deny
Scheduling holdsPostgresCompose volume, cross-replicaDB error becomes tool error; schema startup blocks listener
Vendor grantsOpenBao KV v2dev-mode memory in labVault failure returns 503; no vendor call
Broker token cachebroker process60-second memory cachecache loss rereads Vault
Consent transaction/statebroker process10-minute memory onlyrestart invalidates active browser flows
Refresh lockbroker processmemory only10-second timeout then reread; multiple replicas can duplicate refresh requests
Gateway configurationKonnect DP cacheDP local cacheDP continues serving during CP uplink loss
Audit logs/tracesLoki/Tempo filesystemCompose volumeslab-only single-node retention

MCP 2026-07-28 compliance status

Current wire behavior (since 2026-09-30)

  • Official v2 server packages; fresh McpServer per request via createMcpHandler.
  • 2026-07-28 requests carry protocol version, clientInfo and clientCapabilities in _meta; server/discover answers with supported versions.
  • The SDK checks the MCP-Protocol-Version / Mcp-Method / Mcp-Name headers against the body.
  • 2025-era requests are still served, by the SDK’s stateless legacy fallback.
  • The acceptance clients send the 2026-07-28 shape; phase 3 probes discovery and the fallback.

Required modern behavior (all but the conformance gate done)

  • Upgrade to the official v2 client/server packages supporting modern and legacy eras.
  • Implement server/discover and advertise supported versions/capabilities/serverInfo.
  • Require protocol version, clientInfo, and clientCapabilities in request _meta.
  • Validate MCP-Protocol-Version, Mcp-Method, and conditional Mcp-Name against the body.
  • Return modern HTTP status and JSON-RPC error codes.
  • Update all clients/tests and add a conformance gate.

Transport lifecycle

Modern HTTP exposes POST only; GET and DELETE on /mcp answer 405 after authentication (no server-initiated stream, no session teardown). Request-scoped SSE remains optional. Client disconnect should cancel work: the FHIR fetch has a timeout signal but is still not wired to the client disconnect signal.

Backward compatibility

If legacy support is required, v2 auto-negotiation should probe modern discovery and fall back to initialize-era behavior. The server must distinguish modern protocol errors from legacy endpoint absence.

OAuth 2.1 / related RFC compliance delta

AreaPresentRequired remediation
PKCEPublic clients and broker use S256; mockhub enforces verifierBroker must verify discovered AS metadata advertises S256 before starting authorization
Protected Resource Metadatapath-inserted and root routes; authorization server list; header method; DPoP signing algorithms; empty scope lists omittedUse canonical HTTPS MCP endpoint as resource (the mcp:// form is a documented deviation, issue #13); match retrieval/request URL exactly
Resource indicatorsserver audience is checkedReplace mcp://srv/* PRM resource with HTTPS endpoint resource; retain tier audience separately if desired
Authorization server discoveryKeycloak OIDC discovery; vendor RFC 8414 fetchValidate metadata issuer and HTTPS endpoints; implement MCP-prescribed discovery behavior in clients
Issuer identificationbroker validates RFC 9207 issuer when advertisedEnsure every operated OAuth client validates issuer, including errors; production issuer must be HTTPS
Redirect URIsPKCE clients register exact localhost /callback URIs (RFC 9700 exact match; issue #15 closed)Done in the lab; production keeps exact registration (native loopback port variance per RFC 8252 where a client requires it)
Transport securitymTLS workload leg; otherwise HTTP labProduction TLS everywhere with consistent public issuer/resource URLs
Refresh protectionmock rotation/replay burn; broker CAS/single-flightDistributed lock for multi-replica broker; sender constrain or rotate public-client refresh tokens at AS
Sender-constrained tokensDPoP enforced at the internal DP and re-checked at the servers for workforce-dpop; mTLS cnf binding for workloadsExtend to claude-code when the client ships proof support; production should enforce DPoP at the AS for all public interactive clients
Token passthroughvendor route replaces hub token; the FHIR server never forwards the caller’s token (optional server-owned UPSTREAM_API_KEY only)Done — the dormant passthrough branch was deleted in the 2026-09-30 server rewrite

Audit tuple and evidence path

token_id / hub_jti → principal → acting_agent → client
                     → origin_idp → tier → patient_compartment
                     → server / route → tool → decision / reason → timestamp

Server evidence

FHIR and scheduling audit the final tool outcome. FHIR distinguishes compartment, upstream exception, and upstream HTTP denial. Scope middleware audits insufficient scope.

Gateway evidence

cnf-check logs certificate-binding denials. dpop-check logs proof rejections and degraded-cache events. DLP logs both clean passes and blocks. vendor-token logs broker decisions and DPoP-scheme refusals. OpenTelemetry adds request traces.

Broker evidence

Consent, resolve path, refresh generation, stale transition, mass-stale page, revoke, security callback failures, and admin denial are JSON events.

Limitations

The lab is not an immutable SIEM, has no production retention policy, and uses unauthenticated local Loki/Tempo. Audit completeness still depends on every rejection path emitting a record.

Verification and next assessment gate

Current checks

All eight phase gates were green on the last full run (2026-10-01 on main 0638fdf: 159 of 159 tests, nothing skipped, the real-GitHub egress and Auth0 legs included — phase 1: 72, 2: 11, 3: 12, 4: 9, 5: 17, 6: 6, 7: 32, plus phase 0’s 4 smoke checks). Every phase also starts from a clean clone. The offline suite (make test, no accounts) holds 248 tests: servers 89, broker 97, DB-less Kong plugins 47, kit claim vectors 15 (plus 4 skipped). The npm workspace build (shared core and both servers) is clean. On 2026-09-30, npm audit and pip-audit reported zero known vulnerabilities, and CI now fails on any high-severity advisory.

CI boundary

GitHub Actions runs lint, types, the offline suites, image builds, decK/compose/realm validation, link and shell checks, and blocking npm audit / pip-audit; CodeQL and Dependabot run alongside. CI also brings up the phase 0 and phase 1 quickstarts from a clean checkout and runs gates 0–1. Konnect/Auth0/GitHub/k3d acceptance (phases 2–7) remains manual.

Reassessment prerequisites

  1. Modern SDK/wire migration and conformance tests. Migration done (2026-09-30); a formal conformance suite remains.
  2. HTTPS canonical resource migration.
  3. Central contract-exact token validation. Done — one shared verifier (2026-09-30).
  4. Scheduling Origin and booking-state fixes. Done — hold lifecycle (issue #12) and the Origin/Host guard (issue #16, 2026-07-16).
  5. OAuth metadata/redirect/TLS hardening. Redirect exact-match landed (issue #15); metadata and TLS items remain.

Required evidence

Run builds, dependency audits, new unit tests, modern MCP conformance, Origin negatives, OAuth discovery/PKCE/redirect tests, phases 0–7, race tests, and a fresh token-in-log scan. Record exact versions and the deployed configuration commit.

No current certification claim: the architecture is well developed and several controls are genuinely implemented, but the current repository cannot accurately claim MCP 2026-07-28, RFC 9728, or production OAuth 2.1 compliance until the listed deltas are closed and verified.