HealthRecordCommunity
FHIR🌏 InternationalEnriched

AI Access Gateway to EHR Data using FHIR and MCP

EHR Tools with MCP and FHIR - LobeHub

June 25, 2025

Summary

This system securely fetches patient data from Electronic Health Records (EHRs) using the SMART on FHIR standard, then exposes it through a set of tools via the Model Context Protocol (MCP). This enables Large Language Models (LLMs) and AI agents to safely perform searches and analyses based on diverse EHR data.

Details

This project functions as a specialized server enabling secure interaction between AI agents, such as Large Language Models (LLMs), and Electronic Health Records (EHRs). It leverages the SMART on FHIR standard for secure data access and the Model Context Protocol (MCP) to expose tools. The system operates in three stages: First, an SMART on FHIR Client connects securely to an EHR, extracting both structured data (e.g., conditions, medications, labs) and unstructured clinical notes. Second, the MCP Server takes this extracted data and makes it available through powerful tools accessible via the Model Context Protocol. Third, an external AI agent uses these provided tools to query or analyze the patient's record. The core tools include: 'grep_record' (text/regex search across all fetched parts), 'query_record' (read-only SQL SELECT queries against structured FHIR data), and 'eval_record' (custom JavaScript execution on fetched data). This setup standardizes and secures the use of comprehensive EHR data for AI. Additionally, a standalone SMART on FHIR Web Client is provided, allowing users to connect directly to their EHR. This client gathers all data into a JSON object containing both structured FHIR resources and extracted plaintext from attachments, ensuring a standardized data input process for the subsequent MCP server stage.

📰
Read Original Article
lobehub.com

Original content copyright by respective publishers