Skip to main content
Glama

Format a JSON document

format_json
Read-only

Format (pretty-print or minify) a JSON document, optionally sorting object keys. Number literals are preserved exactly (64-bit IDs safe); parse errors report the exact line and column.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
jsonYesThe JSON text to format.
indentNoIndentation: '2' or '4' spaces, 'tab', or 'minify'. Defaults to '2'.
sort_keysNoSort object keys alphabetically. Defaults to false.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorYes"line L, col C: message" on a parse error, or null.
formatted_jsonNoThe formatted document. Absent when the input was refused.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "error": {
      +      "description": "\"line L, col C: message\" on a parse error, or null.",
      +      "type": [
      +        "string",
      +        "null"
      +      ]
      +    },
      +    "formatted_json": {
      +      "description": "The formatted document. Absent when the input was refused.",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "error"
      +  ],
      +  "type": "object"
      +}
  2. First observed

TDQS

A3.6/5.0
Behavior4/5

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

readOnlyHint=true already declares a safe read, but the description adds genuine value beyond annotations: lossless preservation of number literals (64-bit IDs safe) and precise line/column error reporting. These are non-obvious behavioral traits that materially affect how an agent trusts and calls the tool.

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 dense sentences, front-loaded with the core operation and then the two edge-case guarantees. No filler; every clause carries distinct information.

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?

With an output schema present and 100% parameter coverage, the description need not explain returns. It covers the operation, options, numeric fidelity, and error reporting, so it is nearly complete; the only real gap is the missing sibling/usage guidance.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents json, indent, and sort_keys fully. The description echoes pretty-print/minify and optional key sorting but adds no syntax or format detail beyond the schema, which is the expected baseline.

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

Purpose4/5

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

States a specific verb (format/pretty-print/minify) and resource (JSON document), so an agent immediately knows the operation. It does not, however, name or distinguish itself from the siblings format_code or ask_codefmt, leaving the JSON-vs-other-language split implicit.

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

Usage Guidelines2/5

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

There is no explicit when-to-use, when-not-to-use, or alternative routing despite two sibling tools (format_code, ask_codefmt) that plausibly overlap. The agent must infer that this is the JSON-specific formatter on its own.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources