# proteintexter agent API

Read and write one account's food log over plain HTTP, or connect an MCP
client (Muse, Claude, anything that speaks MCP) to the same data.

Estimates only. proteintexter counts what someone ate; it never gives health,
nutrition, diet, or medical advice, and a connector must not present its
numbers as any.

## Auth

Every request carries a personal token as `Authorization: Bearer <token>`.
The account owner mints one, signed in (email + emailed code), at
https://www.proteintexter.com/agent. It is shown once and lasts 30 days. A token is scoped to the one account that created it.

## MCP

Endpoint: `https://www.proteintexter.com/api/mcp` (streamable HTTP, Bearer auth).

Tools:

- `whoami`: timezone, the targets the user set, which nutrients they track.
- `list_meals`: confirmed meals with line items over a local date range
  (`from`/`to`, YYYY-MM-DD, both default to today).
- `list_recent_meals`: the newest confirmed meals by count (`limit`,
  default 20, maximum 50), with line items.
- `daily_totals`: per-day calories and macros over a range, plus the user's
  own targets.
- `get_nutrition_totals`: totals and daily averages for one local day, week,
  or month (`period` defaults to day, `date` is a YYYY-MM-DD inside that
  period and defaults to today). Weeks run Monday through Sunday. Includes
  sugar and the user's own targets.
- `get_day_log`: confirmed meals and macro totals for one local date
  (`date`, YYYY-MM-DD).
- `log_meal`: log a meal as line items (`items[]`, optional `eaten_at`,
  `notes`). Lands confirmed, like a texted meal.
- `delete_meal`: delete one meal by id.
- `set_targets`: set the user's own daily protein / calorie / sugar targets.

## HTTP

Same Bearer token; JSON in, JSON out.

- `GET /api/me`: the account and its settings.
- `PATCH /api/me`: update profile, targets, tracked nutrients.
- `GET /api/days?from=YYYY-MM-DD&to=YYYY-MM-DD`: per-day totals; add
  `&meals=1` for the individual meals.
- `GET /api/stats?period=day|week|month`: totals and daily averages.
- `GET|PATCH|DELETE /api/meals/<id>`: one meal and its items.

## Notes

- Photos never leave over the agent API: a meal reports `has_photo`, not a
  URL. Photo estimates stay on the texting line.
- Numbers an agent sends are bounded before they are stored, and a meal's
  totals are re-derived from its items.
- Ranges are capped at 731 days.
