DS DevShelfHub Projects · AI tools
Tutorials / MCP / Schema
MCP Intermediate · 7 min read Page 15 of 23

JSON Schema in MCP

By DevShelfHub

Every tool input, elicitation form, and structured output uses JSON Schema. MCP picked 2020-12 as the default dialect and adds a few constraints to keep schemas tractable across SDKs.

Series progress15 / 23
JSON Schema in MCP tutorial — JSON Schema in MCP

Default dialect: 2020-12 (SEP-1613)

Omitting $schema means 2020-12 — the modern, more expressive vocabulary. Need legacy? Set $schema to draft-07 explicitly.

Default (2020-12)

{ "type": "object", "properties": { ... } }

Explicit draft-07

{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object" }

PrimitiveSchemaDefinition (for elicitation)

Elicitation forms restrict properties to primitives — keeping form UIs tractable. The union:

TypeNotable fields
StringSchemaminLength, maxLength, format ("uri" | "email" | "date" | "date-time"), default
NumberSchemaminimum, maximum, integer vs number, default
BooleanSchemadefault
EnumSchemaenum, items.enum (multi-select), default, minItems/maxItems

EnumSchema variants (SEP-1330)

Untitled single-select

{ "type": "string", "enum": ["small", "medium", "large"] }

Untitled multi-select

{ "type": "array", "items": { "type": "string", "enum": ["a","b"] }, "minItems": 1 }

Tool input/output schemas

Tool inputSchema and outputSchema are full JSON Schema — nested objects, arrays, refs, conditional logic all allowed. The constraint to primitives only applies to elicitation.

tool with rich schema
{
  "name": "create_invoice",
  "inputSchema": {
    "type": "object",
    "properties": {
      "customer": { "type": "object", "properties": { "id": {"type": "string"} }, "required": ["id"] },
      "lines": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": { "description": {"type": "string"}, "amount": {"type": "number"} },
          "required": ["description", "amount"]
        },
        "minItems": 1
      }
    },
    "required": ["customer", "lines"]
  }
}

Validation errors as tool errors (SEP-1303)

When inputs fail validation, return isError: true in CallToolResult with a helpful message. The LLM can read it and retry with corrected arguments — far better UX than a JSON-RPC error.

Quick summary

  • Default dialect: JSON Schema 2020-12; opt out to draft-07 if you must
  • Elicitation properties are limited to primitives (string, number, boolean, enum)
  • Tool schemas are full JSON Schema — go nuts
  • Validation failures belong in isError, not JSON-RPC errors

JSON Schema in MCP FAQ

Which JSON Schema dialect does MCP use?

MCP uses JSON Schema 2020-12 as its default dialect for tool input schemas and form fields. Schemas should include a $schema declaration pointing to the 2020-12 meta-schema for unambiguous validation.

What is PrimitiveSchemaDefinition in MCP?

PrimitiveSchemaDefinition is MCP's restricted schema subset for elicitation form fields. It supports only primitive types (string, number, integer, boolean) plus arrays and objects of primitives — keeping forms simple enough for any client to render.

What is EnumSchema in MCP?

EnumSchema is a variant of PrimitiveSchemaDefinition for fields with a fixed set of allowed values. Use it to present dropdown or radio-button options in elicitation forms, ensuring users can only submit valid values.

Can MCP tool schemas use all JSON Schema features?

Tool inputSchema fields can use most JSON Schema 2020-12 features. However, highly complex schemas (deep $ref chains, $dynamicRef) may not be supported by all SDKs. Stick to common keywords (type, properties, required, enum, minimum, maximum) for maximum compatibility.

How do default values work in MCP schemas?

You can add a default keyword to any schema field to indicate its default value. MCP itself does not enforce defaults — the server or SDK is responsible for applying them when a parameter is omitted by the caller.

Quick jump:API Reference