Skip to main content
Glama

Repair broken JSON (LLM output)

json_repair
Read-onlyIdempotent

Fix malformed JSON typically produced by LLMs: code fences, leading prose, single quotes, unquoted keys, trailing commas, comments, Python True/False/None, NaN, missing closing brackets. Returns the parsed JSON and a list of fixes.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "text": "<text>"
    },
    "name": "json_repair"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYesThe broken JSON text

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, and closed-world, so the description doesn't need to re-establish safety. It does add value beyond them by disclosing the return contract (parsed JSON plus a list of fixes) and the breadth of tolerated defects; it omits what happens when input is unrepairable, which is the main remaining gap.

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, zero filler: the purpose leads, the defect list is compact and scannable, and the return contract closes it out.

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?

For a one-parameter utility with full schema coverage and read-only annotations, this is nearly complete — it covers what it fixes and what it returns. The only meaningful omission is failure behavior on irreparable input, which matters somewhat since there is no output schema.

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 coverage is 100% with a single required parameter, so the schema already defines 'text'. The description marginally enriches it by illustrating what 'broken' means, but adds no syntax or format guidance beyond that — baseline 3 applies.

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?

Names a specific verb and resource ('Fix malformed JSON') and enumerates the exact defect classes handled (code fences, trailing commas, Python literals, NaN, missing brackets), which clearly separates it from a plain validator such as json_validate.

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?

Usage is only implied by the enumeration of malformations — an agent can infer 'use this when the JSON won't parse.' There is no explicit when-to-use/when-not statement and no named alternative (e.g. json_validate for already-valid input) to route between.

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