Skip to main content
Glama

JSON repair: fix broken JSON

json_repair
Read-only

Fix JSON as LLMs often write it: removes json fences and surrounding prose, comments and trailing commas, converts single quotes, quotes bare keys, maps True/False/None, and closes unclosed brackets. Returns the repaired JSON and whether it now parses. Use when an LLM's JSON output fails to parse. Example: text=json {name: 'Ada', tags: ['x',],}

Input Schema

NameRequiredDescriptionDefault
textYesThe broken JSON text

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added
  2. Removed
  3. Added

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false and openWorldHint=true, so 'reads or computes only and changes nothing' is mostly redundant. The description adds genuinely non-redundant behavior: per-call pricing, first 25 free, failed calls free, and 'each call is charged, so repeats are not free', which explains the idempotentHint=false annotation in practical terms.

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

Conciseness4/5

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

The repair list and usage trigger are front-loaded in the first two sentences, so the critical information is reached immediately. The billing/pricing tail is longer than strictly needed for tool selection, though it is operationally relevant.

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?

Even without an output schema, the description says what comes back ('the repaired JSON and whether it now parses'), what happens on failure (failed calls free), and confirms no side effects. Nothing an agent needs in order to call this one-parameter tool correctly is missing.

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?

With one parameter at 100% schema coverage the baseline is 3, and the description adds real value by showing a sample of the 'text' payload (```json fences, single-quoted keys, trailing commas) that demonstrates accepted input rather than just naming the field.

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 concrete verb+resource ('Fix JSON') and then enumerates the exact failure modes it repairs: fences, prose, comments, trailing commas, single quotes, bare keys, True/False/None, unclosed brackets. The clause 'Use when an LLM's JSON output fails to parse' implicitly separates it from json_format/json_validate, which handle well-formed input.

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?

Gives an explicit trigger condition — 'Use when an LLM's JSON output fails to parse' — plus a worked example of the input shape it targets. It does not name the closest siblings (json_validate, json_format) as alternatives, so the agent must infer that valid JSON should go elsewhere.

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.