build_meal
Build a meal with one protein, one carb, and one fat that exactly meets your macro targets. Solves portion sizes from a USDA food database, returning ranked meal options.
Instructions
Build meals of one protein, one carb and one fat that hit macro targets exactly.
A deterministic solver, not a guess: it treats the three foods as a 3x3 linear system and solves for the portion of each, scanning every combination in the database. Results whose portions are exact but unrealistic are discarded, and the remainder ranked by how normal the serving sizes look.
Args: target_protein: Target grams of protein for the meal. target_carb: Target grams of carbohydrate. target_fat: Target grams of fat. exclude_tags: Dietary and allergen labels to avoid, matched against each food's "exclude_for", e.g. ["vegan"] or ["gluten", "dairy"]. Call list_available_tags for valid values. tolerance: Only consulted when NO exact fit exists, to decide whether the closest attempt counts as near enough. 0.15 means +/-15% per macro. include_vegetable: Add a low-calorie vegetable side. Its macros are subtracted from the targets before solving, so the totals still land on the targets exactly. max_results: How many ranked meals to return (default 3).
Returns: {"exact_match", "within_tolerance", "tolerance", "meals": [...], "targets", "candidates_evaluated", "message"}.
Each meal carries "items" (each with name, amount, unit and its own macros),
"totals", and "relative_error" per macro. When "exact_match" is true the
totals equal the targets and relative_error is zero.
When no combination fits, "exact_match" and "within_tolerance" are both false,
"meals" holds the single closest attempt, and "message" states how far off it
is. Report that shortfall to the user -- do NOT present it as a successful fit
or adjust the numbers to look closer.
Report the returned amounts and totals verbatim. They are already exact.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tolerance | No | ||
| target_fat | Yes | ||
| max_results | No | ||
| target_carb | Yes | ||
| exclude_tags | No | ||
| target_protein | Yes | ||
| include_vegetable | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||