SuperAPIAI Directory

fhir-mcp-server

github.com · AI developer platforms

Connect to FHIR servers, for example to query patient history in natural language.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

FHIR MCP Server is a server that implements the full Model Context Protocol (MCP), designed to facilitate seamless interaction between LLM-based agents and FHIR-compliant backends. It provides a standardized interface that supports full CRUD operations on FHIR resources through a comprehensive set of tools, accessible from MCP-compatible clients such as Claude Desktop, allowing users to query and manipulate clinical data using natural language prompts.

Key capabilities:

  • Built on the FastMCP framework, providing high-performance MCP server capabilities.
  • Provides full CRUD operations for major FHIR resources.
  • Intelligent document processing: supports AI-driven document ingestion and chunking for multiple formats such as TXT, CSV, JSON, and PDF.
  • Semantic search: advanced document search via vector embeddings (through Pinecone).
  • RAG-ready: retrieval-augmented generation pipeline with context-aware document querying.
  • Secure authentication: OAuth2 token management for FHIR API integration.
  • LOINC integration: standardized medical terminology querying and validation.
  • Container-ready: supports Docker for easy deployment and scaling.
  • Configurable: provides rich .env-based configuration options.

Architecture: The server uses a modular architecture, including:

  • MCP tools: specialized tools for selected FHIR resource types, with other resources handled by generic tools.
  • FHIR server client: handles FHIR API communication and authentication (OAuth2 and other methods planned).
  • RAG service: embedding-based document processing and semantic retrieval.
  • Vector store: Pinecone integration for similarity-based search.
  • LOINC client: integrates with the LOINC API for terminology resolution and validation.

Usage:

  1. Environment preparation: requires Docker (recommended) or uv for dependency management; a FHIR server account (such as Medplum); a Pinecone API key (required for document search); a LOINC account (optional).
  2. Installation and setup:
    • Clone the repository: git clone https://github.com/the-momentum/fhir-mcp-server && cd fhir-mcp-server
    • Set environment variables: cp config/.env.example config/.env, and edit config/.env to fill in credentials and configuration.
    • Install dependencies: for the Docker method, run make build; for the uv method, run make uv.
    • Update the MCP client configuration (such as Claude Desktop's claude_desktop_config.json).
    • Restart the MCP client to apply the changes.

Docker configuration example: { "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" ] } } }

uv configuration example: { "mcpServers": { "uv-mcp-server": { "command": "uv", "args": ["run", "--frozen", "--directory", "<your-project-path>", "start"], "env": { "PATH": "<uv-bin-folder-path>" } } } }

Security and Encryption: Built-in encryption infrastructure protects sensitive configuration values. Sensitive fields such as API keys and passwords are automatically encrypted and decrypted at runtime. You can use an automated setup script, or manually generate a master key and encrypt sensitive values. Fields that are automatically encrypted include: FHIR_SERVER_CLIENT_SECRET, LOINC_PASSWORD, PINECONE_API_KEY.

Toolset:

  • FHIR resource tools: Support create, read, update, and delete operations for all FHIR resources, and enforce FHIR resource validation to prevent data corruption, providing comprehensive error responses.
  • Document management tools: Support document ingestion in TXT, PDF, CSV, and JSON formats, as well as semantic search based on vector embeddings.
  • LOINC terminology tools: Standardized medical terminology query and validation.

Applicable scenarios:

  • Query patient history, diagnoses, medications, visits, and other information through natural language.
  • Generate and deploy test data to validate FHIR server functionality.
  • Semantic search and RAG applications for medical data documents.

Limitations:

  • The document search feature requires a Pinecone API key; otherwise, semantic retrieval is unavailable.
  • A LOINC account is optional, but when it is missing, the system relies on static or language model-inferred codes, which may be outdated or imprecise.
  • The project was not designed for test data generation scenarios; what is shown in the demo may not work perfectly, but the LLM can correct incorrect choices through trial and error.
  • Future plans include expanding authentication options, supporting more file formats, table-aware document chunking, and OCR support for scanned documents.

License: MIT License.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools