Inspiration

125,000 people die every year from preventable medication errors. 45% of adults have at least one missed preventive care gap. 80% of serious medical errors happen during patient handoffs. These aren't data problems — the data is in the EHR. They're a last-mile problem: raw data that never becomes action. ClinicalMind solves the last mile.

What it does

ClinicalMind is an MCP server exposing 4 specialized clinical AI tools on the Prompt Opinion platform:

1. check_medication_conflicts — Detects drug-drug interactions from a patient's active medication list. Fetches MedicationRequest resources from FHIR automatically via SHARP context. Returns flagged pairs with severity (HIGH/MEDIUM) and plain-language clinical explanation.

2. analyze_care_gaps — Reads patient age, gender, and active FHIR Conditions to surface missing preventive care against USPSTF, ADA, JNC8, and CDC ACIP guidelines. Returns prioritized gaps with guideline citations.

3. generate_clinical_summary — Synthesizes a structured SBAR handoff note by pulling Patient demographics, Conditions, MedicationRequests, and vitals from FHIR. Flags polypharmacy and missing vitals.

4. interpret_lab_trends — Fetches Observation resources over a configurable lookback window, flags abnormal values against evidence-based reference ranges, and detects worsening trends (e.g. rising creatinine = early CKD signal).

How we built it

  • Python 3.11 + FastMCP for the MCP server
  • FHIR R4 via HAPI FHIR public test server for synthetic patient data
  • Prompt Opinion SHARP extension — FHIR context (patient ID, server URL, auth token) propagates automatically through the platform's multi-agent call chain
  • Embedded clinical knowledge base — DDI interaction database, USPSTF/ADA/JNC8/ ACIP guidelines, and lab reference ranges from public clinical sources
  • Deployed on Railway — public HTTPS endpoint, Dockerfile-based CI via GitHub Actions

The key technical challenge was implementing the SHARP FHIR context extension correctly. The server declares ai.promptopinion/fhir-context support in capabilities.extensions during the MCP initialize handshake. From that point, every tool call automatically receives X-FHIR-Server-URL, X-FHIR-Access-Token, and X-Patient-ID headers — no manual input required from the clinician.

Challenges we ran into

  • Getting the FHIR context extension into the correct capabilities.extensions field (not capabilities.experimental) required patching FastMCP's create_initialization_options at import time using the official experimental_capabilities API plus model_extra injection
  • Railway deployment required binding to 0.0.0.0:$PORT dynamically — not hardcoded
  • Ensuring zero PHI throughout: all testing uses fully synthetic FHIR data

Accomplishments that we're proud of

  • All 4 tools working live end-to-end in the Prompt Opinion platform in a single session
  • Clinical accuracy: DDI database and care gap rules grounded in real guidelines — not toy examples
  • FHIR Context Ext Enabled: Yes — full SHARP context propagation working
  • The SBAR summary tool automatically synthesized results from the medication conflict and care gap tools in the same conversation — emergent multi-tool reasoning

What we learned

  • The MCP protocol's capabilities.extensions field is distinct from experimental — platform-specific extensions must go in the right place
  • FastMCP's ServerCapabilities uses Pydantic extra='allow' which enables clean extension injection via model_extra
  • Healthcare AI's real value is not in individual predictions but in connecting data streams — a patient's rising creatinine + their Metformin prescription is more actionable than either fact alone

What's next for ClinicalMind MCP

  1. Expand DDI database to full FDA FAERS dataset (~1,200 interactions)
  2. Add a triage_risk_score tool combining labs, vitals, and conditions into a 0–100 deterioration score (inspired by NEWS2/MEWS)
  3. Arabic clinical summaries for MENA healthcare markets (Egypt MOH, KSA)
  4. Epic/Cerner SMART on FHIR OAuth2 for enterprise deployment

Built With

  • fastmcp
  • fhir-r4
  • github-actions
  • hapi-fhir
  • httpx
  • prompt-opinion
  • pydantic
  • python
  • railway
Share this project:

Updates