home / mcp / fhir mcp server

FHIR MCP Server

A Model Context Protocol implementation for FHIR

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "flexpa-mcp-fhir": {
      "command": "/path/to/@flexpa/mcp-fhir/build/index.js",
      "args": [],
      "env": {
        "FHIR_BASE_URL": "<FHIR_BASE_URL>",
        "FHIR_ACCESS_TOKEN": "<FHIR_ACCESS_TOKEN>"
      }
    }
  }
}

You can run this TypeScript MCP server to interact with a FHIR server, exposing FHIR resources through MCP concepts and enabling search capabilities. It acts as a bridge that lets MCP clients access FHIR data and context for conversations and tooling.

How to use

You will run the MCP server as a local process and connect your MCP client to it. The server exposes MCP Resources that map to FHIR resources, available via fhir:// URIs. You can query for lists of resources, read individual resources, and perform searches against the FHIR server through MCP endpoints. Use the client to request resources by type, iterate through results, and fetch specific resources as JSON to feed into downstream tasks or LLM prompts.

How to install

Prerequisites you need on your machine before you start: a recent version of Node.js and npm, and access to a FHIR server with proper credentials. You will install dependencies, build the server, and run it in development mode if you want auto-rebuilds.

# 1) Install dependencies
npm install

# 2) Build the MCP server
npm run build

# 3) (Optional) Run in watch mode for auto-rebuilds during development
npm run watch

Additional content

Configuration is required to point the MCP server at your FHIR backend and to provide authentication. The following environment variables are used to configure access to the FHIR server.

{
  "mcpServers": {
    "fhir": {
      "command": "/path/to/@flexpa/mcp-fhir/build/index.js",
      "args": []
    }
  },
  "env": {
    "FHIR_BASE_URL": "<FHIR_BASE_URL>",
    "FHIR_ACCESS_TOKEN": "<FHIR_ACCESS_TOKEN>"
  }
}

Notes on debugging and maintenance

MCP servers communicate over stdio, which can complicate debugging. You can use a debugging tool that provides a browser-accessible interface for live inspection and troubleshooting.

Available tools

search_fhir

Search FHIR resources by resourceType and searchParams, returning FHIR search results in JSON.

read_fhir

Read an individual FHIR resource by its URI, returning the resource in JSON format.