Skip to main content
Glama

JSON repair for LLM output: fixes broken JSON and checks it against your schema

repair_json
Read-only

Turns messy LLM output into valid JSON: strips Markdown code fences and surrounding prose, fixes trailing commas, single quotes, unquoted keys, comments, Python True/None, cut-off brackets, and stringified JSON. Optionally validates the result against a JSON Schema (draft 4 to 2020-12) and lists each error with its location. Returns the parsed data, the JSON text, and what was changed. Not charged if no JSON can be recovered or the input is invalid. Paid via x402; see list_prices.

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": "repair_json"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYesThe broken JSON or LLM reply, up to 30,000 characters.
schemaNoOptional JSON Schema to validate the repaired data against.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only declare readOnlyHint and openWorldHint; the description goes well beyond by disclosing return contents (parsed data, JSON text, list of changes), validation scope (draft 4 to 2020-12), and billing behavior (not charged on unrecoverable/invalid input, paid via x402, refer to list_prices). This is unusually rich behavioral context for a read-only 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?

Front-loads the core capability, then nests repair specifics, validation, returns, and billing in tight clauses. No filler sentences; every clause carries actionable information.

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

Completeness5/5

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

With no output schema, the description compensates by naming the three return components and detailing failure/billing semantics. For a two-parameter utility with a nested optional schema object, an agent has everything needed to invoke it and interpret the result.

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 description coverage is 100%, so baseline is 3; the description adds value by explaining the 'schema' parameter accepts a JSON Schema for validation across drafts 4–2020-12. One caution: the schema's maxLength of 2048 conflicts with the param text 'up to 30,000 characters', an inconsistency the description does not resolve.

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?

States a specific verb and resource ('Turns messy LLM output into valid JSON') and enumerates the exact repair classes (fences, prose, trailing commas, single quotes, Python literals, cut-off brackets). An agent can immediately tell this is a JSON salvage/validation utility, distinct from any sibling.

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

Usage Guidelines4/5

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

Clear context for use ('messy LLM output', 'stringified JSON', 'cut-off brackets') and the optional validation path. It does not name a when-not condition or an alternative sibling, but none of the sibling tools (chain_*, check_*, read_*) overlap, so the guidance is adequate without routing.

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