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
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | Yes | Numeric value to convert. |
from | string | Yes | Source unit: mm, cm, m, km, in (or inch), ft, yd, mile, nm |
to | string | Yes | Target unit: mm, cm, m, km, in (or inch), ft, yd, mile, nm |
Response
| Field | Type | Description |
|---|---|---|
result | number | Converted value. |
Example
{
"value": 100,
"from": "cm",
"to": "m"
}
Result:
{
"result": 1.0
}
More examples
value | from | to | result |
|---|---|---|---|
1 | km | mile | 0.6213711922... |
1 | in | cm | 2.54 |
1 | nm | km | 1.852 |
1760 | yd | mile | 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
inandinchare aliases for the inch; both are accepted.nmis the nautical mile (1 852 m), not the nanometre.- All results are 64-bit floating-point numbers.