Skip to main content
Glama
paladini

devutils-mcp-server

byte_convert

Convert byte units between B, KB, MB, GB, TB, and PB using binary (1024) or SI (1000) standards for data size calculations.

Instructions

Convert between byte units (B, KB, MB, GB, TB, PB). Supports both binary (1024) and SI (1000) standards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYesThe numeric value to convert
from_unitYesSource unit
binaryNoUse binary (1024) instead of SI (1000) standard (default: true)

Implementation Reference

  • The "byte_convert" tool is defined and implemented directly using `server.tool` inside `registerConverterTools`. The implementation calculates the base (1024 vs 1000), normalizes the input value to bytes, and converts it to all other units.
    server.tool(
      "byte_convert",
      "Convert between byte units (B, KB, MB, GB, TB, PB). Supports both binary (1024) and SI (1000) standards.",
      {
        value: z.number().describe("The numeric value to convert"),
        from_unit: z
          .enum(["B", "KB", "MB", "GB", "TB", "PB"])
          .describe("Source unit"),
        binary: z
          .boolean()
          .default(true)
          .describe("Use binary (1024) instead of SI (1000) standard (default: true)"),
      },
      async ({ value, from_unit, binary }) => {
        const base = binary ? 1024 : 1000;
        const units = ["B", "KB", "MB", "GB", "TB", "PB"];
        const fromIndex = units.indexOf(from_unit);
        const bytes = value * Math.pow(base, fromIndex);
    
        const result: Record<string, string> = {
          standard: binary ? "Binary (1024)" : "SI (1000)",
        };
    
        for (let i = 0; i < units.length; i++) {
          const converted = bytes / Math.pow(base, i);
          result[units[i]] =
            converted >= 1
              ? converted.toLocaleString("en-US", { maximumFractionDigits: 4 })
              : converted.toExponential(4);
        }
    
        return {
          content: [
            { type: "text" as const, text: JSON.stringify(result, null, 2) },
          ],
        };
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/paladini/devutils-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server