Python: Fix local MCP tools with AzureAIProjectAgentProvider#3315
Merged
giles17 merged 2 commits intomicrosoft:mainfrom Jan 21, 2026
Merged
Python: Fix local MCP tools with AzureAIProjectAgentProvider#3315giles17 merged 2 commits intomicrosoft:mainfrom
AzureAIProjectAgentProvider#3315giles17 merged 2 commits intomicrosoft:mainfrom
Conversation
AzureAIProjectAgentProviderAzureAIProjectAgentProvider
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where local MCP tools (MCPTool) were not working with AzureAIProjectAgentProvider. The Azure AI Responses API requires tools to be defined on the agent at creation time, but local MCP tools were being filtered out because the system only recognized HostedMCPTool instances.
Changes:
- Modified
create_agentto detect and connect MCP tools before agent creation, extracting their functions for Azure AI - Updated
_merge_toolsto include MCPTool instances alongside AIFunction instances for ChatAgent runtime handling - Added comprehensive unit tests covering MCP tool integration scenarios
- Updated the sample to demonstrate proper MCP tool usage with context manager pattern
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/azure-ai/agent_framework_azure_ai/_project_provider.py | Core fix: Separates MCP tools from other tools, connects them early to discover functions, and passes functions to Azure AI while preserving original MCP tool instances for ChatAgent |
| python/packages/azure-ai/tests/test_provider.py | Adds MockMCPTool helper class and two comprehensive test cases validating MCP tool connection and function discovery |
| python/samples/getting_started/agents/azure_ai/azure_ai_with_local_mcp.py | Updates sample to extract MCP tool initialization and adds agent context manager for proper cleanup (contains duplicate print statement) |
python/samples/getting_started/agents/azure_ai/azure_ai_with_local_mcp.py
Outdated
Show resolved
Hide resolved
dmytrostruk
approved these changes
Jan 21, 2026
markwallace-microsoft
approved these changes
Jan 21, 2026
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…soft#3315) * azureai v2 local mcp fix * addressed copilot comments
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.
Motivation and Context
Fixes an issue where
MCPStreamableHTTPTool(and other local MCP tools) were not working withAzureAIProjectAgentProvider. The agent would respond using its training data instead of calling the MCP server tools.The Azure AI Responses API requires tools to be defined on the agent at creation time - they cannot be passed at request time like with OpenAI's API. Local MCP tools (
MCPTool) were being filtered out during agent creation becauseto_azure_ai_tools()only recognizedHostedMCPTool, not localMCPToolinstances.Resolves #3303
Description
Contribution Checklist