The FHIR MCP Server implements the Model Context Protocol to connect LLM-based agents with FHIR-compliant healthcare backends. It enables natural language interactions with clinical data through Claude Desktop and other MCP-compatible clients, providing a comprehensive suite of tools for FHIR resource management.
Clone the repository:
git clone https://github.com/the-momentum/fhir-mcp-server
cd fhir-mcp-server
Set up environment variables:
cp config/.env.example config/.env
Install Dependencies:
For Docker-based execution:
make build
For uv-based execution:
make uv
Update MCP Client configuration:
For Docker setup (in Claude Desktop's claude_desktop_config.json
):
{
"mcpServers": {
"docker-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--init",
"--name",
"fhir-mcp-server",
"--mount",
"type=bind,source=<your-project-path>/app,target=/root_project/app",
"--mount",
"type=bind,source=<your-project-path>/config/.env,target=/root_project/config/.env",
"-e", "TRANSPORT_MODE=stdio",
"mcp-server:latest"
]
}
}
}
For uv setup, first get uv path from terminal, then update config:
{
"mcpServers": {
"uv-mcp-server": {
"command": "uv",
"args": [
"run",
"--frozen",
"--directory",
"<your-project-path>",
"start"
],
"env": {
"PATH": "<uv-bin-folder-path>"
}
}
}
}
Restart MCP Client to apply changes
The server includes built-in encryption for sensitive configuration values. You can set up encryption using the automated script:
# uv method
uv run scripts/cryptography/setup_encryption.py
# docker method
docker exec fhir-mcp-server uv run scripts/cryptography/setup_encryption.py
Variable | Description | Example Value |
---|---|---|
MASTER_KEY | Master encryption key | gAAAAABl... |
FHIR_SERVER_HOST | FHIR API host URL | https://api.medplum.com |
FHIR_BASE_URL | FHIR base path | /fhir/R4 |
FHIR_SERVER_CLIENT_ID | OAuth2 client ID | 019720e7... |
FHIR_SERVER_CLIENT_SECRET | OAuth2 client secret | gAAAAABl... |
LOINC_USERNAME | LOINC account username | loinc-user |
LOINC_PASSWORD | LOINC account password | gAAAAABl... |
PINECONE_API_KEY | Pinecone API key | gAAAAABl... |
EMBEDDING_MODEL | HuggingFace embedding model | NeuML/pubmedbert-base-embeddings |
Tool | Resource Type | Description |
---|---|---|
request_patient_resource |
Patient | Manage patient demographics |
request_observation_resource |
Observation | Handle clinical measurements |
request_condition_resource |
Condition | Manage diagnoses |
request_medication_resource |
Medication | Handle medication information |
request_immunization_resource |
Immunization | Manage vaccination records |
request_encounter_resource |
Encounter | Handle patient visits |
request_allergy_intolerance_resource |
AllergyIntolerance | Manage allergies |
request_family_member_history_resource |
FamilyMemberHistory | Handle family health history |
request_generic_resource |
Any FHIR Resource | Operate on any other FHIR resource |
Tool | Description |
---|---|
request_document_reference_resource |
Manage FHIR DocumentReference resources |
add_document_to_pinecone |
Ingest documents into vector database |
search_pinecone |
Perform semantic search across indexed documents |
Tool | Description |
---|---|
get_loinc_codes |
Retrieve standardized LOINC codes |
All tools support full CRUD operations with proper error handling and data validation.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "fhir-mcp-server" '{"command":"docker","args":["run","-i","--rm","--init","--mount","type=bind,source=${projectPath}/app,target=/root_project/app","--mount","type=bind,source=${projectPath}/config/.env,target=/root_project/config/.env","mcp-server:latest"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"fhir-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--init",
"--mount",
"type=bind,source=${projectPath}/app,target=/root_project/app",
"--mount",
"type=bind,source=${projectPath}/config/.env,target=/root_project/config/.env",
"mcp-server:latest"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"fhir-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"--init",
"--mount",
"type=bind,source=${projectPath}/app,target=/root_project/app",
"--mount",
"type=bind,source=${projectPath}/config/.env,target=/root_project/config/.env",
"mcp-server:latest"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect