This MCP server implementation connects to FHIR servers, providing a bridge between LLMs and healthcare data. It enables access to FHIR resources through a standardized interface, allowing AI assistants to search and retrieve healthcare information in a structured way.
Before installing the MCP FHIR server, ensure you have:
npm install @flexpa/mcp-fhir
FHIR_BASE_URL="https://your-fhir-server.com"
FHIR_ACCESS_TOKEN="your-access-token"
To use the MCP FHIR server with Claude Desktop:
MacOS:
nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows:
notepad %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"fhir": {
"command": "/path/to/@flexpa/mcp-fhir/build/index.js"
},
"env": {
"FHIR_BASE_URL": "<FHIR_BASE_URL>",
"FHIR_ACCESS_TOKEN": "<FHIR_ACCESS_TOKEN>"
}
}
}
The server provides access to FHIR resources through URI-based identifiers. Resources are addressed using the fhir://
protocol.
To retrieve a specific FHIR resource, use the read_fhir
tool with a URI in the format:
fhir://{resourceType}/{id}
For example:
fhir://Patient/123
fhir://Observation/456
fhir://MedicationRequest/789
The server supports searching FHIR resources using the standard FHIR search parameters. Use the search_fhir
tool with:
resourceType
: The type of FHIR resource to search forsearchParams
: A map of search parameters corresponding to FHIR search parametersExample search parameters:
{ "name": "Smith" }
{ "patient": "Patient/123", "code": "8480-6" }
{ "patient": "Patient/123", "date": "ge2023-01-01" }
Searches for FHIR resources based on resource type and search parameters.
Parameters:
resourceType
: The FHIR resource type to searchsearchParams
: Object containing search parametersReturns FHIR search results in JSON format.
Retrieves a specific FHIR resource by URI.
Parameters:
uri
: The FHIR resource URI (e.g., fhir://Patient/123
)Returns the complete FHIR resource in JSON format.
The MCP Inspector can help debug communication between Claude and the MCP server:
npm run inspector
This will provide a URL to access debugging tools in your browser, allowing you to monitor the requests and responses between Claude and the MCP FHIR server.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "fhir" '{"command":"/path/to/@flexpa/mcp-fhir/build/index.js","env":{"FHIR_BASE_URL":"<FHIR_BASE_URL>","FHIR_ACCESS_TOKEN":"<FHIR_ACCESS_TOKEN>"}}'
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": {
"command": "/path/to/@flexpa/mcp-fhir/build/index.js",
"env": {
"FHIR_BASE_URL": "<FHIR_BASE_URL>",
"FHIR_ACCESS_TOKEN": "<FHIR_ACCESS_TOKEN>"
}
}
}
}
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": {
"command": "/path/to/@flexpa/mcp-fhir/build/index.js",
"env": {
"FHIR_BASE_URL": "<FHIR_BASE_URL>",
"FHIR_ACCESS_TOKEN": "<FHIR_ACCESS_TOKEN>"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect