Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export CRONOMETER_PASSWORD="your-password"

| Tool | Description |
|------|-------------|
| `get_food_log` | Diary entries for a date with food names, amounts, and meal groups |
| `get_food_log` | Diary entries for a date with food names, amounts, and meal groups, plus an energy_summary (target/consumed/remaining kcal) |
| `get_daily_nutrition` | Daily macro and micronutrient totals |
| `get_nutrition_scores` | Category scores (Vitamins, Minerals, etc.) with per-nutrient consumed amounts and confidence levels |

Expand Down
25 changes: 25 additions & 0 deletions src/cronometer_api_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,41 @@ def get_food_log(date: str | None = None) -> str:
Returns every food entry logged for the day, including food names,
amounts, meal groups, and nutrient data.

Also returns a top-level energy_summary field with pre-computed
values most relevant to the user:

- total_target_kcal: daily calorie target dynamically adjusted
for expenditure and weight goal (equivalent to Cronometer's
"Total Target" in the Energy Summary screen)
- consumed_kcal: total calories consumed
- remaining_kcal: calories remaining to stay on target
(total_target_kcal - consumed_kcal). Always report this
when summarizing the user's day. Prefer this over manually
deriving values from the burn breakdown fields.

Args:
date: Date as YYYY-MM-DD (defaults to today).
"""
try:
client = _get_client()
day = _parse_date(date)
data = client.get_diary(day)

summary = (data or {}).get("summary") or {}
target = (summary.get("macros") or {}).get("energy")
consumed = (summary.get("consumed") or {}).get("total")
energy_summary: dict | None = None
if target is not None and consumed is not None:
energy_summary = {
"total_target_kcal": target,
"consumed_kcal": consumed,
"remaining_kcal": int(round(target - consumed)),
}

return _ok(
{
"date": date or str(date_module_today()),
"energy_summary": energy_summary,
"diary": data,
}
)
Expand Down
Loading