HealthChain
This server provides FHIR tools for healthcare AI agents to build, validate, read, and code clinical data.
Build FHIR resources from flat fields (Condition, MedicationStatement, Observation, AllergyIntolerance, Patient) with automatic nesting and validation.
Validate FHIR resources against spec and value-set bindings, returning issues to correct.
Load FHIR Bundles from file or JSON string to serve as the working data for read tools.
Read resources as full FHIR JSON or flattened coded entries (with status filtering and medication reference resolution).
Resolve FHIR references (e.g., Patient/123, urn:uuid, contained refs) within the loaded bundle.
Look up terminology codes via free-text search or browse the full catalog, ensuring no invented codes.
Connect Python pipelines and applications to live FHIR APIs, build and validate structured output, and deliver it through REST, CDS Hooks, CDA, MCP, or LangChain.
Installation
pip install healthchainRelated MCP server: FhirMCP
What HealthChain Does
HealthChain puts a consistent FHIR boundary around your Python code: live data in, your own logic in the middle, and validated FHIR out. Built for research software, healthcare data, and AI teams.
Why HealthChain?
Every healthcare data team rebuilds the same integration layer. Whether your logic is rule-based, a logistic regression, or an agent, it needs authenticated access to real FHIR APIs and a reliable way to turn output into coded FHIR. Pipelines tied to one site's warehouse don't travel, and structural or coding errors may only be discovered downstream.
HealthChain handles that layer so you can focus on your logic and your domain.
Live data, not exports — Connect to live FHIR APIs instead of site-specific warehouse queries and stale extracts
Keep connection details out of pipeline logic — Load endpoints and credentials from environment-backed configuration
Build FHIR with less boilerplate — Use flat, typed helpers instead of manually assembling deeply nested resources
Catch errors early — Get structured validation reports with failing field paths and actionable diagnostics
Resolve codes instead of guessing them — Map free text through a swappable terminology lookup before building a resource
Choose how to deliver the result — Expose output through FHIR REST services, CDS Hooks, SOAP/CDA, MCP, or LangChain
🏆 Recognition & Community
Featured & Presented:
Featured in TLDR AI Newsletter (900K+ developers)
Featured by Medplum for open source integration with Epic
Presented at NHS Python Open Source Conference (watch talk)
Built from NHS AI deployment experience – read the origin story
🤝 Pilots & Partnerships
Exploring HealthChain for your product or organization? Get in touch to discuss integrations, pilots, or collaborations, or join our Discord to connect with the community.
Usage Examples
Build a FHIR Service
Expose Multiple FHIR Sources [Docs]
from healthchain.gateway import HealthChainAPI, FHIRGateway
from healthchain.gateway.clients import FHIRAuthConfig
from healthchain.fhir.r4b import Bundle, Patient
# Create a FHIR-connected service
app = HealthChainAPI(title="Multi-EHR Patient Data")
# Credentials are loaded from EPIC_* and CERNER_* environment variables
fhir = FHIRGateway()
fhir.add_source("epic", FHIRAuthConfig.from_env("EPIC").to_connection_string())
fhir.add_source("cerner", FHIRAuthConfig.from_env("CERNER").to_connection_string())
@fhir.aggregate(Patient)
def patient_data(id: str, source: str) -> Bundle:
"""Fetch patient data from any configured FHIR source."""
bundle = fhir.search(
Patient,
{"_id": id},
source,
add_provenance=True,
provenance_tag="healthchain-source",
)
return bundle
app.register_gateway(fhir)
# Available at: GET /fhir/aggregate/Patient?id=123&sources=epic&sources=cerner
if __name__ == "__main__":
app.run(port=8888)Scaffold with the CLI
Turn a working pipeline into a configurable FHIR service:
healthchain new my-app -t fhir-gateway
cd my-app
healthchain serveAdd your logic in app.py. Use healthchain.yaml to configure FHIR sources and service settings while keeping credentials in environment variables. See the CLI reference for all commands.
Agent and Assistant Workflows
Give an Agent FHIR Tools [Docs]
from healthchain.tools import FHIRToolkit
# One toolkit: build, validate, read, and code FHIR — as typed agent tools
kit = FHIRToolkit(bundle="patient_bundle.json")
kit.as_mcp().run() # serve to Claude or any MCP client
tools = kit.as_langchain() # or drop into a LangChain agentOr serve the tools straight from the terminal:
healthchain mcp --bundle patient_bundle.jsonBuild with an AI Assistant
Install the HealthChain plugin to give Claude Code or Codex the current API, CLI, and recipes:
# Claude Code
/plugin marketplace add healthchainai/HealthChain
/plugin install healthchain@healthchain
# Codex
codex plugin marketplace add healthchainai/HealthChain
codex plugin add healthchain@healthchainOr point any assistant at llms.txt for a map of the current API docs.
🛣️ What we're building towards
🔌 Deeper FHIR connectivity — more authentication patterns, write workflows, and real-world examples from pilot deployments
🧪 Broader validation — cover more resource types and value-set bindings, with clearer correction reports and optional server-backed profile validation
🧭 Terminology integrations — connect the
TerminologyLookupinterface to FHIR terminology servers and licensed vocabularies🔎 Traceable data movement — carry provenance, validation results, and source errors through transformations and downstream delivery
🧱 Reusable data workflows — strengthen the patterns for moving research extracts, claims, and application data behind consistent FHIR interfaces
🤝 Contributing
Building research software or working with healthcare data? Contribute a cookbook — bring your use case, and I'll personally support you through it
Read CONTRIBUTING.md for guidelines
Technical questions and ideas → GitHub Discussions
Pilots and partnerships → email
🤗 Acknowledgements
This project builds on fhir.resources and CDS Hooks standards developed by HL7 and Boston Children's Hospital.
© 2024–2026 dotimplement ai. HealthChain is an open source project maintained by dotimplement ai.
Available Tools
8 toolsbuild_resourceA
Build a FHIR resource from flat fields and validate it. Call this instead of writing FHIR JSON by hand — it does the nesting (CodeableConcepts, Dosage) and returns {ok, resource} or {ok: false, issues} to correct. Supported resource_type values: Condition, MedicationStatement, Observation, AllergyIntolerance, Patient. Use a code returned by lookup_code, never an invented one.
Inputs: resource_type (required), code, unit, onset, +12 more.
get_coded_entriesA
Read the coded identity of every resource of a type in the loaded bundle as flat records (code/display/system/status/authored_on/value/unit). Call this first for questions about conditions, medications, allergies, or observations — it resolves medicationReference to the actual Medication for you. Optionally filter by status (e.g. 'active').
Inputs: resource_type (required), status.
get_resourcesA
Get all resources of a type from the loaded bundle as full FHIR JSON. Call this when you need fields the flattened get_coded_entries view doesn't carry.
Inputs: resource_type (required).
list_codesA
List every code in the local terminology catalog, optionally filtered to one code system URI. Call this to browse what codes are available (e.g. to build a mention list); use lookup_code to search by name.
Inputs: system.
load_bundleA
Load a FHIR Bundle from a file path or JSON string and make it the working bundle for the read tools. Call this first when given bundle data. Invalid bundles return issues[] locating each problem (e.g. Bundle.entry[2].resource.subject).
Inputs: source (required).
lookup_codeA
Search the terminology catalog for codes matching free text (e.g. 'metoprolol 25', 'type 2 diabetes'). Call this whenever you need a code — use a returned candidate, never invent or recall one. Results are ranked tightest-match-first; optionally restrict to one code system URI.
Inputs: query (required), system.
resolve_referenceA
Resolve a FHIR reference (e.g. 'Patient/123', 'urn:uuid:...') to its target resource within the loaded bundle. For a contained reference ('#med1'), also pass parent_resource_id — the id of the resource the reference appears in.
Inputs: reference (required), parent_resource_id.
validate_resourceA
Validate a FHIR resource (JSON object) against the spec, including required value-set bindings. Call this after constructing or editing FHIR JSON yourself; read issues[] (severity/diagnostics/expression) and correct the resource. Never raises.
Inputs: resource (required), resource_type.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clear, distinct purpose: building, validating, loading, retrieving, resolving references, and terminology lookup. No two tools overlap in functionality.
All tool names follow a consistent verb_noun pattern using lowercase and underscores, e.g., build_resource, load_bundle, get_resources, lookup_code. This makes the API predictable.
With 8 tools, the set is well-scoped for a FHIR utility server, covering essential operations without being bloated or too sparse.
The set covers building, validating, loading, and reading FHIR resources, as well as reference resolution and terminology lookup. Minor gaps like missing update/delete tools or limited build resource types prevent a perfect score.
Maintenance
Related MCP Connectors
Privacy-preserving synthetic health data generation. FHIR R4/R5 compliant.
HL7 FHIR R4 health-data API for AI agents: free sandbox, 30 synthetic patients, AI-ready context.
Securely access and manage FHIR healthcare data stored in Medplum.
Guardrailed FHIR access for AI agents: PHI redaction, audit trail, step-up auth, tenant isolation
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables LLM-based agents to interact with FHIR healthcare data through natural language prompts, providing full CRUD operations on FHIR resources, document processing, and semantic search capabilities.13102MIT
- AlicenseNot gradedqualityBmaintenanceEnables LLMs to securely interact with FHIR healthcare servers and HL7 terminology services. Provides comprehensive healthcare data operations with built-in PHI protection, audit logging, and SMART on FHIR authentication.MIT
- AlicenseAqualityBmaintenanceProvides seamless integration with FHIR APIs, enabling AI/LLM tools to search, retrieve, and analyze clinical healthcare data with support for SMART-on-FHIR authentication and multiple transport protocols.71,026 PyPI137Apache 2.0
- FlicenseNot gradedqualityAmaintenanceEnables LLM-based agents and MCP-compatible clients to query and manipulate FHIR resources through full CRUD tools, with document ingestion, semantic search, LOINC terminology lookup, and OAuth2-authenticated FHIR API integration.-