Five MCP Tools That See a Pregnancy as One Clinical Unit
US maternal mortality keeps rising, and over 80% of pregnancy-related deaths are preventable. The predictive signals live across completely different parts of the chart. I built an MCP server that aggregates them — and a Triage agent that delegates to it.
US maternal mortality keeps rising. Over 80% of pregnancy-related deaths are preventable per the CDC, but the signals that predict them — rising BP, falling platelets, elevated AST, worsening proteinuria, transportation barriers, food insecurity — live across completely different parts of the chart. No single clinician sees them aggregated in one view, and rule-based EHR alerts don't fire on constellations of data.
The pediatric downstream gets ignored too. Every preeclampsia-driven NICU admission, every macrosomic baby born to a GDM mother, is a $25K+ cost that prenatal care isn't currently pricing in. I wanted to test whether giving an LLM the right structured slice of FHIR could let it do the mother-baby pattern-matching a busy OB can't always do in the 15 minutes before a prenatal visit.

Five tools, one server, FHIR R4
MaternalGuard is a Model Context Protocol server with 5 tools that read a pregnant patient's FHIR R4 data and return decision-ready context to the Prompt Opinion platform's AI:
- AssessMaternalRisk — demographics, conditions, recent vitals, labs, meds, with high-risk ICD-10 flags and ACOG Practice Bulletin references.
- InterpretLabTrends — longitudinal lab and vital readings grouped by LOINC code with pregnancy-specific reference ranges.
- ScreenSocialDeterminants — insurance, language, address, social history observations, flagged barriers.
- GenerateCarePlan — conditions, allergies, meds, existing care plans plus ACOG-aligned screening recommendations.
- PredictNeonatalImpact — maps maternal data to projected neonatal outcomes with a gestational-age-stratified neonatal readiness checklist.

Two-level agent composition
Two composed agents demonstrate the 'Agents Assemble' thesis. Prenatal Visit Prep orchestrates all 5 MaternalGuard tools and retrieves from a grounded clinical-guidelines Collection (NICE NG133, USPSTF, CDC, IADPSG, WHO) into a single 6-section consolidated pre-visit brief. Every claim is cited with values, dates, LOINC codes, and ACOG Practice Bulletin numbers; grounded claims quote directly from the Collection PDFs.
On-Call OB Triage is a Prompt Opinion Orchestrator Agent with no MCP tools of its own. It A2A-delegates to Prenatal Visit Prep for acute symptom triage and converts the returned brief into a triage disposition (REASSURANCE, OFFICE VISIT, L&D EVALUATION, or EMERGENCY) plus a language-appropriate patient-facing summary. Two-level agent composition entirely over open standards — MCP, A2A, SHARP, FHIR R4, US Core.
What broke and why it matters
Three failure modes stand out, because each one is a lesson about LLM-in-the-loop healthcare:
- Zod null handling. The platform's LLM passes "patientId": null explicitly in tool arguments rather than omitting the field, which caused zod validation errors on z.string().optional(). Fixed by adding .nullable() to every optional parameter across all 5 tools.
- Gestational age passing. The LLM was passing null for gestationalAgeWeeks to GenerateCarePlan, which collapsed the ACOG screening recommendations. Fixed with a system-prompt rule telling it to compute the value from the Z34.XX condition code or onsetDateTime.
- Vector retrieval wiring. After attaching the Collection, retrieval would not fire. Input tokens stayed tiny and the LLM hallucinated quoted passages. Root cause was a "Disable Embedded Tools" toggle that blocked the platform's SearchSources retrieval tool. Re-enabling it plus explicit prompt rules forbidding misuse restored retrieval.
Safety has to be structural
I tried prompting the LLM to 'be safe' and it worked inconsistently. Requiring citations per claim, ending every brief with 'Clinician review required before any action', and adding a platform-level guardrail that validates every response before it reaches the user — that moves safety from a vibe into architecture.
What the agent gets right
End-to-end multi-signal pattern recognition. The agent correctly identifies the HELLP progression pattern on the synthetic Maria Santos chart from the combination of rising BP, rising AST, falling platelets, rising proteinuria, and elevated uric acid. A constellation no single-metric rule engine would fire on.
Allergy-aware recommendations. GBS prophylaxis guidance at 36 weeks automatically flags the patient's penicillin allergy and recommends alternatives (cefazolin for low-severity, clindamycin or vancomycin for anaphylactic) per ACOG PB #797. Language-agnostic patient communication — the on-call triage disposition produces a one-sentence patient-facing summary in the patient's preferred language with proper clinical terminology (e.g., Spanish 'sala de labor y parto' for L&D, never the false-friend 'laboratorio').
What's next
Postpartum continuity — extending the tool set to cover the 12-week postpartum window, where over a third of pregnancy-related deaths occur. Real FHIR integration against live Epic and Cerner sandboxes. A companion NeonatalPrep agent that subscribes to PredictNeonatalImpact output and coordinates with NICU, L&D, and anesthesia agents via A2A. Unit economics suggest break-even versus one avoided NICU admission ($25K+) at roughly 300K briefs.