HealthForge MCP Server
by gavdevs
README.md
# healthforge
[](LICENSE)
**Self-hosted, bot-native health tracking — the mealforge sibling.** Chef writes meals into
[mealforge](https://github.com/gavdevs/mealforge); Coach (the trainer bot) pushes nutrition and
workout plans into healthforge over MCP, reads the weekly summary on Sunday, adjusts, and pushes
again. The app records what you actually eat and do: a grams-first food diary over open food APIs
(USDA FoodData Central + Open Food Facts, every pick cached locally), the adaptive macro engine's
math, workout plans and session logs, the weight trend line, fasting and water. One SQLite file, one
container, your server — nothing leaves it.
The pairing is the identity: **Chef → mealforge, Coach → healthforge.** One agent mesh, two
purpose-built apps.
**P2 status — Coach enters.** The tracker core above is live (P1), and the coach loop now runs end
to end: the **MCP tool surface v1** answers at `/mcp` — `push_nutrition_plan`,
`get_active_nutrition_plan`, `get_nutrition_plans`, `complete_nutrition_plan`,
`get_weekly_summary`, `get_day_status` (nudge codes with severities), `get_next_best_action`,
`get_weight_trend`, `log_weight`, `search_foods`, `get_food`, `log_food`, plus `get_app_info`.
The **deterministic weekly engine** (MacroFactor's energy-balance math with Carbon-style
guardrails) lives in `packages/shared` and powers both surfaces: expenditure estimate from
`meanDailyIntake − (ΔtrendWeight × tissueEnergyDensity)/windowDays`, suggested targets with
hold-protein, and guardrails — ±300 kcal/day change cap, a hard calorie floor, an 80% logging
completeness gate (an under-logged week says _insufficient data_ instead of inventing a number),
a 1%/week rate ceiling, adherence-neutrality by construction, and time-off windows excluded from
averages. Every constant is a settings-level tunable, shipped as defaults with property tests.
The web gains the **Check-in** page (the same numbers `get_weekly_summary` returns: adherence,
trend, expenditure, suggestions, workout completion, time-off manager) and the **Plans** page
(active plan + browsable history with per-day planned-vs-actual). **P3 adds the workout half**:
`push_workout_plan` / `get_active_workout_plan` / `complete_workout_plan` over MCP, a seeded
exercise library, the **Workouts** page — this week's sessions as a guided log of set-groups
(actual reps/weight/RPE, re-logging replaces), with volume-per-muscle-group and per-exercise
Epley rep-max charts — and workout completion % in the weekly summary. **P4 adds the progress
half**: dated entries holding up to three pose-tagged photos (front/side/back) plus tape metrics —
photos stored under `./data/photos/` next to the SQLite file, EXIF stripped at ingest, thumbnails
generated on the server, served by the app's own local-only media route and **deliberately
unreachable over MCP** — with a side-by-side compare of any two dates. **P5 adds the mealforge
bridge**: chef recipes import read-only from `MEALFORGE_URL` into the **Recipes** page, the
one-time **ingredient mapping you own** (each line prefilled with the top local-food hit and a
mass-unit grams guess — suggestions to confirm or override, never an auto-matcher), an optional
cooked-pot weight that flips logging to per-cooked-gram, re-syncs that never touch logged history
(the snapshot rule), and the config-gated `import_mealforge_recipe` / `log_mealforge_recipe`
tools — unset, the bridge is hidden entirely and the surface stays the 18 base tools. **P6
completes the v1 spec**: the **fasting** card (one tap starts a protocol preset — 16:8, 18:6,
20:4, circadian, 36 h, custom — a live ticking timer, one tap ends, editable timestamps, no
streaks or zone screens), the **water** card (250/500/750 ml one-tap presets against a
settings-level daily goal, per-day history), the **micronutrient coverage** view (the diary's
day/week panel against a shipped FDA Daily Values table — label-tier foods contribute only what
their label carried, an untracked nutrient says so), the weekly summary's **water + fasting
roll-ups** on both surfaces, the chat tools `log_water` / `log_fast` with honest retry semantics
taught in the instructions block, and the **Data** page — full JSON export/import where photos
ship metadata only, never bytes. Every FR in the v1 spec is delivered; the post-v1 roadmap
(barcode camera scanning, the LP3 app, auto-pilot mode) lives in the
[master spec](docs/healthforge-spec-2026-11-29.md) §9, the source of truth for every decision;
[`openspec/`](openspec/) holds the repo-native distillation.
## How it works
```
┌──────────┐ MCP (streamable http) ┌──────────────────────────────┐
│ Coach │ ───────────────────────▶ │ HealthForge │
│ (bot) │ push_nutrition_plan │ • food diary + food search │
│ Sunday │ log_weight / log_food │ • weekly engine + plans │
│ review: │ get_weekly_summary │ • weight trend │
│ adjust, │ ◀─────────────────────── │ • progress photos (P4) │
│ push │ │ • workouts (P3) │
│ │ │ • fasting / water (P6) │
└──────────┘ └──────────────────────────────┘
▲ web UI (PWA) LP3 app (later)
│ mealforge = the recipe base, unchanged: import chef recipes, map
│ ingredients to real foods + grams once, log weighed portions.
```
## Quick start (self-hosting)
```bash
git clone <this repo> && cd healthforge # or copy the folder
docker compose up -d
```
The web app and MCP endpoint are now on port `8091` (mealforge's sibling — both can run side by
side):
- Web UI: `http://<host>:8091`
- MCP endpoint: `http://<host>:8091/mcp`
Data lives in a single SQLite file (WAL mode) under `./data/` — back that folder up and you've
backed up everything. The **Data** page (P6) also exports the whole database as one JSON you can
keep anywhere, and restores one into a fresh instance — progress photos ship as metadata only
(bare filenames; the image files live in `./data/photos/`, EXIF stripped at ingest, thumbnails
generated on the server, never exposed over MCP), so the backup story stays "copy the data dir."
> **Security note:** like mealforge, there is no built-in authentication. This is designed for a
> household on a private network — put it on your Tailscale/VPN, or behind a reverse proxy that
> does auth. Progress photos make the private-network stance more important, not less.
### Configuration
Set `APP_URL` (in a `.env` next to `docker-compose.yml`) to the URL your household reaches, e.g.
`APP_URL=https://healthforge.your-tailnet.ts.net` — MCP tools return it so the model can link you
to the app. See [`.env.example`](.env.example) for the full list: `USDA_API_KEY` (free data.gov
key, enables USDA live search; the public `DEMO_KEY` works for dev), `OFF_COUNTRY` (default
`us`), `MEALFORGE_URL` (P5 — enables the recipe bridge; unset hides it entirely, and the MCP
surface stays the 18 base tools). Without a USDA key the app is
OFF-only for live search and fully functional from its cache — a down or absent API never
blocks logging. Local search p95 measured at ~1.7 ms over a 2,000-food cache
(`scripts/bench-local-search.ts`).
### Verify your install
```bash
bash scripts/verify-mcp.sh http://<host>:8091
```
This smoke-tests the MCP endpoint end to end: `initialize` (including the coach instructions
block), `tools/list` (the full v1 surface), and `tools/call` round trips through the coach loop —
log a weigh-in, read the trend, day status, log a glass of water and run a fast (the P6
trackers, with water's honest double-log and the fast's idempotent start), push a nutrition plan
and a workout block (verifying the one-active rule + history on both), read the weekly summary,
complete the plans. **It writes** — point it at a fresh/cold-boot instance (or a scratch
`DATABASE_URL`), not at a database you care about.
## Connect your agent
Any client that speaks MCP over streamable HTTP works — point it at `http://<host>:8091/mcp`.
For the Hermes household mesh, the coach profile's config gains a `healthforge` entry (the same
`mcp_servers:` shape as the mealforge entry):
```yaml
mcp_servers:
healthforge:
transport: http
url: http://<host>:8091/mcp
```
Pair it with the repo-shipped coach skill — copy
[`skills/health-coaching/SKILL.md`](skills/health-coaching/SKILL.md) into the coach profile's
skills directory. The skill teaches the loop the tools are shaped around: intake → mid-week
nudges → the Sunday `get_weekly_summary` review (nutrition adherence + workout completion) →
the two-step pushes (propose in chat, push only on confirmation — weekly nutrition plan and
structured workout block alike) → adjust, with the refusal boundaries (never invent kcal, never
edit history without confirmation, no medical advice). Wiring the coach profile itself is an
owner step — the repo ships the skill and the snippet above, nothing touches your profile.
## Development
Requirements: Node 22 and pnpm (`corepack enable` gets you pnpm). It's an Nx monorepo: `apps/api`
(Hono + tRPC v11 + Drizzle + SQLite, serves the MCP endpoint and the built web app), `apps/web`
(React 19 + Vite + TanStack Router + Tailwind 4 + Recharts), `packages/{shared,config,ui}`.
```bash
pnpm install
pnpm dev # api on :3000, web on :5173 (proxies /trpc)
pnpm nx run-many -t test,build # vitest + builds
pnpm lint # biome check
pnpm spec:validate # openspec tree consistency
```
Work is spec-driven: the master spec is the authority, `openspec/changes/` carries the per-phase
requirement deltas, and features are built test-first against those requirements.
## License
[AGPL-3.0](LICENSE) — Copyright (c) 2026 gavdevs.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues