Skip to main content
Glama
paladini

devutils-mcp-server

json_format

Format JSON strings with customizable indentation or minify them for cleaner, more readable code.

Instructions

Format (pretty-print) a JSON string with configurable indentation. Can also minify JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputYesThe JSON string to format
indentNoNumber of spaces for indentation (0 = minify, default: 2)

Implementation Reference

  • The handler function for 'json_format' which takes the input JSON string and an optional indentation level, parses the input, and returns the formatted (or minified) JSON string.
    async ({ input, indent }) => {
      try {
        const parsed = JSON.parse(input);
        const formatted =
          indent === 0
            ? JSON.stringify(parsed)
            : JSON.stringify(parsed, null, indent);
        return { content: [{ type: "text" as const, text: formatted }] };
      } catch (e) {
        return {
          content: [
            {
              type: "text" as const,
              text: `Error: Invalid JSON — ${e instanceof Error ? e.message : String(e)}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema definition using Zod for 'json_format', defining the required input string and optional integer indent level.
    {
      input: z.string().describe("The JSON string to format"),
      indent: z
        .number()
        .int()
        .min(0)
        .max(8)
        .default(2)
        .describe("Number of spaces for indentation (0 = minify, default: 2)"),
    },
  • Registration of the 'json_format' tool in the MCP server using server.tool.
    server.tool(
      "json_format",
      "Format (pretty-print) a JSON string with configurable indentation. Can also minify JSON.",
      {
        input: z.string().describe("The JSON string to format"),
        indent: z
          .number()
          .int()
          .min(0)
          .max(8)
          .default(2)
          .describe("Number of spaces for indentation (0 = minify, default: 2)"),
      },
      async ({ input, indent }) => {
        try {
          const parsed = JSON.parse(input);
          const formatted =
            indent === 0
              ? JSON.stringify(parsed)
              : JSON.stringify(parsed, null, indent);
          return { content: [{ type: "text" as const, text: formatted }] };
        } catch (e) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error: Invalid JSON — ${e instanceof Error ? e.message : String(e)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, description carries full burden. It successfully discloses the minification behavior (indent=0) but fails to mention error handling for invalid JSON, idempotency, or the exact return type since no output schema exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences efficiently structured: first establishes core purpose (pretty-printing), second adds secondary capability (minifying). No redundancy or filler content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Appropriate for a simple 2-parameter utility with well-documented schema. Minor gap: lacks explicit mention of return value (formatted string) given no output schema exists, though this is strongly implied by the description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear descriptions. The description adds valuable semantic context by explicitly connecting the 'indent' parameter to the minification capability, explaining *why* you might adjust indentation beyond the mechanical schema definition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description uses specific verb 'Format (pretty-print)' with resource 'JSON string' and clearly distinguishes from siblings like json_validate (validation) and json_path_query (extraction) by focusing on presentation/transformation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides implied usage through functional description (formatting/minifying) but lacks explicit guidance on when to use vs. siblings like json_validate or json_path_query, and does not state prerequisites like valid JSON input.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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