Skip to main content
Glama
Bristlecone2026

Bristlecone Logic Utilities

repair_json

Read-onlyIdempotent

Fixes malformed, truncated, or unclosed JSON strings from LLMs by deterministically parsing and repairing syntax errors, then returns valid JSON.

Instructions

Deterministically parses and repairs malformed, truncated, or unclosed JSON strings produced by LLMs (e.g. missing closing brackets, unescaped quotes, trailing commas). Returns parsed valid JSON object. Use when an LLM produces syntax-broken JSON. Do not use on valid non-JSON prose or for modifying data values.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
raw_jsonYesThe unparsed, malformed, or incomplete JSON text string requiring syntax repair into standard RFC 8259 format.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYes
repaired_jsonYes

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.3.0

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint, covering safety. The description adds valuable behavioral context beyond these: it states the tool is 'deterministically' repairing, which implies consistent output, and explicitly says it 'Returns parsed valid JSON object'—a behavioral trait not in the annotations. It does not describe failure behavior, but that is minor given the annotations and output schema.

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?

The description is a single, tightly packed sentence that front-loads the core function, immediately lists examples, and concludes with usage constraints. Every phrase earns its place with no fluff or repetition. It is concise and structurally ideal.

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 single-parameter tool with a 100% documented schema and an output schema present, the description is nearly complete. It covers purpose, usage boundaries, and examples. It omits edge-case behavior (e.g., what if repair fails), but that is typically captured by the output schema. Overall, the agent has sufficient information to invoke it correctly.

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 coverage is 100% (raw_json has a full description), so baseline is 3. The tool description adds meaningful semantic context by enumerating example malformations (missing brackets, unescaped quotes, trailing commas), which clarifies what kinds of inputs are expected beyond the schema's generic wording. This enrichment justifies a 4.

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 clearly states a specific verb+resource: it parses and repairs malformed/truncated/unclosed JSON strings. It lists concrete failure modes (missing closing brackets, unescaped quotes, trailing commas) and explicitly distinguishes from non-JSON use cases ('Do not use on valid non-JSON prose or for modifying data values'). This makes it unmistakably distinct from sibling tools like chunk_text or eval_expression.

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?

Provides explicit when-to-use guidance: 'Use when an LLM produces syntax-broken JSON' and a clear exclusion: 'Do not use on valid non-JSON prose or for modifying data values.' This directly tells an agent when to select this tool and when to avoid it, fully satisfying the usage criterion.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Bristlecone2026/bristlecone-logic'

If you have feedback or need assistance with the MCP directory API, please join our Discord server