convert_mass
Converts a numeric mass value from one unit to another. Supports metric (mg, g, kg, t), and common imperial/US units (oz, lb, st).
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | Yes | Numeric value to convert. |
from | string | Yes | Source unit: mg, g, kg, t (metric tonne), oz, lb, st |
to | string | Yes | Target unit: mg, g, kg, t (metric tonne), oz, lb, st |
Response
| Field | Type | Description |
|---|---|---|
result | number | Converted value. |
Example
{
"value": 1000,
"from": "g",
"to": "kg"
}
Result:
{
"result": 1.0
}
More examples
value | from | to | result |
|---|---|---|---|
1 | kg | lb | 2.2046226218... |
1 | lb | oz | 16.0 |
1 | t | kg | 1000.0 |
14 | st | kg | 88.9041044... |
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
tis the metric tonne (1 000 kg), not the short or long ton.stis the stone (UK), equal to 14 lb.- All results are 64-bit floating-point numbers.