Skip to main content

convert_data_size

Converts a numeric data size value from one binary unit to another. Uses IEC binary prefixes: 1 KB = 1 024 B, 1 MB = 1 024 KB, and so on.

Parameters​

ParameterTypeRequiredDescription
valuenumberYesNumeric value to convert.
fromstringYesSource unit (case-insensitive): B, KB, MB, GB, TB, PB
tostringYesTarget unit (case-insensitive): B, KB, MB, GB, TB, PB

Response​

FieldTypeDescription
resultnumberConverted value.

Example​

{
"value": 1,
"from": "TB",
"to": "GB"
}

Result:

{
"result": 1024.0
}

More examples​

valuefromtoresult
1KBB1024.0
1GBMB1024.0
1PBTB1024.0
512MBGB0.5

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 matching is case-insensitive: GB, gb, and Gb are all accepted.
  • This tool uses binary (base-1024) prefixes only. Decimal SI prefixes (1 KB = 1 000 B) are not supported.
  • All results are 64-bit floating-point numbers, so sub-byte fractional results are possible.