Skip to main content

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​

ParameterTypeRequiredDescription
valuenumberYesNumeric value to convert.
fromstringYesSource unit: mg, g, kg, t (metric tonne), oz, lb, st
tostringYesTarget unit: mg, g, kg, t (metric tonne), oz, lb, st

Response​

FieldTypeDescription
resultnumberConverted value.

Example​

{
"value": 1000,
"from": "g",
"to": "kg"
}

Result:

{
"result": 1.0
}

More examples​

valuefromtoresult
1kglb2.2046226218...
1lboz16.0
1tkg1000.0
14stkg88.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).

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​

  • t is the metric tonne (1 000 kg), not the short or long ton.
  • st is the stone (UK), equal to 14 lb.
  • All results are 64-bit floating-point numbers.