GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing github.com — Give recursive tool return types an object-rooted output schema by maxisbey · Pull Request #3376 · modelcontextprotocol/python-sdk Conversation
Contributor
Fixes #3337 When a tool's return type is self-referential, pydantic emits the output schema as Motivation and ContextThe trigger is narrow (recursive The fix is unconditional rather than per-protocol-version: the schema is an object, pydantic just spells a recursive root as How Has This Been Tested?
Breaking ChangesNone. The only observable change is the JSON content of Types of changes
Checklist
Additional contextDeliberately out of scope: a A v1.x backport follows — v1 ships the same shape silently and strict clients reject it there too.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionspydantic emits a self-referential model as {"$defs": {...}, "$ref": "#/$defs/Model"}
with no type at the root. Tool.outputSchema requires type: object at the root on
2025-11-25 and earlier, so a single tool with a recursive return type failed the
entire tools/list result for every legacy-negotiated client.
Inline the referenced definition onto the root when the generated schema is a
bare local $ref, keeping $defs for the nested references. The shape is the same
on every protocol version.
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 issues found across 3 files
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
6 of 9 tasks
Uh oh!
There was an error while loading. Please reload this page.
Contributor
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. 🟡 _inline_root_ref assumes a root Extended reasoning...A tool returns a BaseModel whose schema is customized to carry a root Verification: nit — src/mcp/server/mcpserver/utilities/func_metadata.py:91
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Recursive tool return type publishes an outputSchema with no root type, failing tools/list on 2025-11-25 sessionsUh oh!
There was an error while loading. Please reload this page. 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. | ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |