# Calorie Service Single-tenant, agent-first nutrition logging. The owner's agent is the only client. There is no signup, no user_id, and no human UI. All times use America/Denver local dates for day boundaries; weights are pounds; nutrition is kcal plus grams. ## Connect - Base URL: https://calorie.txe.app - MCP endpoint: https://calorie.txe.app/mcp - Transport: Streamable HTTP - REST base: https://calorie.txe.app/api/v1 - Auth header: `Authorization: Bearer ` - `X-API-Key: ` is also accepted. - Token: the owner supplies the single service token; it is not published here. - Connector guide: https://calorie.txe.app/docs/muse-connector - Documentation index: https://calorie.txe.app/docs - Unauthenticated data requests return 401. - Public, data-free routes: `/health`, `/`, `/llms.txt`, `/docs`, `/docs/muse-connector`, `/muse-connector.md`. ## Wiring up 1. The owner configures `https://calorie.txe.app/mcp` with the bearer header in the MCP client or Muse connector. 2. The client calls `tools/list`; all ten tools advertise schemas and read/write annotations. 3. A typical first flow is `get_settings`, `get_today`, `search_food`, `log_entry`, then `get_today`. 4. Manual test: `npx @modelcontextprotocol/inspector@latest`, connect to `https://calorie.txe.app/mcp`, and add the bearer header. Example client configuration (the token is supplied by the owner, not by this document): ```json { "url": "https://calorie.txe.app/mcp", "transport": "streamable-http", "headers": { "Authorization": "Bearer " } } ``` ## Operations | MCP tool | REST | Class | Description | |---|---|---|---| | `log_entry` | `POST /api/v1/entries` | write | Log one food entry with pre-resolved totals. | | `get_today` | `GET /api/v1/today` | read | Get one day's entries and DayTotals. | | `get_range` | `GET /api/v1/range?from=&to=` | read | Get inclusive daily totals and entries. | | `undo_last` | `POST /api/v1/entries/undo-last` | write/destructive | Soft-delete the most recent entry. | | `delete_entry` | `DELETE /api/v1/entries/{id}` | write/destructive | Soft-delete one entry by id. | | `log_weight` | `POST /api/v1/weights` | write | Upsert one weight per local date. | | `get_weights` | `GET /api/v1/weights?from=&to=` | read | List weights in an inclusive range. | | `search_food` | `GET /api/v1/foods/search?q=|upc=` | read/open-world | Search cache, USDA, then Open Food Facts. | | `get_settings` | `GET /api/v1/settings` | read | Read targets, goal, and timezone. | | `update_target` | `PATCH /api/v1/settings` | write | Partially update or clear targets and goal. | Every MCP tool takes the REST request fields as a JSON object and returns the same response body. MCP errors set `isError: true` and contain `{ "error": { "code": "...", "message": "..." } }`. ## Conventions - Dates: `YYYY-MM-DD` in America/Denver. Timestamps: RFC 3339 UTC. - Nutrition: integer kcal >= 0; macros in grams >= 0 with at most 1 decimal. - Weight: pounds > 0 with at most 1 decimal. - Entries store totals for the logged quantity, not per-serving values. - `log_entry` never looks up food; `search_food` never creates an entry. - Deletes are soft; deleted entries never appear in totals or lists. - `log_entry` and `log_weight` accept an optional UUID `idempotency_key`. Replaying the same key and payload returns the original response with `idempotent_replay: true`; a different payload returns 409. - `get_range` and `get_weights` are inclusive, require `from <= to`, and allow at most 366 days. ## Errors `{ "error": { "code": string, "message": string } }` Codes: `validation_error` (400), `unauthenticated` (401), `not_found` (404), `nothing_to_undo` (404), `entry_not_found` (404), `idempotency_conflict` (409), `idempotency_in_progress` (409), `upstream_unavailable` (502), `internal_error` (500). ## Examples Log an entry: ```bash curl -X POST https://calorie.txe.app/api/v1/entries \ -H "Authorization: Bearer $SERVICE_TOKEN" \ -H "content-type: application/json" \ -d '{"meal":"snack","description":"Greek yogurt","quantity":1,"serving_label":"1 cup (245g)","nutrition":{"kcal":150,"protein_g":20,"carbs_g":10,"fat_g":4},"source":"manual"}' ``` Read today: ```bash curl https://calorie.txe.app/api/v1/today -H "Authorization: Bearer $SERVICE_TOKEN" ``` Search food: ```bash curl "https://calorie.txe.app/api/v1/foods/search?q=greek%20yogurt&limit=5" \ -H "Authorization: Bearer $SERVICE_TOKEN" ``` Log a weight: ```bash curl -X POST https://calorie.txe.app/api/v1/weights \ -H "Authorization: Bearer $SERVICE_TOKEN" \ -H "content-type: application/json" \ -d '{"weight_lb":185.4}' ``` Set targets: ```bash curl -X PATCH https://calorie.txe.app/api/v1/settings \ -H "Authorization: Bearer $SERVICE_TOKEN" \ -H "content-type: application/json" \ -d '{"target_kcal":2200,"target_protein_g":150,"goal":"lose"}' ``` ## Rate limits There is no application-level rate limit in v1. Cloudflare edge protections apply. Food searches are cached locally; USDA and Open Food Facts have their own upstream limits. Repeated searches for the same food should hit the cache.