Skip to main content

convert_length

Converts a numeric length value from one unit to another. Supports metric (mm through km), imperial (inch, ft, yd, mile), and nautical mile.

Parameters​

ParameterTypeRequiredDescription
valuenumberYesNumeric value to convert.
fromstringYesSource unit: mm, cm, m, km, in (or inch), ft, yd, mile, nm
tostringYesTarget unit: mm, cm, m, km, in (or inch), ft, yd, mile, nm

Response​

FieldTypeDescription
resultnumberConverted value.

Example​

{
"value": 100,
"from": "cm",
"to": "m"
}

Result:

{
"result": 1.0
}

More examples​

valuefromtoresult
1kmmile0.6213711922...
1incm2.54
1nmkm1.852
1760ydmile1.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​

  • in and inch are aliases for the inch; both are accepted.
  • nm is the nautical mile (1 852 m), not the nanometre.
  • All results are 64-bit floating-point numbers.