Python: Support MCP tool binding by reference in declarative YAML#5052
Open
hashwnath wants to merge 1 commit intomicrosoft:mainfrom
Open
Python: Support MCP tool binding by reference in declarative YAML#5052hashwnath wants to merge 1 commit intomicrosoft:mainfrom
hashwnath wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…crosoft#4927) Add binding resolution for McpTool in AgentFactory._parse_tool(), matching the existing FunctionTool pattern. MCP tools can now be resolved either by explicit bindings list or by matching the tool name against factory bindings, allowing pre-built MCP tool dicts to be passed via AgentFactory(bindings=...) instead of requiring full connection details in every YAML file. Fixes microsoft#4927
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.
Summary
Fixes #4927
AgentFactory._parse_tool()ignoresself.bindingsfor theMcpToolcase, unlikeFunctionToolwhere bindings correctly resolve the callable. This causes pre-built MCP tool dicts passed viaAgentFactory(bindings={"product-mcp": mcp_tool})to be silently ignored — the factory always constructs the tool from YAML fields, resulting inserver_url: ''and a 500 error when nourlis specified in the YAML.This PR adds binding resolution for
McpToolin_parse_tool(), mirroring the existingFunctionToolpattern:tool_resource.bindingslist againstself.bindingsdicttool_resource.namedirectly againstself.bindingskeysIf a binding resolves, the pre-built tool dict is returned directly. If no binding matches, the existing dict-building logic runs unchanged.
Changes
_loader.py: Added binding-by-reference resolution in theMcpToolcase of_parse_tool()test_declarative_loader.py: Added 4 tests:allowedTools, no url)Test plan
server_url: '')