Inspiration

Medication errors remain one of the most significant sources of preventable harm in modern healthcare. While large language models are powerful reasoning tools, they lack real-time clinical context—making them inherently unsafe for critical decision-making.

An AI can recommend a drug, but it has no awareness of whether the patient has Stage 4 Chronic Kidney Disease (CKD), a life-threatening allergy, or conflicting medications. This gap between intelligence and context is where real risk lies.

MedSentinel was built to eliminate that gap—acting as a real-time clinical safety layer that connects Prompt Opinion's advanced AI agents directly to live Electronic Health Record (EHR) systems, ensuring every recommendation is grounded in patient-specific data.


What it does

MedSentinel is a FHIR-native clinical decision support system powered by a Model Context Protocol (MCP) server. It acts as a secure, real-time bridge between an AI agent (running natively on the Prompt Opinion platform) and hospital EHR databases.

Instead of relying on static knowledge, the AI dynamically queries live patient data using 7 specialized clinical tools:

  1. get_patient_info
  2. get_patient_conditions
  3. get_patient_medications
  4. analyze_drug_interactions
  5. check_dose_appropriateness
  6. get_allergy_conflicts
  7. generate_safety_brief — a master synthesis tool powered by Gemini 2.5 Flash Lite

With a simple command like:
"Run a medication safety check on this patient"

The system autonomously:

  • Retrieves the patient’s live clinical data
  • Cross-references medications with kidney function (eGFR), conditions, and allergies
  • Detects contraindications and dosing risks
  • Generates a concise, clinically actionable safety report

Because MedSentinel is built on the global HL7 FHIR standard, it integrates seamlessly with modern hospital systems—without requiring custom backend changes.


How we built it

We engineered MedSentinel as a scalable, production-ready MCP server using:

  • TypeScript + Node.js for a robust backend foundation
  • Express with Server-Sent Events (SSE) for real-time MCP communication
  • The official @modelcontextprotocol/sdk to implement protocol-compliant tool orchestration

For healthcare interoperability:

  • Integrated HL7 FHIR R4 to interact with EHR data
  • Used the HAPI FHIR Sandbox to simulate real-world clinical workflows
  • Applied Zod for strict runtime validation and schema safety

For AI-powered reasoning:

  • Leveraged Google Gemini 2.5 Flash Lite to generate structured, clinician-ready safety narratives

Deployment & scalability:

  • Hosted on Google Cloud Run, enabling a persistent, auto-scalable webhook endpoint
  • Designed to be fully plug-and-play with the Prompt Opinion agent ecosystem

Challenges we ran into

  • FHIR Data Complexity: Extracting precise clinical signals (like the latest eGFR) from deeply nested and noisy healthcare datasets
  • Context Integrity: Preventing hallucinations by maintaining strict patient identity and context across multiple tool calls
  • Multi-source Orchestration: Efficiently aggregating data from medications, labs, conditions, and allergies into a coherent AI-ready context
  • Latency vs Accuracy Trade-offs: Balancing real-time responsiveness with comprehensive clinical validation

Accomplishments that we're proud of

  • Built a fully functional, FHIR-native MCP server aligned with modern interoperability standards
  • Successfully demonstrated a real-world clinical safety scenario, where the system identified and prevented a medication error in a Stage 4 CKD patient using live lab data
  • Created a zero-hallucination workflow, where every AI response is grounded in verifiable patient data
  • Successfully integrated our complex medical architecture directly into the Prompt Opinion Agent Ecosystem, proving that Prompt Opinion is the perfect platform for building enterprise-grade, high-stakes AI applications.

What we learned

  • How the Model Context Protocol (MCP) enables a standardized, model-agnostic way to connect AI with real-world data sources
  • The importance of grounded AI in high-stakes domains like healthcare
  • Techniques to guide AI systems to behave like a clinical decision support tool, not just a conversational model
  • The immense value of the Prompt Opinion platform for rapidly prototyping and deploying secure AI agents

What's next for MedSentinel

We are expanding MedSentinel into a full clinical intelligence platform by:

  • Enhancing the drug interaction and safety rule engine
  • Adding write-back capabilities (e.g., drafting clinical notes, suggesting prescription changes)
  • Supporting advanced multi-agent clinical workflows exclusively within Prompt Opinion, leveraging their orchestration capabilities to simulate an entire medical board
  • Integrating with real hospital EHR systems for pilot deployments
  • Exploring predictive analytics for proactive risk detection

Built With

Share this project:

Updates