Skip to content

Python: [Breaking] Add MCP tool approval callback for Azure AI Agent - #14210

Merged
SergeyMenshykh merged 2 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-mcp-tool-approval-callback
Jul 28, 2026
Merged

Python: [Breaking] Add MCP tool approval callback for Azure AI Agent#14210
SergeyMenshykh merged 2 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-mcp-tool-approval-callback

Conversation

@SergeyMenshykh

Copy link
Copy Markdown
Contributor

Summary

  • Add an Azure AI Agent callback for MCP tool approval requests.
  • Route MCP tool approval submissions through a shared helper in thread actions.
  • Add unit coverage for approval, denial, callback failures, and per-call decisions.

Testing

  • python -m pytest tests/unit/agents/azure_ai_agent

Add an agent-level callback for Azure AI MCP tool approval requests and use it when submitting tool approvals from thread actions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3e190979-228b-4a82-8e63-5ad14bd4879f
Copilot AI review requested due to automatic review settings July 27, 2026 18:25
@SergeyMenshykh
SergeyMenshykh requested a review from a team as a code owner July 27, 2026 18:25

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Code Review

Reviewers: 5 | Confidence: 90% | Result: All clear

Reviewed: Correctness, Security Reliability, Test Coverage, Failure Modes, Design Approach


Automated review by SergeyMenshykh's agents

@SergeyMenshykh SergeyMenshykh changed the title Add MCP tool approval callback for Azure AI Agent Python: [Breaking] Add MCP tool approval callback for Azure AI Agent Jul 27, 2026
@SergeyMenshykh SergeyMenshykh self-assigned this Jul 27, 2026
@SergeyMenshykh SergeyMenshykh moved this to In Review in Agent Framework Jul 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Azure AI Agent–level callback that decides whether to approve each pending MCP tool call when Azure AI Foundry requests tool approvals, defaulting to deny when no callback is configured.

Changes:

  • Introduces MCPToolApprovalRequest and MCPToolApprovalCallback for per-call approval decisions.
  • Routes MCP tool approval handling in AgentThreadActions through shared helpers (non-streaming + streaming).
  • Adds unit tests covering approval/denial, callback errors, and per-call decisions.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/semantic_kernel/agents/azure_ai/agent_thread_actions.py Adds shared helpers to build/resolve MCP tool approvals and wires them into invoke + streaming paths.
python/semantic_kernel/agents/azure_ai/azure_ai_agent.py Adds mcp_tool_approval_callback to the agent model and constructor with documented deny-by-default behavior.
python/semantic_kernel/agents/azure_ai/mcp_tool_approval.py Introduces the approval request dataclass and callback type alias.
python/semantic_kernel/agents/init.py Re-exports the MCP approval callback/request types from the agents package.
python/tests/unit/agents/azure_ai_agent/test_mcp_tool_approval.py Adds unit coverage for approval resolution and end-to-end invoke handling.
python/samples/concepts/agents/azure_ai_agent/azure_ai_agent_mcp_streaming.py Updates sample comments to reflect the new approval-callback behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/semantic_kernel/agents/azure_ai/agent_thread_actions.py Outdated
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
__init__.py40100% 
agents
   __init__.py10280%62, 66
agents/azure_ai
   agent_thread_actions.py47618960%181, 183, 220–226, 272–274, 360, 364, 369, 372, 375–376, 380, 383, 386–387, 391, 394, 397–398, 402–403, 407–408, 412–413, 417–418, 422, 425, 535, 537, 578–579, 603, 605–607, 609–611, 613, 615–617, 619–620, 622–627, 629–637, 641–642, 645–648, 652, 655–656, 659–660, 663, 666, 669–670, 673–674, 677–683, 685–686, 690, 693–694, 702–703, 708, 712–715, 717–718, 725, 727, 731, 734–739, 741–743, 748–749, 752–755, 758, 765–766, 773, 775, 779, 781–782, 786–795, 797–805, 856, 859, 893–894, 901–905, 965, 971–974, 1066–1068, 1072, 1077–1078, 1082, 1099–1101, 1105–1106, 1121–1122, 1269–1272, 1274–1275, 1283, 1287–1288, 1293
   azure_ai_agent.py36718050%101, 103–106, 108–110, 112–117, 119, 121, 123–125, 127, 144, 146–149, 151–156, 158, 163–164, 169–172, 177–181, 183–186, 188–194, 199, 201–204, 206–208, 210–213, 215, 217, 227–228, 230–233, 235–236, 241, 243–249, 251, 284, 295–296, 301–302, 305, 310–315, 322–323, 325, 330–331, 342–348, 406, 408, 414, 425, 428, 430, 432, 436, 470, 501–503, 505, 507–508, 510–513, 516–518, 520–521, 524, 527–536, 538, 547–548, 551–553, 555–556, 566–567, 569, 587, 589, 592, 594–595, 597–598, 600, 609–610, 612, 614–617, 620, 622, 625–627, 631, 703, 813, 921, 995
   mcp_tool_approval.py160100% 
TOTAL29006561980% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4087 23 💤 0 ❌ 0 🔥 2m 18s ⏱️

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 3e190979-228b-4a82-8e63-5ad14bd4879f
@SergeyMenshykh
SergeyMenshykh enabled auto-merge July 28, 2026 09:02
@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue Jul 28, 2026
Merged via the queue into microsoft:main with commit 3da48a3 Jul 28, 2026
32 checks passed
@SergeyMenshykh
SergeyMenshykh deleted the sergeymenshykh-mcp-tool-approval-callback branch July 28, 2026 18:22
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants