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:
- retrieve_archetype: Gets OpenEHR archetype definitions by clinical concept or ID
- generate_aql: Creates AQL queries from natural language using archetype structure
- 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:
- Calls
retrieve_archetype(concept="blood_pressure")
→ Gets archetype structure - Calls
generate_aql(query="last 15 blood pressure readings", archetype=..., patient_id="xyz")
→ Gets AQL - 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
- Clone the repository:
- Create and activate virtual environment:
- Install dependencies:
- Configure environment:
- Verify setup:
- Start the server:
🚀 Quick Setup for New Users
If someone shares this repo with you, here's what you need to do:
- Clone the repository
- Create your own virtual environment (the
venv/
folder is not shared) - Install all dependencies from
requirements.txt
- Configure your environment with your own settings
- Run the server
Complete setup commands:
Configuration
Edit .env
file with your settings:
Usage
The MCP server exposes tools that can be used by an LLM to:
- Retrieve archetype definitions
- Generate AQL queries
- Execute queries against an EHR system
Example Flow
- User asks: "Give me last 15 readings for blood pressure for patient xyz"
- LLM calls
retrieve_archetype
tool to get blood pressure archetype structure - LLM calls
generate_aql
tool to create an appropriate AQL query - LLM calls
execute_ehr_query
tool to run the query against the EHR system - 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.
This server cannot be installed
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.