# FHIR AI agents need a policy broker — not a direct database connection

> Putting LLM agents on EHR data is a connection-shape problem: policy brokers, scoped SMART apps or constrained MCP tools beat warehouse SQL. Writes should be proposals humans approve, with model and tool calls in the audit trail.

- Author: Arjun Patel
- Published: 2026-11-29
- Canonical: https://www.threeindex.com/blog/fhir-ai-agents-policy-broker-not-direct-db
- Tags: Healthcare, FHIR
- Related: https://www.threeindex.com/healthcare/system-integration

## The connection shape decides what you can enforce

Benchmarks like FHIR-AgentBench show that agents struggle with realistic FHIR graphs even when they can call APIs and run code. The harder product problem is policy: once an agent can reach patient data, prompts are not a substitute for authorization.

Four patterns dominate. A policy broker sits between agent and FHIR server and evaluates every call. A scoped SMART app uses OAuth scopes that last for a session. An MCP tool layer over FHIR makes tools enumerable and testable. Direct database or warehouse access is the anti-pattern for identifiable data.

Pick the pattern in the architecture brief before prompt engineering starts. You cannot retrofit compartment awareness into free-form SQL later.

## Policy brokers and MCP tools beat prompt promises

Brokers hold credentials, apply per-call rules, redact fields and produce a complete audit. MCP tools over FHIR shrink the surface to named operations — still treat tool descriptions as injection surface and validate arguments server-side.

SMART scopes are portable and familiar, but coarse: whatever you mint for the session the agent may use for the whole session. Prefer narrower tools or a broker when the agent chains many steps across compartments.

Default deny. Explicit allow lists of resource types, profiles, time windows and code systems beat "the model knows HIPAA."

## Writes go to a proposal queue

The safest agent write path does not write. It proposes a candidate resource, holds it for human approval, then commits. Failure becomes a rejected draft instead of a corrected chart after harm.

Record the approval as accountability in the clinical record path — Provenance-style linkage of who approved, which model version drafted, and which tool produced the payload.

Read-only pilots are a sane first slice. Bidirectional write without a queue is how compliance reviews end projects.

## Audit must reconstruct the agent as an actor

Six months later you need to answer: which model and prompt revision, which tools and parameters, which patient compartment, which human approved. If that lives only in ephemeral logs, you do not have an audit trail.

Store enough structure to replay authorization decisions, not only that "an access occurred." Align identity so the agent never impersonates a clinician without an on-behalf-of context your IdP understands.

Related habits for non-AI healthcare products still apply: healthcare software beyond the chart UI.

## Retrieval quality is an engineering problem

FHIR-AgentBench results show multi-turn retrieval and code execution help, while precision stays noisy when recall is prioritized. Product teams should constrain tools to precise searches and structured extraction rather than dumping whole charts into context.

Minimum necessary is both a privacy rule and a quality rule. Smaller, scoped context reduces leakage and hallucination fuel.

Evaluate agents on your resource profiles and implementation guides, not only on public quiz benchmarks.

## What to put in the integration brief

List allowed FHIR resources and profiles, read versus propose-write permissions, IdP and SMART details, MCP or broker choice, retention of tool logs, and the human roles that approve writes. Name the EHR sandbox path and who owns App Orchard or equivalent access.

Exclude warehouse shortcuts for PHI. Exclude autonomous order placement unless a separate regulatory path exists.

Ask partners to demo a rejected proposal and a complete audit reconstruction — not only a happy-path read.

## How ThreeIndex delivers FHIR-aware agents

Our system integration work starts from authorization and audit, then wires AI. Healthcare AI features stay suggest-and-propose unless you explicitly scope a regulated decision-support path. Code and cloud stay in accounts you own.

We treat MCP and agent runtimes as dependencies to allowlist — same discipline as any other integration surface.

Send a brief with your FHIR surface, write ambitions and who must approve agent proposals. We will design a first slice that can survive a compliance review.

## FAQ

### Should an AI agent query the EHR database directly?
No for identifiable clinical data. Prefer a policy broker or tightly scoped FHIR and MCP tools so every read and proposed write is authorized, redacted and auditable.

### How should AI agents write back to FHIR?
Prefer proposal queues: the agent drafts a resource, a human approves or rejects, then the approved payload reaches the FHIR server. Record the approval in Provenance or equivalent audit.

### How does ThreeIndex build FHIR-aware AI integrations?
We design integration and AI slices with authorization, audit and human approval in client-owned environments — see system integration and healthcare AI solutions.

## About ThreeIndex

ThreeIndex is an AI-first software development company building web, mobile, cloud and AI software for teams worldwide. Founded in 2020.

- Site: https://www.threeindex.com/
- Contact: https://www.threeindex.com/contact
- LLM index: https://www.threeindex.com/llms.txt
