Repository navigation
fix(mcpserver): handle bare typing.Dict and typing sequence generics in func_metadata - #3772
chauvuusvn wants to merge 1 commit into
Conversation
…onsistently in func_metadata
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3771. If a maintainer assigns you to #3771, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Fixes #3771
Motivation and Context
In
src/mcp/server/mcpserver/utilities/func_metadata.py, return type inspection behaved inconsistently for unsubscriptedtypinggeneric counterparts compared to standard built-in types:typing.Dict:get_origin(typing.Dict)isdictbutget_args(typing.Dict)is(). It fell through thelen(args) == 2check into theelsebranch, mistakenly forcingwrap_output = True(wrapped in{"result": ...}) instead of being treated as a top-level JSON object likedictordict[str, Any].typing.List/typing.Tuple:typing.List in (list, tuple)evaluates toFalse, bypassing the opt-out gate at line 449 and unintentionally producing a wrapped Pydantic output model.How Has This Been Tested?
tests/server/mcpserver/test_func_metadata.py:func_bare_typing_dictverifyingoutput_schemais a partial object dict andwrap_outputisFalse.test_bare_typing_sequence_opts_out_of_structured_outputverifyingmeta.output_schema is Noneforlist,typing.List,tuple, andtyping.Tuple.test_func_metadata.pypass.Breaking Changes
None. This aligns unsubscripted
typinggenerics (typing.Dict,typing.List,typing.Tuple) with standard Pythondict,list,tuplebehavior.Types of changes
Checklist
help wanted, or I'm a maintainer)