Preserve dict output Field metadata#3042
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes MCPServer tool output-schema generation so that dict[str, T] return types preserve top-level Annotated[...] / Field(...) metadata (e.g., description) in the generated JSON schema, aligning dict outputs with other structured output return types.
Changes:
- Pass the original (potentially
Annotated) return annotation into thedict[str, T]RootModel creation path. - Add a regression test asserting that
Field(description=...)onAnnotated[dict[str, int], ...]appears inmeta.output_schema.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/mcp/server/mcpserver/utilities/func_metadata.py |
Ensures dict[str, T] structured output schema generation uses the original return annotation so Annotated/Field metadata is preserved. |
tests/server/mcpserver/test_func_metadata.py |
Adds a regression assertion that description is retained for Annotated[dict[str, T], Field(...)] outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
No issues found across 2 files
Tip: cubic could auto-approve low-risk PRs like this, if it thinks it's safe to merge. Learn more
Re-trigger cubic
|
Thanks for the PR. Tracking this in #2939 instead. Closing this as part of a wider backlog cleanup around the v2 release. If it's still relevant, feel free to reopen. |
Summary
Testing
Fixes #2935