[dotnet-port-api] Add hosted MCP tool approval mode - #1155
PratikDhanave (PratikDhanave) wants to merge 1 commit into
Conversation
hostedtool.MCPServer had no way to control approval, so every hosted MCP tool call required an mcp_approval_request round-trip (the Responses API defaults require_approval to "always"). Add an ApprovalMode field (MCPApprovalAlways/MCPApprovalNever) mirroring .NET HostedMcpServerTool. ApprovalMode, and forward it as require_approval on the Responses request. The zero value preserves the provider default. Implements microsoft#1138.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is backward-compatible and the new behavior is covered by focused tests.
Review effort: Lite
Findings: None
What changed in this PR
Adds hosted MCP approval-mode control and forwards it through the OpenAI Responses provider while preserving existing defaults.
Changes:
- Adds
MCPApprovalAlwaysandMCPApprovalNever. - Serializes non-zero approval modes as
require_approval. - Adds coverage for always, never, and unset modes.
| File | Description |
|---|---|
tool/hostedtool/hostedtool.go |
Defines the approval-mode API. |
provider/openaiprovider/responses.go |
Forwards approval mode to Responses requests. |
provider/openaiprovider/responses_test.go |
Tests request serialization behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Scope: public API, user-visible behavior Changed Go contract: Upstream evidence reviewed:
Result: aligned (with a disclosed, intentional scope reduction) Both upstream implementations support three forms: always/never for all tools, and a per-tool "specific" filter (.NET
One suggestion for a Go-side follow-up (not a blocking parity issue): since No
|
| Headers map[string]string | ||
| // ApprovalMode controls whether calls to this MCP server require approval. | ||
| // The zero value leaves the provider default (which, for the OpenAI Responses | ||
| // API, requires approval for every call). Mirrors the .NET |
There was a problem hiding this comment.
Don't mention .net in public docs.
Implements #1138.
hostedtool.MCPServerhad no approval-mode control, so every hosted MCP tool call required anmcp_approval_requestround-trip — the Responses API defaultsrequire_approvalto"always"when omitted, and there was no way to request auto-approval.Change
MCPApprovalMode(MCPApprovalAlways/MCPApprovalNever) and anApprovalModefield onhostedtool.MCPServer, mirroring the .NETHostedMcpServerTool.ApprovalMode.require_approvalon the OpenAI Responses request. The zero value leaves the provider default (always), so existing behavior is unchanged.Scoped to the two simple settings (always/never); the per-tool approval filter form can follow separately.
Test
TestResponsesMCPServerApprovalMode:never→"require_approval":"never",always→"always", unset → field omitted. Thenevercase fails before the change (field absent), passes after.