Skip to main content
Glama

Infer a JSON Schema from samples

ai_json_schema_infer
Read-onlyIdempotent

Generate a JSON Schema (draft 2020-12) from sample JSON, JSONL, or files by inferring types, nullability, required keys, formats, and enums.

Instructions

Generate a JSON Schema (draft 2020-12) from one or more sample JSON values: types (integer vs number, mixed types as a type list), "null" added where a value can be null, required = keys present in every sample object, array items merged across all elements, string formats guessed when every sample matches (date-time, date, email, uri, uuid), and optional enums for small repeated string sets. Give "samples" (an array of sample values), or "text" (JSON, or JSONL = one sample per line), or "file" (path or base64 of a .json/.jsonl file). An array sample describes an array; to treat its elements as separate samples set eachItem. Pure local code; optionally writes the schema to "output".

Input Schema

NameRequiredDescriptionDefault
fileNoOr: a .json/.jsonl file (local path or base64).
textNoOr: JSON text (one sample) or JSONL (one sample per line).
enumsNoEmit "enum" for string fields with few distinct values that repeat. Default false.
titleNoOptional "title" for the schema.
outputNoOptional: also write the schema as a .json file here.
formatsNoGuess string formats (default true).
samplesNoSample values; each element is one sample.
eachItemNoIf the only sample is an array, use its elements as the samples (schema of one record). Default false.
requiredNoList keys present in every sample as "required" (default true).
maxEnumValuesNoLargest string set turned into an enum (default 8).
additionalPropertiesNofalse adds additionalProperties: false to every object (strict). Default true (left open).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

B3.3/5.0
Behavior1/5

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

The annotations declare readOnlyHint=true, but the description says the tool can optionally write the schema to an output file. Writing a file is a side effect, directly contradicting the readOnlyHint annotation.

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 definition is dense but front-loaded, starting with the core generation behavior and then covering inference rules. It earns most of its length, though it could be more clearly structured for an 11-parameter tool.

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?

The description covers input modes, inference behavior, and optional output for a complex tool with no output schema. It is nearly complete, but it does not explicitly state the exact return shape and includes the readOnly contradiction.

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 every parameter is already documented in the input schema. The description adds useful behavioral context around sample interpretation and eachItem, but most of the parameter semantics are already present in the schema.

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 states a specific verb and resource: generate a JSON Schema from sample JSON values. It is clearly distinguishable from the sibling ai_json_schema_validate, which would validate rather than infer a schema.

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 by the purpose: supply sample JSON and receive an inferred schema. However, the description never explicitly says when to choose this over ai_json_schema_validate or what inputs are unsuitable.

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

Deploy Server

Other Tools