MCP Guardrail Patterns for Healthcare AI

How tenant isolation, access control, audit trails, and human-in-the-loop work together when AI agents access clinical data through FHIR R6 + MCP

Status
Version
FHIR Version
Resource Types
Operations
Data Source
0
Audit Events

Agent Guardrail Sequence

LIVE DEMO

Watch an AI agent attempt to write clinical data through 6 security guardrails in 60 seconds. Each step demonstrates a real pattern: PHI redaction, $validate, Permission $evaluate (deny then permit), HMAC step-up auth, human-in-the-loop, and immutable audit trail.

Patient Explorer

Read/Write

Create a sample patient, read it back with PHI redaction, and search. Identifiers are masked, addresses stripped, telecom redacted.

ETag:

MCP Agent Tool Loop

MCP

Select a tool, provide input, and execute. Read tools require no step-up; write tools require HMAC authorization. All emit AuditEvents.

Context Envelope Builder

Bundle

Ingest a patient-centric Bundle to build a bounded context envelope (TTL 30 min). The envelope provides a policy-stamped, time-limited view for agent context windows.

Context:

HIPAA Safe Harbor De-identification

PHI

Side-by-side comparison: standard redacted read vs. full Safe Harbor de-identification (45 CFR 164.514(b)). Names, IDs, addresses, dates generalized to year.

Standard Redaction
Safe Harbor De-identified

Human-in-the-Loop Enforcement

Clinical Safety

Clinical writes (Observation, Condition, etc.) require X-Human-Confirmed: true header. Without it, the server returns HTTP 428 Precondition Required. This prevents autonomous agent writes to clinical data without human review.

OAuth 2.1 + PKCE Flow

Security

Full OAuth 2.1 flow: Dynamic client registration (RFC 7591), Authorization with PKCE S256, Token exchange, and Revocation (RFC 7009). SMART-on-FHIR v2 compatible.

R6 Ballot Resources & Operations

BALLOT

Resources new or restructured in R6 (v6.0.0-ballot3): Permission (access control, separate from Consent), SubscriptionTopic (restructured pub/sub), NutritionIntake, DeviceAlert. Operations $stats and $lastn are standard FHIR operations (available since R4) demonstrated here with stored data.

Scope: This is a reference implementation for exploring R6 ballot resources and MCP guardrail patterns — not a production FHIR server. Validation is structural only (required fields + value constraints). Search supports code, status, patient, and _lastUpdated parameters.

R6 Permission — Access Control

R6 NEW

R6 separates Permission (machine-readable access rules) from Consent (patient agreements). Permission encodes attribute-based access control with deny-overrides/permit-overrides combining. Create a Permission, then evaluate access decisions via $evaluate.

Observation $stats & $lastn

FHIR Std

Standard FHIR operations (available since R4): $stats computes min/max/mean/count over stored numeric Observation values, $lastn returns the most recent observations per code. Both support patient + code filtering. Implementation limited to valueQuantity (numeric observations only).

Topic-Based Subscriptions

R6 Ballot

R6 restructures Subscription around SubscriptionTopic (introduced in R5, maturing in R6). Topics define triggerable events. This demo stores topics and subscriptions but does not dispatch notifications — it demonstrates the resource model and discovery pattern only.

R6 New Resources

R6 Core

NutritionIntake: Records food/liquid/supplement consumption (hospitals, meal tracking, school districts). DeviceAlert: Medical device alert/alarm conditions aligned with ISO/IEEE 11073 and IEC 60601-1-8.

Curatr — Patient Data Quality

NEW v1.0

Patient-owned data quality evaluation. Creates a Condition with a retired ICD-9-CM code, evaluates it against live terminology APIs (NLM ICD-10-CM, tx.fhir.org), presents issues in plain language, then applies patient-approved fixes with a linked Provenance record.

Flow: Create ICD-9 Condition → $curatr-evaluate (live terminology check) → Review issues → $curatr-apply-fix (update + Provenance). No black-box corrections — patient decides.

Resource Validation ($validate)

Read-only

Validate a FHIR R6 resource against structural rules. Agent proposals must pass validation before commit.

Live Audit Feed

Append-Only
No audit events yet. Interact with the panels to generate events.

Security Posture

Tenant Isolation Enforced
HMAC Step-up Tokens Required
PHI Redaction All Reads
Human-in-the-Loop Clinical
OAuth 2.1 + PKCE S256
Audit Trail Immutable
ETag Concurrency If-Match
Medical Disclaimer Injected
Curatr Data Quality Patient-Owned