Skip to main content
Glama

Convert broken JSON to valid JSON and check it on a schema

json_repair
Read-only

Repairs broken JSON: markdown fences, comments, trailing commas, single quotes, unquoted keys, Python literals (True, False, None) and truncated endings. Pure code first; the model is asked once only when code cannot repair it. Optional JSON Schema check covers type, required, properties, items, enum, minimum, maximum, minLength, maxLength and pattern. Input max 1 MB. Related tools on this server, for a different need: json_validate when you need to check JSON data against a JSON Schema. Price: $0.002 per successful call, paid with x402 (USDC on Base, Solana and 10 more networks); failed calls are not charged.

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 (max 1 MB)
schemaNoOptional JSON Schema to validate the repaired value against

Output Schema

NameRequiredDescriptionDefault
fixesNo
validNo
valueNo
problemsNo
checkedAtNo
usedModelNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changed
    • addedOutput schema / properties / checkedAt
      Added value: +{}
    • addedOutput schema / properties / fixes
      Added value: +{}
    • addedOutput schema / properties / problems
      Added value: +{}
    • addedOutput schema / properties / usedModel
      Added value: +{}
    • addedOutput schema / properties / valid
      Added value: +{}
    • addedOutput schema / properties / value
      Added value: +{}
  2. Added

TDQS

A4.6/5.0
Behavior5/5

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

Beyond the readOnlyHint/openWorldHint annotations, the description discloses the repair strategy (deterministic code, at most one model call), a hard input limit of 1 MB, the cost model ($0.002 per successful call via x402/USDC, failed calls free), and the schema keywords actually enforced. These are exactly the operational facts an agent needs before committing to a paid call.

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?

Repair capabilities are front-loaded in a single dense sentence, then escalation, schema support, limits, and the sibling disambiguation follow in logical order with no filler. The closing pricing sentence is long and carries network detail an agent may not need on every call, which is the only real slack.

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?

For a two-parameter tool with an output schema, the description covers the remaining gaps: what defects it fixes, the size ceiling, the cost and failure-charging behavior, and which sibling to prefer. Nothing material an agent needs to invoke it correctly is missing.

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%, so the schema already documents both the text and schema parameters, making 3 the baseline. The description adds some value by enumerating which JSON Schema keywords the check honors (type, required, properties, items, enum, minimum, maximum, minLength, maxLength, pattern), which tells the agent which schemas will actually be enforced, but it adds nothing about format or edge cases for the input text.

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?

The description names a specific verb (repairs) and resource (broken JSON) and enumerates the exact defect classes handled: markdown fences, comments, trailing commas, single quotes, unquoted keys, Python literals, truncated endings. It also explicitly separates itself from json_validate, so an agent can choose between them without opening either schema.

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

Usage Guidelines5/5

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

It states when to use a sibling instead: 'json_validate when you need to check JSON data against a JSON Schema', which is a concrete condition rather than a vague pointer. It also clarifies the internal escalation policy (code first, model asked once), so the agent knows it need not retry or pre-clean input.

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