Replace Mcp approvals with Function approvals#7104
Closed
jozkee wants to merge 2 commits intodotnet:mainfrom
Closed
Replace Mcp approvals with Function approvals#7104jozkee wants to merge 2 commits intodotnet:mainfrom
jozkee wants to merge 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the approval mechanism for tool calls by replacing MCP-specific approval types (McpServerToolApprovalRequestContent and McpServerToolApprovalResponseContent) with generalized FunctionApprovalRequestContent and FunctionApprovalResponseContent types. This allows the function approval system to handle both regular function calls and MCP server tool calls uniformly.
Key Changes:
- Deleted MCP-specific approval content types and consolidated them into the existing Function approval types
- Changed
FunctionApprovalRequestContentandFunctionApprovalResponseContentto acceptAIContentinstead ofFunctionCallContent, enabling support for multiple call types (e.g.,FunctionCallContent,McpServerToolCallContent) - Updated property names from
FunctionCalltoCallContentto reflect the more general nature - Added pattern matching logic in
FunctionInvokingChatClientto handle mixed approval scenarios where onlyFunctionCallContentapprovals are processed - Updated OpenAI response client to map MCP approval items to the generalized approval types
- Added comprehensive tests for mixed approval scenarios
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolApprovalRequestContent.cs |
Deleted - functionality replaced by generalized FunctionApprovalRequestContent |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolApprovalResponseContent.cs |
Deleted - functionality replaced by generalized FunctionApprovalResponseContent |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionApprovalRequestContent.cs |
Changed to accept AIContent instead of FunctionCallContent; renamed property FunctionCall → CallContent |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionApprovalResponseContent.cs |
Changed to accept AIContent instead of FunctionCallContent; renamed property FunctionCall → CallContent |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/UserInputRequestContent.cs |
Removed McpServerToolApprovalRequestContent from JSON polymorphic type hierarchy |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/UserInputResponseContent.cs |
Removed McpServerToolApprovalResponseContent from JSON polymorphic type hierarchy |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/AIContent.cs |
Removed commented-out type discriminators for deleted MCP approval types |
src/Libraries/Microsoft.Extensions.AI.Abstractions/Utilities/AIJsonUtilities.Defaults.cs |
Removed JSON serialization registration for deleted MCP approval types |
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs |
Added pattern matching to process only FunctionCallContent from approval types; updated struct to be readonly with init properties; fixed spelling error |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs |
Updated to map MCP approval items to generalized FunctionApprovalRequestContent and FunctionApprovalResponseContent with McpServerToolCallContent |
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs |
Changed namespace; updated assertions to use CallContent property; added comprehensive tests for mixed approval scenarios |
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs |
Updated test assertions to use generalized approval types |
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs |
Updated test assertions and approval response creation logic; reordered test execution calls |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Contents/FunctionApprovalRequestContentTests.cs |
Updated tests to use CallContent property and added type assertions for deserialized content |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Contents/FunctionApprovalResponseContentTests.cs |
Updated tests to use CallContent property and added type assertions for deserialized content |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Contents/UserInputRequestContentTests.cs |
Commented out MCP-specific test case; updated deserialization type |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Contents/UserInputResponseContentTests.cs |
Commented out MCP-specific test case with note about experimental status |
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Contents/AIContentTests.cs |
Updated test to use generalized approval types with MCP content |
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs
Show resolved
Hide resolved
stephentoub
reviewed
Dec 4, 2025
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Outdated
Show resolved
Hide resolved
stephentoub
reviewed
Dec 4, 2025
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs
Outdated
Show resolved
Hide resolved
16 tasks
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Strawman proposal for replacing
McpServerToolApprovalRequestContentandMcpServerToolApprovalResponseContentwith Function approval types.#6492 (comment)
cc @westey-m
Microsoft Reviewers: Open in CodeFlow