---
title: "What is JSON Schema? How LLM tools and MCP use it"
description: "JSON Schema is a vocabulary for describing and validating JSON data. How tool calling, MCP inputSchema, and structured outputs use it, and which keywords work."
type: "glossary-term"
canonical_url: "https://theaiengineering.com/glossary/json-schema"
markdown_url: "https://theaiengineering.com/glossary/json-schema.md"
topic: "Prompt and context engineering"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
updated: "2026-11-06"
keywords: ["JSON Schema","JSON Schema 2020-12","inputSchema"]
citation: "The AI Engineering Editors. \"What is JSON Schema? How LLM tools and MCP use it.\" The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/json-schema"
---

# What is JSON Schema? How LLM tools and MCP use it

Also called JSON Schema 2020-12, inputSchema.

> **Definition of JSON Schema:** JSON Schema is a declarative vocabulary, itself written in JSON, for describing the structure of JSON data; LLM APIs and MCP use it to define tool arguments and constrain model output.

JSON Schema is a vocabulary for describing what valid JSON data looks like: which properties an object has, their types, which ones are required, and which values are allowed. A schema is itself a JSON document. The current version listed on [json-schema.org](https://json-schema.org/specification) is 2020-12, published as a Core specification and a Validation specification. In AI engineering, JSON Schema is the shared language for tool parameters: model APIs use it to describe tools to the model in [tool calling](https://theaiengineering.com/glossary/tool-calling), and MCP servers use it to declare each tool's inputs and outputs.

## How JSON Schema works

A JSON Schema works as a set of keywords, each constraining one aspect of a JSON value. `type` restricts the JSON type, `properties` describes each field of an object, `required` lists the fields that must be present, and keywords such as `enum`, `pattern`, `minimum`, and `maxItems` narrow the allowed values. A validator checks a value against every keyword.

A typical tool argument schema:

```json
{
  "type": "object",
  "properties": {
    "city": { "type": "string", "description": "City name, such as Lisbon" },
    "units": { "type": "string", "enum": ["metric", "imperial"] },
    "days": { "type": "integer", "minimum": 1, "maximum": 7 }
  },
  "required": ["city"],
  "additionalProperties": false
}
```

Validators ignore annotation keywords such as `description`, but a model reads a field's description as guidance for filling it, so field descriptions are part of the prompt. `$defs` and `$ref` let a schema reuse subschemas, and `$schema` declares which dialect a schema follows.

The [Model Context Protocol](https://theaiengineering.com/glossary/model-context-protocol) makes JSON Schema mandatory for tools. The [MCP base protocol](https://modelcontextprotocol.io/specification/2026-07-28/basic) says a schema without a `$schema` field defaults to 2020-12, implementations must support at least that dialect, and they must not automatically dereference a `$ref` that points to a network URI. Every tool's `inputSchema` must be a valid schema object; a tool with no parameters should use `{ "type": "object", "additionalProperties": false }`. An optional `outputSchema` describes the tool's `structuredContent`. Revision 2026-07-28 loosened both fields to accept any 2020-12 keyword. MCP SDKs usually generate these schemas from code, such as Python type hints or Zod definitions in TypeScript.

## JSON Schema vs structured outputs

JSON Schema is a description language; [structured outputs](https://theaiengineering.com/glossary/structured-outputs) is a model API feature that uses a JSON Schema to constrain what the model generates. A validator checks JSON after it exists, while constrained decoding blocks invalid tokens during generation. Providers support only a subset of JSON Schema for constrained decoding.

| | JSON Schema validation | Structured outputs |
|---|---|---|
| When it runs | After the JSON exists | During generation |
| Keywords | Everything in the declared dialect | A provider-defined subset |
| On a mismatch | Reports errors; the caller retries | Invalid tokens are never generated |
| Typical use | MCP tool inputs, API payloads, config files | Model responses and strict tool arguments |

OpenAI's [supported schemas](https://developers.openai.com/api/docs/guides/structured-outputs) section shows how large the gap is. Structured Outputs accepts string, number, boolean, integer, object, array, enum, and `anyOf`, with `pattern` and `format` for strings, range and `multipleOf` keywords for numbers, and `minItems` and `maxItems` for arrays. Every field must be listed in `required`, with optional fields written as a union with `null`, and every object needs `additionalProperties: false`. The root must be an object, not `anyOf`. A schema may have up to 5,000 object properties and 10 levels of nesting, and `allOf`, `not`, `if`, `then`, `else`, `dependentRequired`, and `dependentSchemas` are not supported. Definitions and recursive schemas are allowed.

The gap matters when one schema feeds several consumers. A schema that MCP accepts as an `inputSchema` can still be rejected by a provider's strict mode if it uses `allOf` or a conditional. Write tool schemas for the strictest consumer, and keep validation in code for business rules that no schema expresses.

[Tool calling](https://theaiengineering.com/articles/tool-calling) shows how schemas shape tool definitions and strict mode.

## Related terms

- [Structured outputs](https://theaiengineering.com/glossary/structured-outputs): Structured outputs is an LLM API feature that constrains generation so the model's response always conforms to a developer-supplied JSON Schema, producing output that code can parse without retries.
- [Tool calling](https://theaiengineering.com/glossary/tool-calling): Tool calling is an LLM capability in which the model, given a list of tool definitions, outputs a structured request naming a tool and its arguments, which the application executes and returns.
- [Model Context Protocol (MCP)](https://theaiengineering.com/glossary/model-context-protocol): Model Context Protocol (MCP) is an open protocol, introduced by Anthropic in November 2024, that standardizes how AI applications connect to external tools, data sources, and prompts through MCP servers.
- [MCP server](https://theaiengineering.com/glossary/mcp-server): An MCP server is a program that exposes tools, resources, and prompts to AI applications through the Model Context Protocol, running locally over stdio or remotely over Streamable HTTP.
- [JSON-RPC](https://theaiengineering.com/glossary/json-rpc): JSON-RPC is a lightweight, transport-agnostic remote procedure call protocol that encodes method calls, results, and errors as JSON objects; version 2.0 is the message format of MCP and A2A.

## Guides that cover json schema

- [A2A protocol vs MCP: differences and when to use each](https://theaiengineering.com/articles/a2a-vs-mcp): A2A protocol vs MCP: A2A connects AI agents to other agents, and MCP connects an agent to tools and data. Compare agent cards, tasks, transports, and security.
- [How to build an MCP server: a Python and TypeScript tutorial](https://theaiengineering.com/articles/how-to-build-an-mcp-server): Learn how to build an MCP server with the official Python and TypeScript SDKs: tools, resources, transports, testing, client config, and production security.
- [How to build an AI agent: a step-by-step guide in Python](https://theaiengineering.com/articles/how-to-build-an-ai-agent): Learn how to build an AI agent from scratch in Python: when you need one, tool schemas, the agent loop, stop conditions, guardrails, evals, and tracing.
- [What is tool calling? How LLM function calling works](https://theaiengineering.com/articles/tool-calling): Tool calling lets an LLM request actions from your code through structured calls. Learn the request loop, parallel calls, structured outputs, security, and MCP.
- [What is the Model Context Protocol (MCP)? How it works](https://theaiengineering.com/articles/what-is-model-context-protocol): The Model Context Protocol (MCP) is an open standard for connecting AI apps to tools and data. Learn its architecture, transports, tool calls, and security.
- [vLLM vs Ollama vs llama.cpp vs SGLang: which engine to use](https://theaiengineering.com/articles/vllm-vs-ollama): vLLM vs Ollama compared with llama.cpp, SGLang, LM Studio, and TensorRT-LLM: scope, hardware, APIs, concurrency, and which engine fits local or production use.
- [LLM benchmarks explained: what they measure and how to read them](https://theaiengineering.com/articles/llm-benchmarks): LLM benchmarks explained: what MMLU-Pro, GPQA, SWE-bench, LiveCodeBench, ARC-AGI, and LMArena measure, why scores saturate, and how to read a leaderboard.
- [LLM evaluation: a practical guide to evals, metrics, and judges](https://theaiengineering.com/articles/llm-evaluation): LLM evaluation for engineers: build eval datasets, pick metrics, calibrate LLM-as-a-judge, evaluate RAG and agents, and gate every release in CI.
- [AI engineer roadmap: skills, projects, and resources by stage](https://theaiengineering.com/articles/ai-engineer-roadmap): A practical AI engineer roadmap in seven stages, each with the skills to learn, a project to ship, and resources worth the time, from Python to production.
- [What are AI agents? How agents work and when to use one](https://theaiengineering.com/articles/what-are-ai-agents): AI agents are LLM systems that call tools in a loop until a task is done. Learn how the loop works, agents vs agentic AI, examples, failure modes, and limits.

Part of the [Prompt and context engineering](https://theaiengineering.com/topics/prompt-engineering) topic hub.

## Cite this definition

The AI Engineering Editors. "What is JSON Schema? How LLM tools and MCP use it." The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/json-schema

- Title: What is JSON Schema? How LLM tools and MCP use it
- Author: The AI Engineering Editors
- Publisher: The AI Engineering
- Updated: 2026-11-06
- URL: https://theaiengineering.com/glossary/json-schema
- Markdown: https://theaiengineering.com/glossary/json-schema.md
