fhir-mcp-server
An MCP server over FHIR R4 that provides tools, a resource, and a prompt for interacting with patient data.
search_patients: search patients by family name, with optional limit (default 5).
get_observations: fetch clinical observations for a patient ID, with optional limit (default 10).
fhir://patient/{patient_id}: access a patient resource by ID (application-triggered).
resumen_clinico: generate a clinical summary for a patient (user-triggered slash command).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@fhir-mcp-server find patients with last name Smith and list their observations"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
fhir-mcp-server
A minimal MCP server over FHIR, built with the
official Python SDK v2 (mcp 2.1.1+).
It exposes all three MCP primitives — tool, resource and prompt — against a HAPI FHIR R4 server, and ships with an in-memory test suite.
The interesting problem with agent tooling isn't getting it to run once. It's proving it behaves. So the tests are the point of this repo as much as the server is.
Why v2 matters
Most MCP tutorials and Stack Overflow answers still show the v1 API:
from mcp.server.fastmcp import FastMCP # v1 — outdated
from mcp.server import MCPServer # v2 — currentSDK v2 was a major rework released alongside the 2026-07-28 spec revision. Two things bite if you arrive from v1:
Result models use
snake_case:tool.input_schema, nottool.inputSchema;result.resource_templates, notresult.resourceTemplates.FastMCPis gone from the official SDK. (Note:fastmcpon PyPI is a different, third-party package — don't confuse the two.)
Related MCP server: FHIR MCP Server
Requirements
Python 3.10+ and uv.
Install
uv venv .venv
source .venv/bin/activate
uv pip install "mcp[cli]" httpx
uv pip install pytest inline-snapshot # tests onlyRun
uv run mcp dev server.py # MCP Inspector — try the tools in a form
uv run mcp run server.py # stdio — for a real hostTo connect it to a host (Claude Code, Claude Desktop, an IDE):
uv run --with "mcp[cli]" mcp run /absolute/path/to/server.pyThe host launches the server as a subprocess and speaks over stdin/stdout. No port, nothing listening on the network.
Test
pytest -vtest_tools_registrados PASSED
test_prompt_registrado PASSED
test_resource_template PASSED
test_search_patients_contra_servidor_real PASSEDClient(mcp) connects to the server object in memory — no subprocess, no
port, no wire. Same idea as FastAPI's TestClient. The last test is an
integration test and hits the public sandbox, so it needs network.
What it exposes
Primitive | Name | Who triggers it |
Tool |
| the model |
Tool |
| the model |
Resource |
| the application |
Prompt |
| the user |
The three primitives differ by who decides to use them, not by what they
do. A tool is a POST (acts, has side effects), a resource is a GET (loads
data, changes nothing), a prompt is a slash command.
You don't write JSON Schema — the SDK generates it from type hints. A parameter with a default stops being required. It's just Python.
Data
Points at https://hapi.fhir.org/baseR4, the public HAPI FHIR test
sandbox.
⚠️ Never put real clinical data in a public repo. Synthetic or sandbox data, always.
License
MIT
If this saved you an afternoon, a coffee helps ☕
Available Tools
2 toolsget_observationsA
Trae las observaciones clínicas de un paciente por su ID FHIR.
Inputs: patient_id (required), limit. Returns: result
search_patientsB
Busca pacientes por apellido en el servidor FHIR.
Inputs: family_name (required), limit. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: one searches for patients by last name, the other retrieves clinical observations for a specific patient ID. There is no meaningful overlap or ambiguity between them.
Both tool names follow the same verb_noun snake_case pattern: search_patients and get_observations. The naming is consistent, predictable, and easy for an agent to navigate.
With only two tools, the server feels thin for a FHIR implementation, which typically supports a much broader range of resources and operations. However, the count is not egregiously low and could be acceptable for a narrowly scoped use case.
The server covers only patient search and observation retrieval, missing foundational FHIR operations like getting a patient by ID, creating or updating resources, and searching observations by clinical criteria. Agents would likely encounter dead ends when trying to perform common FHIR workflows.
Related MCP Connectors
Hosted MCP server for the Healthie EHR & telehealth API: patients, appointments, charting, tasks.
FHIR R4 health records for AI: people connect their own record with consent; free FHIR sandbox.
Hosted MCP server for Cliniko — patients, appointments, availability, and invoices for AI agents.
Hosted MCP server exposing US hospital procedure cost data to AI assistants
Related MCP Servers
- FlicenseNot gradedqualityAmaintenanceEnables LLM-based agents and MCP-compatible clients to perform full CRUD operations on FHIR resources and query or manipulate clinical data using natural-language prompts. It also supports document ingestion, semantic search, LOINC terminology lookup, and OAuth2 authentication for FHIR APIs.-
- FlicenseNot gradedqualityAmaintenanceEnables MCP-compatible clients and LLM agents to perform full CRUD operations on FHIR resources, query and manipulate clinical data through natural-language prompts, and use document ingestion, semantic search, and terminology lookup against a FHIR backend.-
- FlicenseNot gradedqualityAmaintenanceEnables LLM-based agents and MCP-compatible clients to interact with a FHIR-compliant backend for full CRUD operations on FHIR resources, document ingestion, semantic search, LOINC terminology lookup, and synthetic data generation through natural-language prompts.-
- FlicenseNot gradedqualityAmaintenanceEnables MCP-compatible clients and LLM-based agents to interact with FHIR-compliant healthcare backends via natural-language prompts, supporting full CRUD operations on FHIR resources, document ingestion, semantic search, and LOINC terminology lookup.-