Skip to content

Commit 8ad0ac7

Browse files
authored
Merge pull request modelcontextprotocol#655 from olaservo/clarify-json-schema-version
SEP-1613: Establish JSON Schema 2020-12 as Default Dialect for MCP
2 parents 5fa3143 + e9d025d commit 8ad0ac7

File tree

9 files changed

+984
-272
lines changed

9 files changed

+984
-272
lines changed

docs/specification/draft/basic/index.mdx

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ and instead retrieve credentials from the environment.
104104
Additionally, clients and servers **MAY** negotiate their own custom authentication and
105105
authorization strategies.
106106

107-
For further discussions and contributions to the evolution of MCPs auth mechanisms, join
107+
For further discussions and contributions to the evolution of MCP's auth mechanisms, join
108108
us in
109109
[GitHub Discussions](https://github.com/modelcontextprotocol/specification/discussions)
110110
to help shape the future of the protocol!
@@ -120,9 +120,61 @@ There is also a
120120
which is automatically generated from the TypeScript source of truth, for use with
121121
various automated tooling.
122122

123-
### General fields
123+
## JSON Schema Usage
124124

125-
#### `_meta`
125+
The Model Context Protocol uses JSON Schema for validation throughout the protocol. This section clarifies how JSON Schema should be used within MCP messages.
126+
127+
### Schema Dialect
128+
129+
MCP supports JSON Schema with the following rules:
130+
131+
1. **Default dialect**: When a schema does not include a `$schema` field, it defaults to JSON Schema 2020-12 (`https://json-schema.org/draft/2020-12/schema`)
132+
1. **Explicit dialect**: Schemas MAY include a `$schema` field to specify a different dialect
133+
1. **Supported dialects**: Implementations MUST support at least 2020-12 and SHOULD document which additional dialects they support
134+
1. **Recommendation**: Implementors are RECOMMENDED to use JSON Schema 2020-12.
135+
136+
### Example Usage
137+
138+
#### Default dialect (2020-12):
139+
140+
```json
141+
{
142+
"type": "object",
143+
"properties": {
144+
"name": { "type": "string" },
145+
"age": { "type": "integer", "minimum": 0 }
146+
},
147+
"required": ["name"]
148+
}
149+
```
150+
151+
#### Explicit dialect (draft-07):
152+
153+
```json
154+
{
155+
"$schema": "http://json-schema.org/draft-07/schema#",
156+
"type": "object",
157+
"properties": {
158+
"name": { "type": "string" },
159+
"age": { "type": "integer", "minimum": 0 }
160+
},
161+
"required": ["name"]
162+
}
163+
```
164+
165+
### Implementation Requirements
166+
167+
- Clients and servers **MUST** support JSON Schema 2020-12 for schemas without an explicit `$schema` field
168+
- Clients and servers **MUST** validate schemas according to their declared or default dialect. They **MUST** handle unsupported dialects gracefully by returning an appropriate error indicating the dialect is not supported.
169+
- Clients and servers **SHOULD** document which schema dialects they support
170+
171+
### Schema Validation
172+
173+
- Schemas **MUST** be valid according to their declared or default dialect
174+
175+
## General fields
176+
177+
### `_meta`
126178

127179
The `_meta` property/parameter is reserved by MCP to allow clients and servers
128180
to attach additional metadata to their interactions.

docs/specification/draft/schema.mdx

Lines changed: 6 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/specification/draft/server/tools.mdx

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,20 @@ A tool definition includes:
194194
- `title`: Optional human-readable name of the tool for display purposes.
195195
- `description`: Human-readable description of functionality
196196
- `inputSchema`: JSON Schema defining expected parameters
197+
- Follows the [JSON Schema usage guidelines](/specification/draft/basic#json-schema-usage)
198+
- Defaults to 2020-12 if no `$schema` field is present
199+
- **MUST** be a valid JSON Schema object (not `null`)
200+
- For tools with no parameters, use one of these valid approaches:
201+
- `{ "type": "object", "additionalProperties": false }` - **Recommended**: explicitly accepts only empty objects
202+
- `{ "type": "object" }` - accepts any object (including with properties)
197203
- `outputSchema`: Optional JSON Schema defining expected output structure
204+
- Follows the [JSON Schema usage guidelines](/specification/draft/basic#json-schema-usage)
205+
- Defaults to 2020-12 if no `$schema` field is present
198206
- `annotations`: optional properties describing tool behavior
199207

200208
<Warning>
201-
202-
For trust & safety and security, clients **MUST** consider
203-
tool annotations to be untrusted unless they come from trusted servers.
204-
209+
For trust & safety and security, clients **MUST** consider tool annotations to
210+
be untrusted unless they come from trusted servers.
205211
</Warning>
206212

207213
#### Tool Names
@@ -390,6 +396,56 @@ Providing an output schema helps clients and LLMs understand and properly handle
390396
- Guiding clients and LLMs to properly parse and utilize the returned data
391397
- Supporting better documentation and developer experience
392398

399+
### Schema Examples
400+
401+
#### Tool with default 2020-12 schema:
402+
403+
```json
404+
{
405+
"name": "calculate_sum",
406+
"description": "Add two numbers",
407+
"inputSchema": {
408+
"type": "object",
409+
"properties": {
410+
"a": { "type": "number" },
411+
"b": { "type": "number" }
412+
},
413+
"required": ["a", "b"]
414+
}
415+
}
416+
```
417+
418+
#### Tool with explicit draft-07 schema:
419+
420+
```json
421+
{
422+
"name": "calculate_sum",
423+
"description": "Add two numbers",
424+
"inputSchema": {
425+
"$schema": "http://json-schema.org/draft-07/schema#",
426+
"type": "object",
427+
"properties": {
428+
"a": { "type": "number" },
429+
"b": { "type": "number" }
430+
},
431+
"required": ["a", "b"]
432+
}
433+
}
434+
```
435+
436+
#### Tool with no parameters:
437+
438+
```json
439+
{
440+
"name": "get_current_time",
441+
"description": "Returns the current server time",
442+
"inputSchema": {
443+
"type": "object",
444+
"additionalProperties": false
445+
}
446+
}
447+
```
448+
393449
## Error Handling
394450

395451
Tools use two error reporting mechanisms:

0 commit comments

Comments
 (0)