Skip to main content
Glama

util_json_repair

Read-only

Repair broken JSON (offline, deterministic) — Fixes malformed JSON from LLMs and scrapers without AI: strips markdown code fences and surrounding prose, removes comments and trailing/extra commas, quotes unquoted keys and bare values, converts single quotes and smart quotes, Python/JS literals (True/False/None/undefined/NaN), hex and odd numbers, escapes raw newlines, inserts missing commas and closes unclosed strings and brackets. Returns the parsed json, compact or pretty (pretty=1) text and the list of fixes applied. 422 if nothing JSON-like is present. Cheaper, faster alternative to /v1/ai/json-repair. Price: $0.001 USDC (Base, via x402).

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": {
      "json": "<json>"
    },
    "name": "util_json_repair"
  }
}

Input Schema

NameRequiredDescriptionDefault
jsonYes{name: 'Ada', age: 36, tags: ['math','code',], active: True,}

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.5/5.0
Behavior5/5

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

Goes well past the annotations: it discloses the execution model (offline, no AI, deterministic), the failure mode (422 when nothing JSON-like is present), the access/payment requirement ($0.001 USDC on Base via x402), and the return shape (parsed JSON plus fix list). That is exactly the behavioral context annotations cannot carry. The only mild tension is "offline" against openWorldHint=true, but "without AI" makes the intent unambiguous.

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?

Front-loaded with the core action and elaborated in a single dense but scannable block; the long fix enumeration is largely justified by how much it clarifies input tolerance. It could be trimmed slightly, and the pricing/alternative notes are tucked at the tail rather than near the top.

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 no output schema, the description covers output shape, error behavior, cost, and execution model, which is close to complete. The remaining gap is the unresolved "pretty=1" flag, which the schema does not expose, leaving one documented capability without an obvious invocation path.

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 fully documented parameter, the baseline is 3; the description earns an extra point by spelling out the input dialect it tolerates, so the caller knows what shape of garbage is acceptable. It loses some credit for referencing "pretty=1" as a mode even though the schema exposes no such parameter, which leaves the caller unsure how to request pretty output.

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 ("Repair broken JSON") and then enumerates concrete defect classes it handles (code fences, comments, trailing commas, smart quotes, Python/JS literals, unclosed brackets). It explicitly names the sibling alternative ("Cheaper, faster alternative to /v1/ai/json-repair"), so an agent can distinguish it from ai_json_repair 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 Guidelines4/5

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

Gives a clear selection condition against the obvious alternative: use this when you want the offline, deterministic, cheaper path instead of the AI-based repair. It stops short of ruling out other siblings (util_json_validate, util_json_canonical) which an agent might pick for already-valid input, so it is clear but not complete on when-not-to-use.

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