Skip to content

Give recursive tool output schemas an object root (#3337) - #3340

Closed
AuraVox-ro wants to merge 1 commit into
modelcontextprotocol:mainfrom
AuraVox-ro:fix/3337-recursive-output-schema
Closed

Give recursive tool output schemas an object root (#3337)#3340
AuraVox-ro wants to merge 1 commit into
modelcontextprotocol:mainfrom
AuraVox-ro:fix/3337-recursive-output-schema

Conversation

@AuraVox-ro

Copy link
Copy Markdown

Fixes #3337

Recursive BaseModel tool return types made Pydantic emit a $ref-only root with no type: object. That serializes on 2026-07-28, but 2025-11-25 Tool.outputSchema requires an object root, so a legacy tools/list failed validation for the entire listing.

This inlines the referenced object definition at the root and keeps $defs so nested self-references still resolve.

Motivation and Context

See #3337. One recursive tool schema should not fail the entire tools/list for 2025-11-25 sessions.

How Has This Been Tested?

  • unit: test_structured_output_recursive_basemodel
  • integration: test_tool_recursive_output_schema_lists_on_legacy (Client mode=legacy plus a second unrelated tool)

Breaking Changes

None. Recursive output schemas gain a root type: object; nested $refs are unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I am assigned to the linked issue (or it is labeled help wanted, or I'm a maintainer)
  • I have disclosed any AI assistance and can explain the change in my own words
  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

AI-assisted. I own the change and can answer review questions.

…ol#3337)

Pydantic emits $ref-only roots for self-referential models, which fails 2025-11-25 tools/list validation. Inline the object definition at the root so legacy clients can list tools.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #3337.

If a maintainer would like this change as a PR from you, they'll assign you to #3337 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.)

There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten.

Maintainers: reopening this PR, removing the missing-issue-link label, or adding bypass-issue-check bypasses the check.

@github-actions github-actions Bot closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully 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 sessions

1 participant