Protocols

JSON Schema

JSON Schema describes and validates the structure of JSON values.

TypeValidInvalidcitystring"Pune"42daysinteger3"three"A schema states what valid JSON looks like.
JSON Schema describes and validates the structure of JSON values. Values shown in the worked visual are illustrative unless the labels state otherwise.

How it works

It can require fields, constrain types, and define nested alternatives. Validation catches malformed tool arguments before execution.

A concrete example

Illustrative: require city as a string and days as an integer from 1 through 10.

Do not confuse it with TypeScript type

JSON Schema validates runtime data; a TypeScript type is erased at runtime.

Study the full lesson