Skip to main content
Glama
mise-en-place

mise-en-place

by edgargalvan

mise-en-place

一个 MCP 服务器,为指定名称和数量的食材返回可信的大量营养素数据,数据来源于 USDA FoodData Central。

它只有一个职责:当 LLM 在规划膳食或构建食谱时,为真实食物、真实数量提供真实的卡路里/蛋白质/碳水化合物/脂肪数据,绝不给出看似合理的猜测。成分构成、食谱设计和算术运算由调用模型自行处理。正确的输入是此服务器唯一关心的问题。

它是什么

mise-en-place 本身并不是营养数据库。它是 USDA FoodData Central 之上的一个查询层,旨在让 LLM 能够搜索食物、将数量(“1 个中等洋葱”、“2 汤匙”、“6 盎司”)解析为克数,并获得真实、有来源的宏量营养素数据,而不是凭空捏造。它通过 MCP(stdio)运行,因此任何支持 MCP 的客户端(Claude Code、Claude Desktop 或任何其他支持该协议的客户端)都可以直接连接。

八个工具:search_foods、get_nutrition、get_nutrition_batch、save_override、save_recipe、get_recipe、get_recipe_history、list_recipes。完整的签名和模式见 INTERFACES.md。

Related MCP server: nutrition-mcp-server

如何使用

要求: Python 3.11+,一个免费的 USDA FoodData Central API 密钥(即时注册)。

git clone <this repo>
cd mise-en-place
uv sync   # or: pip install -e .
export USDA_API_KEY=<your key>

将其注册到 MCP 客户端,例如 Claude Code:

claude mcp add mise-en-place -s local -e USDA_API_KEY=<your key> -- \
  uv run --directory /path/to/mise-en-place mise-en-place

重启客户端以加载新连接,然后直接询问你要烹饪的内容。服务器自身的 instructions(见 server.py 中的 _SERVER_INSTRUCTIONS)随连接一起传递,并告知模型如何正确使用工具,因此无需手动粘贴任何内容到聊天中。如果你正在运行带有自己宏量营养素目标的定期膳食规划会话,请参阅 MEAL_PLANNING_PROMPT.md。目标因人而异、因餐而异,因此服务器从不存储它们;该文件是它们的唯一存放位置。

个人修正和保存的食谱存放在 ~/.mise-en-place/(MISE_HOME)中,绝不会提交。仓库根目录下的 masses.toml 是随附的、已检入的默认常见家用计量重量表(一个中等洋葱、一个大鸡蛋):由人工编写、附有引用来源,并且可以通过编辑它来安全地提出异议。

为什么使用它

很多“帮我查卡路里”的工具回答的是它们实际上并不知道答案的问题。这个工具不会:

  • 绝不捏造营养素数值。 如果 USDA 没有该数据,工具会抛出错误或明确报告该数据缺失,绝不会用零或估算值来冒充事实。

  • 绝不回退到整数。 无法解析为质量的数量(通过 USDA 自身的份量数据、你自己的保存修正或随附的 masses.toml 默认值)会抛出错误,而不会默认使用 100 克或猜测密度。

  • 每个不确定的值都会明确说明。 低置信度匹配、工具不确定的候选结果、假设的质量:所有这些都会作为结构化警告返回给调用模型,而不是看起来与已验证数据一样可信的数字。

  • 修正会让工具永久变得更好。 save_override 和 save_recipe 意味着错误只需修正一次,而不必在每次查询相同食材时重新猜测。

  • 比模型自行猜测可衡量地更准确。 一个针对手工验证的标签数据的 10 个食谱基准测试显示,该工具的平均误差为 4.99%,而同一模型在无工具访问的情况下为 8.26%。方法和当前数据见下文。

我们如何验证这确实是真的

“绝不捏造数值”这条规则说起来容易,做起来也容易悄悄违反。有两件事为其提供支撑。

实时、重新验证的测试数据。 本项目引用的每个 USDA ID(在 masses.toml 和测试套件的黄金值中)都会在每次运行时从真实 API 重新获取,并对照其声称的内容进行检查(tests/test_golden_values.py、tests/test_masses_toml.py)。过时的引用会大声失败,而不是看起来权威地摆在那里。

准确性针对真实产品数据进行验证,而非另一个食谱网站的意见。 早期的一次准确性测试将该工具的输出与一个流行的健康食谱网站发布的营养数据进行了比较,发现该工具在某些食谱上存在较大偏差。进一步检查发现偏差方向相反:针对实际产品营养标签对手工检查最差的情况进行核对后,发现该工具的数据更接近现实,而第三方网站的数据才是异常值。与任何食谱网站进行比较最终被证明是错误的测试,因为其自身的方法不透明,无法知道它定价的是哪种产品、使用了哪种份量产出约定,或者背后是哪个营养数据库。

由此指向的真正准确性基准(tests/golden_recipes/)由两个刻意分开的来源构建:USDA 针对真正的商品食材的数据(土豆、白砂糖:没有品牌可言的东西),以及针对任何特定商业产品可能意味着的东西的真实产品营养标签(某个品牌的玉米片、包装豆腐)。使用 USDA 数据来验证一个 USDA 支持的工具的通用匹配,只是检查它是否与自己一致;标签数据是唯一对品牌形状食材真正有意义的独立检查。几个食谱刻意以两种方式表述相同的食材:通用名称(“玉米片”)和特定名称(“Mission 玉米片”),因此基准测试既检查工具的默认通用匹配,也检查当食谱明确要求某个命名产品时,它是否能正确找到并优先选择该产品。

最新结果(10 个食谱,配备工具的主体 vs. 仅靠 LLM 回忆的主体,两者均针对相同的手工验证标签数据评分,2026-08-21):配备工具的主体在卡路里/蛋白质/碳水化合物/脂肪上的平均绝对误差为 4.99%,而同一主体在无工具访问的情况下为 8.26%。该工具在 10 个食谱中的 7 个上完胜,在含有真正难以处理的品牌食材或脂肪含量容易记错的肉类切块(鸡腿肉、侧腹牛排)的食谱上表现尤为突出。在裸回忆表现相当或更好的三个食谱中,这并不能证明工具自身的匹配能力弱。这些情况是食谱本身留下了无法计数的数量(没有规定重量的装饰物),迫使两种条件独立猜测,并增加了与基准测试试图衡量的内容无关的噪声。关于一个值得在信任其分数之前修复的案例,请参阅 tests/golden_recipes/eval_prompts.json 中的 note_on_TC10。这个数字会随着测试夹具和工具不断变化而漂移;请将其视为最新读数,而非永久声明。

更多阅读

如果你想了解

阅读

系统必须做什么、置信度模型、宏量营养素报告

REQUIREMENTS.md

模块布局、数据流、测试策略

ARCHITECTURE.md

精确的工具签名和数据模式

INTERFACES.md

已完成和待完成的内容

TASKS.md

任何(人类或代理)在此代码库上工作的规则

CLAUDE.md

Available Tools

8 tools
get_nutritionA

Get verified macros (kcal, protein, carbs, fat) for one ingredient at one quantity. fdc_id must come from a prior search_foods call -- never guess one. amount accepts grams/kg, oz/lb, or a count phrase like "1 medium onion" (the server resolves counts through a cited chain of real sources; it will raise rather than guess if it cannot). label is the user's own word for this ingredient, written verbatim -- do not paraphrase or clean it up, it is used to judge how confident this match is. query should be a search string that actually returns fdc_id among its results -- the server re-runs it and checks. This catches an ID invented from memory; it does not confirm query is the search you actually used, only that fdc_id is findable through it right now.

Open Food Facts fallback: set source to whatever search_foods returned for the candidate you chose ("usda", the default, or "off"). For "off", fdc_id holds the Open Food Facts barcode search_foods already gave you, query is not consulted (no re-verification exists yet for this source), and count-phrase quantities only resolve if the product itself states a serving size -- otherwise give an explicit mass (grams/oz). The response always carries a caveat naming this a crowdsourced, not USDA, source.

The response always includes a summary, a report_path, and totals (the plate sum, computed server-side, even for one item and even with no target -- never add it up yourself). Read the summary in full and relay every flagged item to the user, not just the confirmed ones -- a caveat you drop silently (a low-confidence match, an assumed mass) defeats the only safety mechanism this tool has. A macro genuinely absent from a food (no protein data at all, for example) comes back as null with a caveat naming it, never as zero -- zero means the food truly has none.

The macros this tool returns are the only ones to state as fact for a food it matched -- never invent or estimate your own number in their place. The one narrow exception: if search_foods finds nothing at all for an item, you may estimate that single item's nutrition instead of leaving it out, but only if you say plainly it is your own guess, not verified data (C-28).

Pass target if the user has a kcal/protein/carb/fat goal for this lookup; use the returned totals.outcomes, never compute whether a target was met yourself.

Inputs: req (required), target.

get_nutrition_batchA

Same as get_nutrition, for multiple ingredients in one call -- use this instead of calling get_nutrition in a loop, it is far faster to iterate on a recipe with. One bad item does not fail the batch: a failed lookup comes back as a marked failure alongside the successful ones, in the same order as reqs.

Read the whole summary before presenting results to the user: it names every item that needed judgment, not just the ones that failed outright. Burying three flagged items under eleven confirmed ones and only mentioning the confirmed ones is the single most damaging way to misuse this tool. A macro absent from one ingredient (no protein data at all, for example) comes back null with a caveat naming it, not zero, and makes that macro's plate total totals.macros come back null too -- reported as incomplete, not silently summed as though the absent ingredient contributed nothing.

totals (the plate sum) is always computed server-side, whether or not you pass target -- never add up the plate's macros yourself, even for a bare "what does this plate total" question. Pass target once for the whole plate to also get totals.outcomes, the per-macro met/not-met judgment; without one, every macro's outcome reads "no target" and only the sum is judged.

Inputs: reqs (required), target.

get_recipeA

Fetch a saved recipe. Omit version for the latest. Macros are computed fresh from the stored plate on every call, never cached -- if this ever disagrees with something said earlier in the conversation, the plate or the underlying food data changed since then; trust this call.

Inputs: name (required), version.

get_recipe_historyA

Fetch every saved version of a recipe, in order, to see how it evolved and why -- each version's notes explains what changed. Use this before assuming a recipe's current numbers are the only numbers it ever had.

Inputs: name (required). Returns: result

list_recipesA

List saved recipes, optionally filtered by protein range, calorie range, or whether a given fdc_id appears as an ingredient. Filters run against each recipe's current plate, computed fresh on read.

Inputs: filter. Returns: result

save_overrideA

Permanently correct what a phrase means or what a count weighs, for this user. Use this the moment a lookup's summary flags something as wrong or low-confidence and the user tells you the right answer -- that correction is the entire point of reading the summary in the first place.

Pass fdc_id to fix which food a phrase resolves to, grams to fix what a count weighs, or both. At least one is required. You cannot supply your own description of the food: the server fetches the real USDA description and writes that, so a bad correction is caught immediately rather than saved blind.

When correcting grams, phrase must be the exact count phrase you would pass as amount to get_nutrition (e.g. "1 medium onion"), not just the ingredient's name (e.g. "onion") -- masses are looked up by that phrase, and a mass saved under the wrong key is never found again.

Every future lookup of this phrase short-circuits to this correction at high confidence. note should say why, briefly -- it is the only record of that later.

Inputs: phrase (required), note, grams, fdc_id.

save_recipeA

Save a new version of a recipe. plate is the user's own plate only, in absolute grams per ingredient -- never a household total. Each ingredient needs an fdc_id from a real lookup (never invent one) and its exact amount in grams. shares records everyone else at the table as a fraction of the user's plate (e.g. {"maria": 0.75}) -- leave it empty if cooking just for the user, that is the common case, not a special one.

Saves are append-only: this always creates a new version, it never overwrites one. notes is required and should say what changed and why (e.g. "corrected cooked weight after weighing it") -- it is the only record of that later, and the most useful field in the whole store.

Inputs: name (required), notes (required), plate (required), shares (required).

search_foodsA

Search USDA FoodData Central for candidate foods matching a plain-language query (e.g. "chicken breast", "greek yogurt"). Returns ranked candidates: generic (Foundation, SR Legacy) before branded, always. Raises only if nothing at all matches -- never returns an empty list.

This is the ONLY way to find a valid fdc_id. Never invent, recall, or reuse an fdc_id from memory or an earlier conversation: call this tool first, read the returned descriptions, and choose the one that actually matches what the user meant. Pass this exact query string as query to get_nutrition or get_nutrition_batch so the server can verify your chosen fdc_id was really one of these results. Each candidate carries a source field ("usda" or "off") -- pass it through as NutritionRequest.source unchanged; fdc_id itself always goes in the same field either way.

A returned candidate can still fail to fetch (USDA's own search index can be ahead of its detail records, especially for newer Foundation entries) -- if get_nutrition/get_nutrition_batch reports that id as failed, do not give up: try the next candidate from this same list. A failed fetch on its own is not evidence the food itself doesn't exist.

Open Food Facts fallback: set expect_branded=True when the ingredient names or clearly implies a specific commercial product (a brand name, "Mission Carb Balance," "Nature's Own keto bun," or a stated attribute like "low-carb"/"keto" you suspect USDA does not carry under that name) -- the same judgment X-7 already asks you to make about when to search using a stated attribute, extended one step further. When set, this also searches Open Food Facts (a free, crowdsourced, barcode-indexed database) and reserves a slice of limit for any candidate that passes a real plausibility gate (no impossible or self-contradictory nutrition values) -- still fundamentally less trustworthy than a USDA record, anyone can edit an entry, and get_nutrition always attaches a caveat naming this plainly. Leave it False (the default) for a plainly generic ingredient (eggs, potato, olive oil, chicken breast) -- Open Food Facts is a packaged-goods database and has nothing to offer a commodity food, so trying it there is pure latency with no upside. USDA alone is still searched every time regardless of this flag, and Open Food Facts is still tried as a last resort if USDA returns literally nothing even when this flag is False, so a real zero- result case is never silently unhandled just because you forgot to set it.

Inputs: query (required), limit, expect_branded. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: search_foods discovers candidate ingredients, get_nutrition and get_nutrition_batch retrieve verified nutrition data for one or many ingredients, save_override permanently corrects lookup data, and save_recipe/get_recipe/get_recipe_history/list_recipes manage the lifecycle of saved recipes. The boundary between fetching a food and fetching nutrition, or between correcting a lookup and saving a full recipe, is strongly reinforced by detailed descriptions.

    Naming Consistency4/5

    Most tools follow verb_noun (search_foods, get_nutrition, save_recipe, list_recipes). Minor deviations: save_override is verb_verb rather than verb_noun, and get_nutrition_batch is a noun modifier rather than verb_noun. Mixed conventions, plus the label get_nutrition_batch when save/retrieve/recipes, however, are predictable and readable, so the set remains usable.

    Tool Count5/5

    8 tools are correctly calibrated for a nutritional dataset and recipe store: 2 ingredient retrieval tools, batch mode, correction, recipe storage, and versioning. Each of the 8 tools is clearly justified and applicable, and complete omission is saved in the moderation of a useful compact-size dataset.

    Completeness4/5

    The core workflow is well covered: find ingredient, get nutritional info, batch retrieval, correct with override, save and read recipes, history and listing. The missing note is delete_recipe; save_recipe remains an append-only operation (each save creates a new version) with no way to remove old recipes. Which is a real limitation—a user can add recipes but cannot delete them. The current scope may be intentional, but this omission prevents entire recipe lifecycle management.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to search the USDA's FoodData Central database and retrieve detailed nutritional information and ingredient lists. It supports comprehensive food data access through keyword searches and structured queries for specific food items.
      3
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides tools to search and retrieve USDA Food Data Central information, including food items, nutrients, and food groups, enabling AI agents to query food data through natural language.
      53 npm
      MIT