Skip to main content

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​

ParameterTypeRequiredDescription
valuenumberYesNumeric value to convert.
fromstringYesSource unit: J, kJ, MJ, cal, kcal, Wh, kWh, BTU, eV, ft_lbf
tostringYesTarget unit: J, kJ, MJ, cal, kcal, Wh, kWh, BTU, eV, ft_lbf

Response​

FieldTypeDescription
resultnumberConverted value.

Example​

{
"value": 1,
"from": "kWh",
"to": "J"
}

Result:

{
"result": 3600000.0
}

More examples​

valuefromtoresult
1kcalkJ4.184
1BTUJ1055.055852...
1WhJ3600.0
1kJcal238.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).

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​

  • Unit strings are case-sensitive: J ≠ j, BTU ≠ btu.
  • cal is the thermochemical calorie (4.184 J); kcal is the kilocalorie (food calorie, 4 184 J).
  • BTU uses the International Table definition (1 055.055 852 62 J).
  • eV is the electronvolt (1.602 176 634 × 10⁻¹⁹ J), intended for physics use cases.
  • ft_lbf is the foot-pound force (1.355 817 948 J).
  • All results are 64-bit floating-point numbers.