Skip to main content
Glama
plate-cost

plate-cost

by rephol

plate-cost

一个MCP 应用,用于计算食谱成本和菜单定价——一个交互式计算器,模型打开它而不是自己进行算术运算。

问 Claude "帮我给我的印尼炒饭定价",你会得到一个可用的电子表格:食材行、采购价格、损耗百分比、份量产出、利润率滑块。改动一个数字,所有内容都会重新计算。按下 Use these numbers,模型会继续对话,使用你输入的数值,而不是它自己编造的数值。

基于 MCP Apps(ext-apps)构建。

plate-cost running in the ext-apps reference host

运行在 ext-apps 的 basic-host 参考宿主中——不是 Claude。模型提出了食谱,组件加载了它,而 "Use these numbers" 将修正后的数值发送回对话中。

为什么这是应用而不是工具

成本计算是探索,不是提问。在你调整份量大小并观察利润率变化之前,你不会知道自己想要什么答案。聊天对此是一个糟糕的界面,而模型在脑子里做算术更糟——LLM 在多步数值计算上不可靠,但在听起来很确定这件事上却完全可靠。

所以分工是:组件捕获输入,服务器做数学计算,模型负责对话。

Related MCP server: ScenarioSim MCP

有趣的部分:知道数字来自哪里

MCP Apps 有一个未解决的问题——ext-apps#746:来自组件的 tools/call 和模型决定发起的调用在服务器端无法区分。对大多数工具来说这无关紧要。但对成本计算工具来说,它决定了你是在做算术还是在洗白一个猜测。

mcp-app-attest 解决了这个问题——从本仓库中提取出来,本仓库是它的第一个使用者。服务器每次提供应用资源时都会铸造一个短期令牌并将其替换到文档中;组件在每次调用时通过 _meta 将其回显。模型永远不会看到资源主体,因此无法生成令牌。无论哪种方式,调用都会得到响应——响应会说明它收到的是哪一种:

{ "perPortion": 3300, "inputsFrom": "model" }

当数字来自模型时,文本回复会说明这一点:

注意:这些数字来自模型,而非计算器。在依赖这些数字之前,请与用户确认采购价格。

[provenance] inputsFrom=model  reason=missing  meta=null
[provenance] inputsFrom=app    meta={..."io.platecost/app-attestation":"XfqGVAiP…"}

这不是什么。 不是授权,也不是人类输入过任何内容的证明。它区分的是代码路径,而非身份。如果宿主将资源文本复制到模型上下文中,模型就能读取令牌——这里没有任何机制阻止这一点,这是宿主需要遵守的约定。被攻破的组件可以发送任何它想要的内容。把它视为"输入到我的表单中"和"由语言模型生成"之间的区别,这正是 #746 所要求的。

它后来被提取到 mcp-app-attest 中,该项目改用签名令牌而非存储令牌——原因见下面的"什么没起作用"说明。

这个领域搞错的两件事

两者都在 src/costing.ts 中,两者都有测试。

损耗意味着买更多,而不是用更多。 成本是 used / (1 - wastePct),而不是 used * (1 + wastePct)。在 50% 损耗时你要买双倍,而不是一点五倍。天真的版本低估了你拥有的每一种需要修整的食材。

利润率(margin)和加价率(markup)是不同的数字。 利润率是 (price - cost) / price;加价率是 (price - cost) / cost。60% 的加价率是 37.5% 的利润率,而 60% 的利润率需要 150% 的加价率。priceForMargin 接受利润率——这就是厨房里"我们要 65%"的意思——并返回两者,这样差距是可见的而不是被假设的。

还处理了:质量和体积族内的单位转换,跨族转换会被拒绝(kg → l 需要你未提供的密度)、每种食材的成本占比,以及按份而非按批次分摊的间接费用。

试试看

npm install
npm run build      # bundles the widget to a single inlined HTML
npm test           # 21 tests
npm run dev        # widget standalone in a browser, no host

将 MCP 客户端指向 server.ts。在宿主之外,认证占位符永远不会被替换,因此调用会被标记为 model——这是诚实的答案。

什么没起作用

  • 无状态的 HTTP 传输。 第一个版本为每个请求构建一个新的服务器,这对无状态工具没问题,但会悄悄破坏这个应用:认证令牌是由一个服务器实例铸造的,当组件回调时该实例已不存在,所以每次组件调用都被拒绝为 unknown。内存中的测试无法发现这一点——它们共享一个实例。只有针对真实宿主运行时才暴露了这个问题。

  • 归咎于 SDK。 在发现上述问题之前,明显的嫌疑是 _meta 在传输中被剥离。事实并非如此:参考宿主通过沙箱代理完整地转发它。这值得知道,因为整个机制依赖于宿主这样做,而规范并不要求这一点。

状态

v0。两个工具(cost-recipe、price-portion),一个组件,21 个测试。

未构建:对话之间的持久化、多食谱比较,以及任何涉及 #753 / #745 中命名空间问题的事项——callServerTool 使用裸工具名,所以这在聚合器后面会出问题。这是下一个值得解决的问题,但这里没有解决。

MIT.

Available Tools

2 tools
cost-recipeCost a recipeB

Cost one batch of a recipe and one portion of it, given ingredient purchase prices, quantities used, waste percentages and portion yield. Opens an interactive calculator. Do not compute food costs yourself — call this.

NameRequiredDescriptionDefault
nameYes
ingredientsYes
yieldPortionsYes
overheadPerPortionNo

Output Schema

NameRequiredDescription
perBatchYes
breakdownYes
inputsFromYes
perPortionYes
overheadPerPortionYes
ingredientCostPerPortionYes

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, but it does disclose a meaningful behavioral trait: the tool 'opens an interactive calculator' rather than silently returning a number, and it warns against self-computation. It omits any note on side effects, permissions, or whether the interactive session blocks, and an output schema covers the return payload.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences, front-loaded with the core action and ending on the key directive. Every sentence carries content, though the fragments 'given…' and the calculator note could be tightened.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need no explanation, and the description covers the main input concepts. It still leaves overheadPerPortion undocumented and provides no basis for choosing between this tool and price-portion, which is a real gap for a 4-parameter tool with an undocumented optional field.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It does name the ingredient-side concepts (purchase prices, quantities used, waste percentages, portion yield), mapping to four of the parameters, but the optional overheadPerPortion parameter is never mentioned and no unit/format semantics are clarified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('cost one batch of a recipe and one portion') plus the key input categories, which is more than a restatement of the name. It does not, however, differentiate itself from the sibling price-portion, so an agent cannot tell the two apart from the description alone.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly directs the agent to use this tool rather than computing food costs itself ('Do not compute food costs yourself — call this'), which is genuine usage guidance. It offers no condition for preferring this over the sibling price-portion, so routing between the two is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

price-portionPrice a portionA

Turn a portion cost into a selling price at a target margin, and report margin, markup and food-cost percentage. Margin and markup are different numbers — call this rather than converting between them yourself.

NameRequiredDescriptionDefault
costYes
priceNo
targetMarginPctNo

Output Schema

NameRequiredDescription
costYes
priceYes
profitYes
marginPctYes
markupPctYes
foodCostPctYes

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations, so the description carries the burden. It discloses the computed outputs (margin, markup, food-cost percentage) and warns about margin/markup confusion, but says nothing about required inputs, error behavior, or how cost/price/targetMarginPct interact (e.g., whether price overrides targetMarginPct).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two tight sentences, front-loaded with the core action and ending on the key disambiguation. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Output schema exists, so return-value detail is unnecessary. The description covers the tool's purpose and usage warning but is thin on the input parameter interaction (price vs targetMarginPct) given 0% schema coverage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so description must compensate. It clarifies the semantic dependency of the three fields implicitly (cost in, target margin or price out) and defines margin/markup, partially compensating. However, it doesn't explain the precedence between providing 'price' vs 'targetMarginPct'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (price) and resources (portion cost → selling price) and the exact computation (target margin, reporting margin/markup/food-cost %). Distinguishes from sibling cost-recipe by being about pricing rather than costing a recipe.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives a clear conditional steer: 'call this rather than converting between them yourself' for margin vs markup conversion, implying when-to-use over manual math. No explicit exclusion vs cost-recipe, but context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

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

  1. 2 tool updatesv0.1.0
    • First observedcost-recipe
    • First observedprice-portion

TDQS

A3.5/5.0

Scored across 2 tools

Disambiguation4/5

The two tools have distinct purposes: costing a recipe versus converting a cost into a selling price. There is minor thematic overlap around food-cost math, but each description clarifies the boundary.

Naming Consistency3/5

Both names use a noun_noun or verb_noun style ('cost-recipe', 'price-portion') with hyphenation, but the verb-first pattern is only loosely applied and not fully predictable.

Tool Count3/5

Two tools is thin for a costing/pricing domain; it may be intentionally narrow, but it is borderline for useful coverage.

Completeness3/5

The surface covers recipe costing and portion pricing, but lacks operations for managing ingredients, recipes, or price lists, creating notable gaps for a full workflow.

Maintenance

ActivityStale
ResponsivenessNo recent community issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Provides hospitality intelligence tools for restaurant optimization, including menu profitability analysis, food cost calculation, reservation management, review sentiment analysis, and allergen checking.
    6 npm
    37 PyPI
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    A deterministic what-if scenario simulation MCP server that projects business metrics over time with exact decimal arithmetic, offering sensitivity analysis and break-even solving.
    6
    36 npm
    1
    MIT