home / mcp / fhir mcp server

FHIR MCP Server

Provides a universal MCP interface to multiple FHIR backends with AI-powered clinical insights.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "kushagra-dutta-fhir-mcp": {
      "url": "http://localhost:9090",
      "headers": {
        "OPENAI_API_KEY": "your-key-here"
      }
    }
  }
}

You can run and connect to a universal FHIR MCP server that centralizes access to multiple FHIR sources, performs AI-powered clinical insights, and exposes robust data retrieval capabilities. This server enables you to switch between FHIR endpoints, run patient searches, retrieve complete patient data, and leverage AI features for clinical analysis, all through a single MCP interface.

How to use

Set up your MCP client to connect to the FHIR MCP server and start performing common healthcare data tasks. You will switch between configured FHIR servers, search for patients, retrieve comprehensive patient information, and invoke AI-powered analyses such as keyword extraction, code mapping, and similar-patient matching. Use the MCP client to trigger actions and receive structured results that combine data from multiple FHIR sources with AI-derived insights.

How to install

Prerequisites: You need Python 3.11 or higher and access to FHIR servers. You will also need an OpenAI API key to enable AI features.

1. Clone the MCP project and navigate into the directory.

2. Install dependencies.

3. Configure environment variables for AI access.

4. Start the MCP server to begin serving requests.

Configuration and usage notes

The MCP server is configured to expose a single local MCP command that starts the server process. Use this entry to run the server locally and make it available to clients.

{
  "mcpServers": {
    "fhir_server": {
      "command": "python",
      "args": ["fhir_server.py"],
      "env": {
        "OPENAI_API_KEY": "your-key-here"
      }
    }
  }
}

Security and environment

Protect your OpenAI API key and other sensitive data. Use secure storage for environment variables and follow your organization’s security practices for credentials, access control, and auditing.

Tools and endpoints to know

This MCP server provides a suite of tools to manage and query FHIR data and apply AI-powered analysis. You can switch between servers, search for patients, retrieve and aggregate patient data, extract clinical keywords from notes, map terms to FHIR codes, and find similar patients.

Troubleshooting tips

If you encounter connectivity issues to a FHIR server, run diagnostics to verify server health, review logs for errors, and confirm that environment variables are set correctly. Use the MCP client to test server connectivity and to diagnose capabilities.

Notes

This MCP setup supports AI-assisted clinical workflows by combining data from multiple FHIR servers with AI-derived insights, enabling more informed patient care while maintaining secure access and auditability.

Available tools

switch_server

Switch between configured FHIR servers by selecting a target server name.

test_server_connectivity

Test connectivity to a specified FHIR server and report health status.

find_patient

Search for patients using criteria such as family name, given name, and birthdate.

get_comprehensive_patient_info

Retrieve complete patient information including demographics, conditions, medications, encounters, and more.

get_patient_conditions

Fetch the condition data associated with a patient.

get_patient_medications

Fetch the medication data associated with a patient.

get_vital_signs

Retrieve vital signs and time-series observations for a patient.

get_lab_results

Fetch laboratory results for a patient.

get_patient_encounters

Retrieve patient encounters and related context.

get_patient_allergies

Retrieve allergy information for a patient.

get_patient_procedures

Fetch procedures performed for a patient.

extract_clinical_keywords

Extract clinical keywords and concepts from free text using AI.

map_to_fhir_codes_fast

Map clinical terms to standardized FHIR codes.

find_similar_patients_simple

Find patients with similar clinical profiles based on criteria.

extract_condition_codes_from_fhir

Extract all condition codes from FHIR data.

list_available_servers

List all configured FHIR servers available to the MCP.

get_server_registry

Provide a registry of all known FHIR servers and their configurations.

diagnose_fhir_server

Diagnose capabilities and health of a specified FHIR server.

clear_condition_cache

Clear the cache that stores condition codes for quick access.

get_condition_cache_stats

Report statistics for the condition code cache.