-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(core,server,client): implement SEP-2106 (tool schemas conform to JSON Schema 2020-12) #2249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mattzcarey
wants to merge
19
commits into
main
Choose a base branch
from
feat/sep-2106-json-schema-2020-12
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8b631d2
feat(core,server,client): implement SEP-2106 JSON Schema 2020-12 tool…
mattzcarey 104ca37
fix(conformance): pass json-schema-ref-no-deref client scenario
mattzcarey 274786e
feat(core,server): default to Ajv2020 dialect + close SEP-2106 test gaps
mattzcarey eafccc5
fix(client): isolate per-tool outputSchema compile failures (PR #2249…
mattzcarey e291c7b
feat(core): opt-in external $ref resolver (SEP-2106 R-2106-10)
mattzcarey 0837580
fix(conformance): advertise raw 2020-12 schema in json-schema-2020-12…
mattzcarey b56bb80
fix(client): document runtime narrowing for structuredContent
mattzcarey 1b9c36d
fix(core): harden external ref resolver exports
mattzcarey 8a53ea0
fix(sep-2106): address validator review followups
mattzcarey 76f4b51
fix(docs): avoid typedoc links to internal ref defaults
mattzcarey de66d37
fix(core): handle data refs and relative schema refs
mattzcarey 862f446
fix(server): add structured content fallback without content
mattzcarey 058ef68
fix: preserve tool schema metadata across pagination
mattzcarey a8b74ea
fix(client): paginate tools listChanged refresh
mattzcarey 551a105
fix(core): normalize external ref host policy checks
mattzcarey 946137b
fix(core): avoid regex in host normalization
mattzcarey dc19947
fix(core): tolerate legacy tuple schemas
mattzcarey 06f9982
fix(core): align SEP-2106 with core-internal split
mattzcarey 327817c
fix(client): paginate prompt and resource list refresh
mattzcarey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| '@modelcontextprotocol/core': minor | ||
| '@modelcontextprotocol/server': minor | ||
| '@modelcontextprotocol/client': minor | ||
| --- | ||
|
|
||
| Implement SEP-2106: tool `inputSchema`/`outputSchema` conform to JSON Schema 2020-12, and `structuredContent` may be any JSON value. | ||
|
|
||
| - `inputSchema` still requires `type: "object"` at the root but now accepts any JSON Schema 2020-12 keyword (`oneOf`/`anyOf`/`allOf`/`not`, `if`/`then`/`else`, `$ref`/`$defs`/`$anchor`, …). | ||
| - `outputSchema` may now be **any** valid JSON Schema 2020-12 — objects, arrays, primitives, or compositions — instead of being restricted to `type: "object"`. | ||
| - `CallToolResult.structuredContent` widens from `{ [key: string]: unknown }` to `unknown`. **This is a source-breaking type change** for typed consumers: property access now requires a runtime narrowing guard before reading object properties. | ||
| - New `CallToolResultWithStructuredContent<T>` type for APIs whose output shape is known ahead of time (for example, server-side handlers typed from `outputSchema`). | ||
| - `McpServer.registerTool` type-checks a handler's returned `structuredContent` against the tool's `outputSchema` inferred output. | ||
| - Servers returning array or primitive `structuredContent` automatically also emit a serialized `TextContent` block, so pre-SEP clients can fall back to the text content. | ||
| - Built-in validators refuse to dereference non-same-document `$ref`/`$dynamicRef` (SSRF guard) and reject schemas exceeding depth / subschema-count bounds (composition-DoS guard). | ||
| - `Client.listTools()` no longer rejects when a single advertised tool's `outputSchema` fails to compile (e.g. it trips the safety guards above): the failure is scoped to the offending tool. Every other tool stays listable and callable; calling the offending tool throws a | ||
| descriptive error instead of silently skipping output validation. | ||
| - The default Node validator now uses `Ajv2020`, so the 2020-12 dialect is honored by default (previously `new Ajv()` ran draft-07 semantics and silently ignored keywords such as `prefixItems`). Both built-in validators now default to the `2020-12` dialect | ||
| (`MCP_DEFAULT_SCHEMA_DIALECT`). | ||
| - For compatibility with existing draft-07 tuple schemas, built-in validators using the default 2020-12 dialect normalize legacy `items: [...]` plus `additionalItems` syntax to the equivalent 2020-12 `prefixItems`/`items` form before compiling. New schemas should prefer | ||
| `prefixItems` directly. | ||
| - New opt-in `resolveExternalSchemaRefs(schema, options)` helper (the SEP's optional external-`$ref` mode): fetches and inlines non-local `$ref`s ahead of time into a self-contained schema. Disabled by default, enforces a host allowlist (and rejects loopback/link-local/private | ||
| targets otherwise), `https`-only by default, with fetch timeout / response-size / document-count limits, dereference logging, and fail-closed on unresolved references. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.