Skip to main content
Glama

OpenEHR MCP Server

OpenEHR MCP Server

A Model Context Protocol (MCP) server that enables LLMs to interact with OpenEHR backends, including:

  • OpenEHR Clinical Knowledge Manager (CKM) for standard archetypes
  • Custom EHR APIs hosted on IIS server connected to on-premise EHR databases
  • Local archetype resources (.adl/.opt files)

Architecture Overview

The server provides three main MCP tools that work together:

  1. retrieve_archetype: Gets OpenEHR archetype definitions by clinical concept or ID
  2. generate_aql: Creates AQL queries from natural language using archetype structure
  3. execute_ehr_query: Executes AQL against your on-premise EHR database via IIS API

Example Workflow

User Query: "Give me last 15 readings for blood pressure for patient xyz"

LLM Flow:

  1. Calls retrieve_archetype(concept="blood_pressure") → Gets archetype structure
  2. Calls generate_aql(query="last 15 blood pressure readings", archetype=..., patient_id="xyz") → Gets AQL
  3. Calls execute_ehr_query(aql=..., patient_id="xyz") → Returns patient data

Quick Start

Prerequisites

  • Python 3.8+
  • Access to your IIS-hosted EHR API
  • Optional: OpenEHR CKM API access

Installation

  1. Clone the repository:
git clone <this-repo> cd openehr-mcp
  1. Create and activate virtual environment:
# Create virtual environment python -m venv venv # Activate virtual environment # Windows: .\venv\Scripts\Activate.ps1 # Linux/Mac: source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment:
# Copy example config cp .env.example .env # Edit .env with your settings notepad .env # Windows
  1. Verify setup:
python verify_setup.py
  1. Start the server:
cd src python main.py # OR for development with auto-reload: # python -m uvicorn main:app --host 0.0.0.0 --port 3000 --reload

🚀 Quick Setup for New Users

If someone shares this repo with you, here's what you need to do:

  1. Clone the repository
  2. Create your own virtual environment (the venv/ folder is not shared)
  3. Install all dependencies from requirements.txt
  4. Configure your environment with your own settings
  5. Run the server

Complete setup commands:

# Windows PowerShell git clone <repo-url> cd openehr-mcp python -m venv venv .\venv\Scripts\Activate.ps1 pip install -r requirements.txt cp .env.example .env # Edit .env with your settings cd src python main.py
# Linux/Mac git clone <repo-url> cd openehr-mcp python -m venv venv source venv/bin/activate pip install -r requirements.txt cp .env.example .env # Edit .env with your settings cd src python main.py

Configuration

Edit .env file with your settings:

# Your IIS EHR API EHR_API_BASE_URL=http://your-iis-server:8080/ehr-api EHR_API_KEY=your_api_key # OpenEHR CKM (optional) CKM_API_URL=https://ckm.openehr.org/ckm OPENEHR_CKM_API_KEY=your_ckm_key # Local archetypes ARCHETYPE_PATH=./templates

Usage

The MCP server exposes tools that can be used by an LLM to:

  1. Retrieve archetype definitions
  2. Generate AQL queries
  3. Execute queries against an EHR system

Example Flow

  1. User asks: "Give me last 15 readings for blood pressure for patient xyz"
  2. LLM calls retrieve_archetype tool to get blood pressure archetype structure
  3. LLM calls generate_aql tool to create an appropriate AQL query
  4. LLM calls execute_ehr_query tool to run the query against the EHR system
  5. Results are returned to the user

Communication Protocols

This MCP server uses Streamable HTTP as its primary communication protocol, allowing for efficient transfer of potentially large medical datasets between the LLM and the EHR systems.

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Enables LLMs to interact with OpenEHR electronic health record systems by retrieving clinical archetypes, generating AQL queries from natural language, and executing queries against on-premise EHR databases. Supports OpenEHR Clinical Knowledge Manager integration and custom IIS-hosted EHR APIs for comprehensive medical data access.

  1. Architecture Overview
    1. Example Workflow
      1. Quick Start
        1. Prerequisites
        2. Installation
      2. 🚀 Quick Setup for New Users
        1. Configuration
      3. Usage
        1. Example Flow
      4. Communication Protocols

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/ajinkyasabale-github/openehr-mcp'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server