Skip to main content
Glama

json_repair

Repair broken or LLM-generated JSON by fixing code fences, comments, trailing commas, single quotes, bare keys and truncation, then optionally validate it against a JSON Schema subset.

Instructions

Repair broken or LLM-produced JSON (code fences, comments, trailing commas, single quotes, bare keys, truncation) and optionally validate against a JSON Schema subset. Free, deterministic.

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
textYes
schemaNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.1/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full load; 'Free, deterministic' usefully rules out side effects and nondeterminism, and 'subset' honestly bounds the schema-validation claim. It never says what happens on failure — whether repair returns partial output, throws, or reports diagnostics, nor whether truncation recovery is lossy — which matters for an LLM-facing repair utility.

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, front-loaded with the core action and its defect list, then the optional mode and a cost guarantee. No filler, and the parenthetical enumeration does real work rather than padding.

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 utility with no output schema and no annotations, the definition covers what it does, what inputs it takes, the optional mode, and the determinism/cost guarantee — enough to invoke it correctly.

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 description coverage is 0% for two parameters, so the description must compensate. It implies 'text' is the JSON to repair and 'schema' is a JSON Schema, and the word 'subset' meaningfully narrows the schema parameter's accepted dialect — but it never says how validation outcomes are surfaced or whether the schema argument changes the return shape, leaving the nested object parameter under-explained.

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 and resource ('Repair ... JSON') and enumerates concrete defect classes it handles (code fences, comments, trailing commas, single quotes, bare keys, truncation), plus an optional schema-validation mode. Neither of the sibling tools (routing, catalog, page conversion) overlaps, so the agent can rule it in or out on the first sentence.

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?

'Repair broken or LLM-produced JSON' gives a clear triggering condition, and 'optionally validate against a JSON Schema subset' signals the second mode is opt-in. It does not state when-not to use it or what to do when JSON is unrecoverable, but for a narrowly scoped utility the context is unambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.