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
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | Yes | Numeric value to convert. |
from | string | Yes | Source unit: ml, cl, dl, l, m3, tsp, tbsp, fl_oz, cup, pt, qt, gal, imp_gal |
to | string | Yes | Target unit: ml, cl, dl, l, m3, tsp, tbsp, fl_oz, cup, pt, qt, gal, imp_gal |
Response
| Field | Type | Description |
|---|---|---|
result | number | Converted value. |
Example
{
"value": 1,
"from": "cup",
"to": "ml"
}
Result:
{
"result": 236.588237
}
More examples
value | from | to | result |
|---|---|---|---|
1 | l | ml | 1000.0 |
1 | gal | l | 3.785411784 |
1 | imp_gal | l | 4.54609 |
3 | tsp | tbsp | 1.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).
| Code | When | Delivered as |
|---|---|---|
invalid_arguments | value is missing or not a number, or from/to is missing or not a string. | protocol error (invalid_params) |
invalid_unit | from or to is not a recognised unit. The error message lists the accepted unit strings. | tool error (isError) |
internal_error | An 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_galis the Imperial (UK) gallon (≈ 4.546 l), distinct from the US gallon (≈ 3.785 l).m3is the cubic metre (1 000 litres).- All results are 64-bit floating-point numbers.