convert_energy
Converts a numeric energy value from one unit to another. Supports SI (J, kJ, MJ), thermal (cal, kcal, BTU), electrical (Wh, kWh), and physics/mechanical units (eV, ft_lbf).
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | Yes | Numeric value to convert. |
from | string | Yes | Source unit: J, kJ, MJ, cal, kcal, Wh, kWh, BTU, eV, ft_lbf |
to | string | Yes | Target unit: J, kJ, MJ, cal, kcal, Wh, kWh, BTU, eV, ft_lbf |
Response
| Field | Type | Description |
|---|---|---|
result | number | Converted value. |
Example
{
"value": 1,
"from": "kWh",
"to": "J"
}
Result:
{
"result": 3600000.0
}
More examples
value | from | to | result |
|---|---|---|---|
1 | kcal | kJ | 4.184 |
1 | BTU | J | 1055.055852... |
1 | Wh | J | 3600.0 |
1 | kJ | cal | 238.845896... |
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
- Unit strings are case-sensitive:
J≠j,BTU≠btu. calis the thermochemical calorie (4.184 J);kcalis the kilocalorie (food calorie, 4 184 J).BTUuses the International Table definition (1 055.055 852 62 J).eVis the electronvolt (1.602 176 634 × 10⁻¹⁹ J), intended for physics use cases.ft_lbfis the foot-pound force (1.355 817 948 J).- All results are 64-bit floating-point numbers.