-
Notifications
You must be signed in to change notification settings - Fork 711
Relax outputSchema to any JSON Schema 2020-12 document per SEP-2106 #1568
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
jayaraman-venkatesan
wants to merge
5
commits into
modelcontextprotocol:main
Choose a base branch
from
jayaraman-venkatesan:feature/sep-2106-output-schema-relaxation
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.
+622
−56
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
126d712
feat(feature/sep-2106-output-schema-relaxation): relax outputSchema t…
jayaraman-venkatesan cb2c315
Merge branch 'main' into feature/sep-2106-output-schema-relaxation
jayaraman-venkatesan c30725c
fix(feature/sep-2106-backward-compat): preserve pre-2026-06-30 wire s…
jayaraman-venkatesan 614f19f
Merge branch 'main' into feature/sep-2106-output-schema-relaxation
jayaraman-venkatesan f8f235c
Merge branch 'main' into feature/sep-2106-output-schema-relaxation
jayaraman-venkatesan 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
|
|
@@ -80,17 +80,20 @@ public JsonElement InputSchema | |
| } = McpJsonUtilities.DefaultMcpToolSchema; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets a JSON Schema object defining the expected structured outputs for the tool. | ||
| /// Gets or sets a JSON Schema document describing the shape of the tool's structured output. | ||
| /// </summary> | ||
| /// <exception cref="ArgumentException">The value is not a valid MCP tool JSON schema.</exception> | ||
| /// <exception cref="ArgumentException">The value is not a JSON object.</exception> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// The schema must be a valid JSON Schema object with the "type" property set to "object". | ||
| /// This is enforced by validation in the setter which will throw an <see cref="ArgumentException"/> | ||
| /// if an invalid schema is provided. | ||
| /// Per SEP-2106 ("Allow valid JSON Schemas in <c>outputSchema</c>"), the schema may describe | ||
| /// any JSON value — object, array, string, number, boolean, or <see langword="null"/> — to | ||
| /// support tools whose structured output is not an object. The setter only validates that the | ||
| /// supplied value is a JSON object (a schema document); deeper keyword-level validation is | ||
| /// intentionally not performed. | ||
| /// </para> | ||
| /// <para> | ||
| /// The schema should describe the shape of the data as returned in <see cref="CallToolResult.StructuredContent"/>. | ||
| /// The schema describes the shape of the value placed in <see cref="CallToolResult.StructuredContent"/>. | ||
| /// Unlike <see cref="InputSchema"/>, the top-level <c>type</c> is no longer required to be <c>"object"</c>. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "no longer" seems unnecessary, especially to someone who may be reading this documentation without knowledge of the prior design. |
||
| /// </para> | ||
| /// </remarks> | ||
| [JsonPropertyName("outputSchema")] | ||
|
|
@@ -99,9 +102,9 @@ public JsonElement? OutputSchema | |
| get => field; | ||
| set | ||
| { | ||
| if (value is not null && !McpJsonUtilities.IsValidMcpToolSchema(value.Value)) | ||
| if (value is not null && !McpJsonUtilities.IsValidJsonSchemaDocument(value.Value)) | ||
| { | ||
| throw new ArgumentException("The specified document is not a valid MCP tool output JSON schema.", nameof(OutputSchema)); | ||
| throw new ArgumentException("The specified document is not a valid JSON Schema document (must be a JSON object).", nameof(OutputSchema)); | ||
| } | ||
|
|
||
| field = value; | ||
|
|
||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method should be named
IsValidToolOutputSchema, since it is designed specifically to validate tool output schemas and not any JSON Schema document.I think we may also need to make this conditional on the protocol version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the function.
About version control here, I did not make that change to keep tools contain schema per SEP-2106. But serving of schema on
tools/callandtools/listmake the decision of wrapping depending on negotiated protocol version