Skip to main content

convert_volume

Converts a numeric volume value from one unit to another. Supports metric (ml through m³), US culinary (tsp, tbsp, fl_oz, cup, pt, qt, gal), and Imperial gallon.

Parameters​

ParameterTypeRequiredDescription
valuenumberYesNumeric value to convert.
fromstringYesSource unit: ml, cl, dl, l, m3, tsp, tbsp, fl_oz, cup, pt, qt, gal, imp_gal
tostringYesTarget unit: ml, cl, dl, l, m3, tsp, tbsp, fl_oz, cup, pt, qt, gal, imp_gal

Response​

FieldTypeDescription
resultnumberConverted value.

Example​

{
"value": 1,
"from": "cup",
"to": "ml"
}

Result:

{
"result": 236.588237
}

More examples​

valuefromtoresult
1lml1000.0
1gall3.785411784
1imp_gall4.54609
3tsptbsp1.0

Errors​

Each failure carries a precise code in the response. Argument-schema and server errors are JSON-RPC protocol errors; a rejected value is returned as a tool result with isError: true (so the agent can read the code and self-correct).

CodeWhenDelivered as
invalid_argumentsvalue is missing or not a number, or from/to is missing or not a string.protocol error (invalid_params)
invalid_unitfrom or to is not a recognised unit. The error message lists the accepted unit strings.tool error (isError)
internal_errorAn unexpected server error.protocol error (internal_error)

Notes​

  • All US culinary units (tsp, tbsp, fl_oz, cup, pt, qt, gal) follow US customary definitions.
  • imp_gal is the Imperial (UK) gallon (≈ 4.546 l), distinct from the US gallon (≈ 3.785 l).
  • m3 is the cubic metre (1 000 litres).
  • All results are 64-bit floating-point numbers.