Support specifying OutputSchema independently of return type for tools returning CallToolResult#1425
Open
Support specifying OutputSchema independently of return type for tools returning CallToolResult#1425
Conversation
…ToolAttribute Adds support for specifying the output schema type independently of the return type for tools returning CallToolResult. This allows developers to advertise a meaningful OutputSchema in tools/list while still having full control over the CallToolResult response (Meta, IsError, StructuredContent). - Add `JsonElement? OutputSchema` property to McpServerToolCreateOptions - Add `Type? OutputSchema` property to McpServerToolAttribute - DeriveOptions converts the attribute's Type to a JSON schema - CreateOutputSchema uses explicit OutputSchema over AIFunction's return schema - Add 13 comprehensive tests covering all variations Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Contributor
|
@halter73 / @mikekistler, I explored creating a |
stephentoub
reviewed
Mar 11, 2026
stephentoub
approved these changes
Mar 11, 2026
Copilot
AI
changed the title
[WIP] Support specifying OutputSchema type independently of return type
Support specifying OutputSchema independently of return type for tools returning CallToolResult
Mar 11, 2026
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Tools returning
CallToolResultdirectly (for control overMeta,IsError,StructuredContent) had no way to advertise a meaningfulOutputSchemaintools/list. The inferred schema would reflectCallToolResultitself rather than the actual structured content shape.Changes
McpServerToolCreateOptions: AddJsonElement? OutputSchemaproperty (pre-computed schema, included inClone())McpServerToolAttribute: AddType? OutputSchemaTypeproperty (converted to JSON schema viaAIJsonUtilities.CreateJsonSchemaduring option derivation)AIFunctionMcpServerTool.CreateOutputSchema: ExplicitOutputSchematakes precedence overAIFunction.ReturnJsonSchema; existing wrapping/normalization logic applies to both pathsUsage
UseStructuredContent = trueis still required forOutputSchema/OutputSchemaTypeto take effect.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.