Skip to main content
Glama

toGrams

Read-onlyIdempotent

Converts any quantity and unit to grams using USDA portion weights or density data. Returns unresolved candidates when exact conversion isn't available.

Instructions

Convert an amount to grams. Mass units are exact. A volume or a count needs either the food's own USDA portion weights, which you get by passing fdcId, or a sourced density row. When neither is available the answer is unresolved with candidates attached, because a cup of flour and a cup of honey do not weigh the same.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
unitYesFree text such as 'tbsp', 'cups', 'oz', 'medium'.
fdcIdNoWhen given, this food's own USDA portion weights are tried before the density table.
quantityYes
ingredientNameNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
noteYes
gramsYesNull when the conversion could not be sourced.
methodYes
unitKindYes
confidenceYes
densityRowYes
fdcPortionYes
normalizedUnitYes
densityCandidatesYes
portionCandidatesYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior4/5

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

The description discloses the unresolved-with-candidates outcome and explains why different foods weight differently, which adds meaningful behavior beyond the read-only/idempotent/open-world annotations. No contradiction with annotations.

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 focused sentences with the core purpose up front. The flour-vs-honey example earns its place by clarifying why volume conversion is not trivial, though it adds slight length.

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?

Given the output schema and read-only/idempotent annotations, the description covers the main conversion logic, edge cases, and required inputs. The only notable gap is the unmentioned role of ingredientName.

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?

The schema leaves ingredientName and fdcId thin, but the description clarifies that fdcId provides USDA portion weights and that volume/count units need extra data. It does not fully explain ingredientName, but it gives enough to guide correct usage.

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?

The description opens with a clear verb and resource: 'Convert an amount to grams.' It then distinguishes exact mass units from ambiguous volume/count cases, which sets it apart from sibling recipe-parsing and macro tools.

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?

It gives explicit guidance on when the conversion is straightforward versus when fdcId or a density row is needed<!-- -->—exactly the decision an agent must make. It does not explicitly name sibling alternatives, but the tool's role is clear from context.

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