Python: Fix MCP tool calls sending empty arguments when inputSchema lacks properties#3861
Closed
giles17 wants to merge 2 commits intomicrosoft:mainfrom
Closed
Python: Fix MCP tool calls sending empty arguments when inputSchema lacks properties#3861giles17 wants to merge 2 commits intomicrosoft:mainfrom
giles17 wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Member
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes MCP tool invocation dropping tool-call arguments when an MCP server returns an inputSchema without properties (e.g., {"type":"object"}), by ensuring the dynamically generated Pydantic input model preserves extra fields.
Changes:
- Update JSON-schema → Pydantic model generation to allow extra fields when
propertiesis missing/empty. - Add a regression test intended to ensure MCPStreamableHTTPTool forwards arguments for schemas without
properties.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
python/packages/core/agent_framework/_tools.py |
Generates Pydantic models with extra="allow" for schemas missing/empty properties, preventing argument loss during model_validate/model_dump. |
python/packages/core/tests/core/test_mcp.py |
Adds a regression test covering MCP tool schemas without properties / with empty properties. |
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.
Fixes a bug where
MCPStreamableHTTPTool(and other MCP tool types) sends empty{}arguments to the MCP server when the server'sinputSchemahas nopropertieskey (e.g.,{"type": "object"}).Motivation and Context
Description
Contribution Checklist