Conversation
There was a problem hiding this comment.
Pull request overview
This PR simplifies the MCP server tool invocation approval mechanism by consolidating approval types. Instead of having separate McpServerToolApprovalRequestContent and McpServerToolApprovalResponseContent classes, it makes McpServerToolCallContent and McpServerToolResultContent inherit from FunctionCallContent and FunctionResultContent respectively, and reuses the existing FunctionApprovalRequestContent and FunctionApprovalResponseContent for MCP approvals.
Changes:
- Removed
McpServerToolApprovalRequestContentandMcpServerToolApprovalResponseContentclasses - Made
McpServerToolCallContentextendFunctionCallContentandMcpServerToolResultContentextendFunctionResultContent - Added
InvocationRequiredproperty toFunctionCallContent(defaults totrue, set tofalsefor MCP tools) - Updated OpenAI integration and tests to work with the unified approval model
- Added API compatibility suppressions for breaking changes
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
McpServerToolApprovalRequestContent.cs |
Deleted - approval now handled through FunctionApprovalRequestContent |
McpServerToolApprovalResponseContent.cs |
Deleted - approval now handled through FunctionApprovalResponseContent |
McpServerToolCallContent.cs |
Now extends FunctionCallContent, inherits Name, CallId, and Arguments properties, sets InvocationRequired = false |
McpServerToolResultContent.cs |
Now extends FunctionResultContent, simplified to only add CallId through base constructor |
FunctionCallContent.cs |
Added InvocationRequired property and polymorphic JSON serialization for McpServerToolCallContent |
FunctionResultContent.cs |
Added polymorphic JSON serialization for McpServerToolResultContent |
UserInputRequestContent.cs |
Removed McpServerToolApprovalRequestContent from JSON derived types |
UserInputResponseContent.cs |
Removed McpServerToolApprovalResponseContent from JSON derived types |
AIContent.cs |
Updated comments to reflect removed types |
OpenAIResponsesChatClient.cs |
Updated to create FunctionApprovalRequestContent wrapping McpServerToolCallContent instead of separate MCP approval types, updated error handling to use Result property |
OpenAIJsonContext.cs |
Removed IReadOnlyDictionary<string, object?> serialization (now uses IDictionary) |
AIJsonUtilities.Defaults.cs |
Removed MCP approval types from JSON serialization registration |
FunctionInvokingChatClient.cs |
Updated approval filtering to check InvocationRequired property on function calls |
CompatibilitySuppressions.xml |
Added suppressions for removed types and changed properties across all target frameworks |
| Test files | Updated to use new API, added tests for mixed MCP/function approval scenarios, fixed namespace |
...ies/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs
Outdated
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientIntegrationTests.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionResultContent.cs
Outdated
Show resolved
Hide resolved
|
@copilot please revise the PR summary based on the current state of the PR |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Updated the PR summary to accurately reflect the current state of the PR. The summary now correctly describes that |
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
…alization and tests
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
stephentoub
left a comment
There was a problem hiding this comment.
This direction makes sense to me.
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolCallContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionCallContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionCallContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolCallContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolResultContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolResultContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/UserInputRequestContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
…erty Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
Addressed in d0a56eb. Updated documentation for:
|
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/InputRequestContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/InputResponseContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedMcpServerTool.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/FunctionApprovalRequestContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/McpServerToolCallContent.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
…iBaselines.ps1 TFM Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
…arer Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
src/Libraries/Microsoft.Extensions.AI.Abstractions/HostedMcpServerToolApprovalMode.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
|
Please double-check that this all works well with Agent Framework. |
|
Built local nugets for MEAI.Abstractions and MEAI.OpenAI, cloned af repo, ran dotnet built and dotnet test consuming these local versions. Aside from source braking changes and few tests' adjustments, seems like things will keep working in agent-framework. |
…lot/update-mcp-server-tool-invocation-again
Summary
This PR consolidates MCP server tool approval flow by making
McpServerToolCallContentandMcpServerToolResultContentinherit fromFunctionCallContentandFunctionResultContentrespectively, instead of having separate approval types.Changes
McpServerToolCallContentextendFunctionCallContentandMcpServerToolResultContentextendFunctionResultContentMcpServerToolApprovalRequestContentandMcpServerToolApprovalResponseContentclasses - MCP approvals now use the existingFunctionApprovalRequestContentandFunctionApprovalResponseContentInformationalOnlyproperty toFunctionCallContent(defaults tofalse). ForMcpServerToolCallContent, this defaults totruesince MCP tool calls are informationalOpenAIResponsesChatClientto work with the unified approval modelCompatibilitySuppressions.xmlStringComparison.OrdinalIgnoreCasefor case-insensitive auth scheme matching per RFC 7235, trim whitespace from both ends of header value, and allow flexible whitespace after "Bearer "Impact
This reduces complexity by reusing existing function call/result abstractions rather than maintaining parallel MCP-specific approval types. The approval mechanism now works consistently for both regular function calls and MCP server tool calls.
Original prompt
This pull request was created from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
Microsoft Reviewers: Open in CodeFlow