feat(mcp): add deep-value reads and a doctor-visit prompt

Expose four read-only relational tools and one prompt over the MCP wire,
each a thin re-export of an existing server-authoritative engine — no new
statistics, no new business logic:

- get_correlation: the FDR-controlled, lag-aware association between two
  named metrics, selected out of the existing correlation discovery the
  Coach and the insight route already run. Descriptive, never causal.
- compare_metric: two metrics over the same trailing window, or one metric
  across two trailing windows, computed over the WMY rollup readers with a
  delta only when both sides share a unit.
- get_metric_baseline: where today's reading sits against the user's own
  usual range (median ± robust deviation) plus the strongest lagged driver,
  reusing the metric-page baseline builder. Honest-null below the learning
  floor — never a fabricated range.
- detect_changepoints: level shifts over the rollup tier via a small in-repo
  CUSUM binary segmentation with a high firing bar.
- doctor_visit_summary prompt: a structured, grounded visit-prep summary
  assembled from the doctor-report data path so the numbers match the
  exported PDF, with the grounding framing injected once — data and context
  only, no diagnosis or verdict.

Every tool returns values, units, reference bands and provenance, declares
read-only / non-destructive / closed-world annotations plus an output schema,
and reports { present: false } for absence. All reads stay session-narrowed
and read-only; the existing security posture is unchanged.
This commit is contained in:
Marc-André Bombeck committed 2026-06-27 15:34:11 +02:00
1 parent 22eb9cba0d
commit cfffb693c3
9 files changed
+1718 -1

No files matched your search

+5
View File
@@ -76,6 +76,11 @@ const READ_TOOLS = [
"list_metrics",
"search",
"fetch",
// Phase 4 — deep-value reads.
"get_correlation",
"compare_metric",
"get_metric_baseline",
"detect_changepoints",
].sort();
/** A valid, narrow-scope (`health:read`) token resolution. */