Skip to main content
Glama
clinical-fhir-agent

clinical-fhir-agent

clinical-fhir-agent

An MCP server and LLM agent that answer clinical questions about synthetic FHIR R4 patients — with every answer cited, refusals when the data don't support an answer, and a reproducible evaluation of how often it gets things right.

⚠️ Not a medical device. This is an engineering and portfolio project. It uses synthetic data only (Synthea), is not certified, and must not be used with real patient data or to make health decisions. See intended use.


Why this project

Demos of LLM agents on medical data are easy; knowing how often they are wrong, and how is the hard part. This project treats the evaluation as the main deliverable:

  • a golden set whose expected answers are computed from the FHIR data, not written from memory or by an LLM;

  • a dev/test split by patient, so prompt tuning never sees the held-out data;

  • metrics for accuracy, hallucination, citation validity and correct refusal, per question category, with confidence intervals over repeated runs;

  • versioned, regenerable reports tied to a commit, a model ID and a dataset digest.

Development follows a lightweight version of the processes used for medical-device software (IEC 62304, ISO 14971): requirements, risk analysis with risk controls verified by evaluation metrics, SOUP list (the LLM included), and traceability enforced in CI.

Related MCP server: his-tools

System overview

 Synthea cohort (pinned) ──► local HAPI FHIR R4 ◄── REST ── MCP server (read-only tools)
                                                                  ▲ MCP
                                                    LLM agent ────┘
                                                    → {answer, citations[], refused}
                                                                  ▲
                                   evaluation: oracle golden set → runner → scorers → report

Details: architecture and ADRs.

Status

Milestone 0 (foundations) complete: a pinned synthetic cohort of 50 patients, loaded into a local FHIR server by a loader that accepts only verified synthetic data. Milestone 1 (MCP server) in progress. See milestones.

Milestone

Content

M0

Repository, CI, process documents, synthetic cohort, local FHIR server

M1

MCP server with read-only FHIR tools

M2

Agent with cited answers and refusals

M3

Evaluation v1: golden set, deterministic scorers, baseline report

M4

Evaluation v2: hallucinations, calibrated judge, adversarial cases, held-out run

M5

System card, final risk review, results

Development

Requires uv and Docker.

uv sync
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run mypy
uv run python scripts/traceability.py --check

Documentation

Document

Content

Intended use

Purpose, scope, foreseeable misuse, assumed safety class

Development plan

Lifecycle, roles, verification strategy

Requirements · Traceability

What the software must do, and how each requirement is verified

Risk analysis

Hazards of a wrong answer and their controls

SOUP

Third-party software, services and models

Open points

Pending decisions and known gaps

License

Code: Apache-2.0.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Exposes a FHIR endpoint as deterministic read-only tools, providing a context layer for retrieving clinical data from FHIR servers.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables LLM agents to query de-identified FHIR-shaped hospital data through audited, read-only tools for patients, encounters, conditions, observations, medications, and interaction checks, while any medication write stays a draft that a clinician must confirm out-of-band.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Gives AI agents read-only access to patient context on any FHIR R4 server, including journey timelines of encounters and appointments, open booking slots, and discharged patients whose follow-ups were never booked. Search, appointment, and follow-up tools return compact summaries, so agents can answer front-desk and outreach questions without write access.
      5
      MIT