Skip to main content

convert_temperature

Converts a temperature value between Celsius, Fahrenheit, and Kelvin using exact offset-and-scale formulas.

Parameters​

ParameterTypeRequiredDescription
valuenumberYesNumeric temperature value to convert.
fromstringYesSource unit: c or celsius, f or fahrenheit, k or kelvin
tostringYesTarget unit: c or celsius, f or fahrenheit, k or kelvin

Response​

FieldTypeDescription
resultnumberConverted value.

Example​

{
"value": 100,
"from": "c",
"to": "f"
}

Result:

{
"result": 212.0
}

More examples​

valuefromtoresult
0ck273.15
32fc0.0
0kc-273.15
37cf98.6

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​

  • Both short forms (c, f, k) and full names (celsius, fahrenheit, kelvin) are accepted and are case-sensitive.
  • Conversion uses the exact formulas: C→F: °C × 9/5 + 32, C↔K: ±273.15 offset.
  • All results are 64-bit floating-point numbers.