-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Preamble
Title: Support full JSON Schema 2020-12
Co-author: John McBride - @jpmcb
Co-author: Ola Hungerford - @olaservo (adopted from #655 per #881 (comment))
Status: proposal
PR: #881
Abstract
There's a major discrepancy with how 2025-06-18
handles structuredContent
in relation to outputSchema
being defined as JSON Schema.
Because structuredContent
must be an object
, the types that can be returned by servers and validated by clients (like type: array
which is fully supported by JSON Schema but throws errors in Inspector, the Typescript-SDK, etc) is dramatically narrow.
Further, which draft of JSON Schema clients and servers use is not well defined leading to general drift among client, SDK, and server implementations. For example, JSON Schema specs in one client that uses JSON Schema draft-07
will be very different from another that uses 2020-12
.
Related:
outputSchema
does not fully support JSON Schema inspector#552- Tool
inputSchema
andoutputSchema
do not support JSON Schema typescript-sdk#685 - Support JSON Schema
allOf
,oneOf
, etc. inspector#496
This SEP loosens JSON schema usage across clients and servers as well as defines using JSON Schema 2020-12
Motivation
In 5.1 Data Types: Tool
, the spec states:
outputSchema
: Optional JSON Schema defining expected output structure
JSON Schema may be of type object
, array
, string
, null
, etc. etc. If it's valid JSON, then JSON Schema can validate it.
But the spec then goes on, in 5.2.6 Structured Content
, to state:
Structured content is returned as a JSON object in the
structuredContent
field of a result.
This represents a dramatic discrepency and severly limits what type of content can be returned by a server and validated in the structured content.
Consider the following valid JSON Schema:
{
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "A unique UUID"
}
},
"required": ["id"],
"additionalProperties": false
}
}
which defines an array of objects where the objects must have an id
property. This is pretty typical, especially in "list" type of operations.
Now, suppose a server responds with the following JSON as structured content:
[
{ "id": "abc123" },
{ "id": "xyz987" }
]
The spec would consider this structured content invalid and non-verifiable by the output schema.
Originally, the MCP specification didn't explicitly state which JSON Schema version to use for tool inputSchema
/outputSchema
and elicitation requestedSchema
, causing compatibility issues between implementations. Different clients and servers assume different versions, leading to validation failures and runtime errors. See: https://github.com/orgs/modelcontextprotocol/discussions/366 (discussion includes links to related issues)
(original context before merged with this SEP: #655)
Specification
- Clarifies JSON Schema dialect usage for embedded schemas within MCP messages by establishing
2020-12
as the default dialect and allowing explicit dialect declaration via the$schema
field. - Loosens
inputSchema
to be an object withtype: object
and any additional property to support JSON schema Draft2020-12
and more powerful validation compositions (likeanyOf
,oneOf
, etc.) - Loosens
outputSchema
to fully support JSON Schema2020-12
since MCP servers may return any valid JSON.- Loosens
structuredContent
to support any JSON validated byoutputSchema
's JSON Schema.
- Loosens
PR: #881
Backward Compatibility
No breaking changes.
Existing schemas without $schema will default to 2020-12
. Servers can optionally add $schema
to use other dialects.
Object schemas will continue to work as expected while the loosened specification can accept other valid JSON schema (like arrays of objects, etc.)
Rationale
The expectation is that any 2020-12
JSON Schema should be valid for fields that expect JSON schema. This includes outputSchema
and structuredContent
to be authentically validated by outputSchema
, not just expected to always be an object: this is far too strict and narrows how tools can respond in ways that backends may not conform to. Further, 2020-12
has been widely adopted by the industry as the current standard but servers can define the schema they expect via the $schema
metadata field.
Reference Implementation
TODO
Security Implications
There are no security implications.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status