Skip to main content
Glama

json_schema_validate

Validate LLM or agent JSON against a JSON Schema and automatically repair common formatting, type, enum, key, array, and default errors; returns errors, repaired JSON, and applied fixes.

Instructions

Validate LLM/agent JSON output against a JSON Schema (2020-12 subset) and auto-repair typical errors: code fences, trailing commas, numbers/booleans as strings, wrong enum case, single value instead of array, null optionals, extra or mis-cased keys, missing defaults. Returns errors, repaired JSON and fixes. POST recommended. Costs 0.001 USDC on Base per successful call (x402). Without a payment key this tool returns the 402 challenge.

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": {
      "schema": "<schema>",
      "data": "<data>"
    },
    "name": "json_schema_validate"
  }
}

Input Schema

NameRequiredDescriptionDefault
dataYesJSON value or string to check
repairNotrue (default) / false
schemaYesJSON Schema

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.0

TDQS

A3.9/5.0
Behavior4/5

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

With no annotations supplied, the description carries the full burden and does well: it discloses the repair catalog (code fences, trailing commas, stringified numbers, enum case, scalar-vs-array, null optionals, extra keys), that results come back as errors, repaired JSON and fixes, and the 0.001 USDC x402 cost plus 402 behavior without a payment key. What it omits is whether repair can silently alter semantic content or whether validation failures are returned rather than raised — meaningful for a mutating transform.

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 opening sentence is front-loaded with purpose and the repair list is compact, and the cost/payment caveat lands at the end where it belongs. The enumerated error classes are dense but each one is informative; only minor tightening (e.g. the trailing payment-key sentence) would improve it.

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 3-parameter tool with no output schema, the definition covers return shape (errors, repaired JSON, fixes), cost, and auth failure mode, which is most of what an agent needs. It stops short of stating what the unsupported remainder of JSON Schema means in practice or whether validation errors are surfaced in-band.

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 100%, so the baseline is 3; the parameter descriptions themselves are terse ("true (default) / false" as a string, "JSON Schema", "JSON value or string to check"). The description's repair catalog indirectly explains what enabling repair does, but it does not clarify the odd string-typed boolean or the supported schema subset boundaries beyond "2020-12 subset".

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 — validate LLM/agent JSON output against a JSON Schema — plus an auto-repair behavior, and lists the concrete error classes it handles. That detail separates it cleanly from the sibling validators (eori_validate, gtin_validate, isbn_validate), which target domain identifiers rather than arbitrary JSON payloads.

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

Usage Guidelines3/5

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

"POST recommended" and the note that a missing payment key yields a 402 challenge give operational context, and "LLM/agent JSON output" scopes the intended input. However, there is no explicit guidance on when to prefer this over another validator, nor any statement about when repair should be disabled or when validation would be inappropriate.

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