Skip to main content
Glama
mcp-ml-tools
by adeoluo

Validate JSON against a JSON Schema

json_schema_validate
Read-onlyIdempotent

Validate JSON documents or raw LLM output against a JSON Schema, returning precise JSON Pointer and JSONPath errors or parse error line and column.

Instructions

Validates a JSON document (or raw model output text, optionally wrapped in a Markdown code fence) against a JSON Schema using Ajv with formats. Returns every error with a JSON Pointer and JSONPath to the offending value, or the line and column of a parse error. Supports draft-07, 2019-09, and 2020-12 (detected from $schema).

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

Input Schema

NameRequiredDescriptionDefault
draftNoOverride draft detection
schemaYesThe JSON Schema
documentNoParsed JSON value to validate
maxErrorsNoMaximum errors (default 50)
documentTextNoRaw JSON text to parse then validate (for example an LLM response)
stripCodeFencesNoStrip a surrounding ``` fence (default true)

Output Schema

NameRequiredDescriptionDefault
draftYes
validYes
errorsYes
errorCountYes
parseErrorNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.2.2

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare this a read-only, idempotent, closed operation, so the safety profile is covered. The description adds real behavior beyond that: draft detection from $schema, code-fence tolerance, JSON Pointer/JSONPath error locations, and line/column reporting for parse failures. It does not say what happens if both `document` and `documentText` are supplied, which is the one notable behavioral gap.

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, then the output contract, then the supported dialects. No filler, and each clause carries information an agent would otherwise have to guess.

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?

With an output schema present, the return values need not be restated, and the description still summarizes error shape helpfully. It covers both input modes and dialect support; the only missing piece for a 6-parameter validator is the mutual exclusivity/precedence of `document` vs `documentText`.

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 description coverage is 100%, so a baseline of 3 is warranted; the description earns an extra point by tying concepts to parameters — code-fence wrapping maps to `stripCodeFences` and $schema detection maps to `draft` as an override. It still gives no guidance on `maxErrors` truncation behavior or precedence between the two document inputs.

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 ("Validates a JSON document ... against a JSON Schema") plus the engine (Ajv with formats) and the two accepted input modes. An agent can immediately tell this is a schema-validation tool, distinct from the sibling search/scan/tokenize utilities.

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?

Usage is implied rather than stated: the parenthetical "(for example an LLM response)" signals that documentText is for raw model output, which guides the choice between the two input modes. However, there is no explicit when-to-use/when-not statement and no mention of how to decide between `document` and `documentText` when both could apply.

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