An AI-powered Model Context Protocol (MCP) server that bridges AI agents with hospital FHIR R4 data — fetching, normalising, and reasoning over patient records using Hugging Face.


💡 Inspiration

Working with healthcare data is notoriously difficult. Electronic Health Records (EHRs) are siloed, deeply nested, and overwhelmingly dense for both clinicians and developers. We wanted to bridge the gap between standardized healthcare data (FHIR) and cutting-edge large language models to create a system that doesn't just display data, but actually understands it. The inspiration for FHIRBridge MCP was to leverage the new Model Context Protocol (MCP) to give AI agents direct, secure, and semantic access to clinical data, empowering them to act as true medical co-pilots capable of reasoning over patient histories.

🚀 What it does

FHIRBridge MCP connects real-time EHR data with Hugging Face's advanced reasoning capabilities. It provides a suite of 14 specialized MCP tools (8 FHIR-native, 6 AI-powered) that can be seamlessly invoked via a clinical dashboard.

Key features include:

  • AI Chart Summaries: Transforms complex, fragmented patient histories into concise, actionable clinical briefings in seconds.
  • ER Triage Flags: Rapidly assesses raw patient data to highlight critical alerts and triage urgency.
  • Medication Safety Analysis: Automatically reviews active medication lists to detect adverse drug interactions and safety concerns.
  • Anomaly Detection: Analyzes lab results and vitals to identify concerning clinical trends.
  • Preventive Care Gaps: Highlights missing preventive care steps based on patient demographics, conditions, and history.

🛠️ How we built it

  • Backend & Interoperability: We built the core server using Python, interfacing directly with the public HAPI FHIR R4 sandbox. We implemented the Model Context Protocol (MCP) to expose specific tools to the AI, allowing it to seamlessly query endpoints like get_patient, get_observations, get_conditions, and get_allergies.
  • AI Engine: We integrated Hugging Face (defaulting to the highly capable HuggingFaceH4/zephyr-7b-beta model) to process the raw, structured FHIR JSON responses. By acting as the reasoning engine, Hugging Face applies clinical logic to generate summaries, flag anomalies, and assess triage states.
  • Frontend Dashboard: The user interface is a "Clinical Dashboard" built with React and Vite. We designed a clean, professional aesthetic using custom CSS. It features real-time KPI cards, quick actions, and a "Tool Runner" interface that elegantly displays both the raw FHIR data responses and the AI-generated insights.

⚠️ Challenges we faced

  • Navigating FHIR Complexity: FHIR R4 resources are incredibly comprehensive but deeply nested. Extracting the relevant clinical signals without overwhelming the LLM's context window required careful data parsing, filtering, and shaping.
  • Latency & Orchestration: Orchestrating sequential API calls (e.g., fetching a patient, then their labs, then their conditions) followed by complex LLM inference can result in high latency. We had to optimize our MCP tool calls and structure our prompts to ensure rapid, reliable responses suitable for a fast-paced clinical environment.
  • Designing for Healthcare: Building a UI that felt intuitive, trustworthy, and authoritative enough for a healthcare setting took iteration. We transitioned from a basic developer tool prototype to a polished, card-based executive dashboard with clear information architecture.

🧠 What we learned

  • The immense potential of the Model Context Protocol (MCP) in standardizing how AI agents interact with external APIs, drastically simplifying tool-use architecture.
  • Deep practical insights into the HL7 FHIR R4 standard and the mechanics of modern healthcare interoperability.
  • How to engineer highly effective prompts to ensure Hugging Face accurately analyzes complex medical data without hallucination, maintaining clinical safety.

🔮 What's next

  • SMART on FHIR Integration: Implementing full OAuth2 flows for secure, authenticated access to real hospital EHR systems (like Epic or Cerner).
  • Multi-modal Analysis: Expanding the system to analyze medical imaging (DICOM) alongside textual FHIR data.
  • Predictive Analytics: Utilizing historical FHIR encounters and observation data to predict patient readmission risks and long-term health outcomes.

Built With

Share this project:

Updates