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
| Parameter | Type | Required | Description |
|---|---|---|---|
value | number | Yes | Numeric value to convert. |
from | string | Yes | Source unit (case-insensitive): B, KB, MB, GB, TB, PB |
to | string | Yes | Target unit (case-insensitive): B, KB, MB, GB, TB, PB |
Response
| Field | Type | Description |
|---|---|---|
result | number | Converted value. |
Example
{
"value": 1,
"from": "TB",
"to": "GB"
}
Result:
{
"result": 1024.0
}
More examples
value | from | to | result |
|---|---|---|---|
1 | KB | B | 1024.0 |
1 | GB | MB | 1024.0 |
1 | PB | TB | 1024.0 |
512 | MB | GB | 0.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).
| 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 matching is case-insensitive:
GB,gb, andGbare 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.