Scope session MCP approvals to app account links (#42133)

## Why

Remembering an app tool approval by connector and tool alone could reuse an
approval when the same tool was called with a different selected account.

## What changed

Include the app `link_id` in MCP tool approval keys so remembered session
approvals apply only to the account link that was approved. Calls for another
link, or calls without a link selector, request their own approval.

## Testing

Add an integration test covering calls across two link IDs and the legacy
no-selector case.

GitOrigin-RevId: 7dd88330b75de312469020d5892dfb2fa5d5fada
This commit is contained in:
Alex Zamoshchin authored and copyberry committed 2026-09-01 20:46:17 +00:00
1 parent 8436b749a4
commit 2393b5c920
3 files changed
+183 -1

No files matched your search

+2
View File
@@ -1373,6 +1373,7 @@ const MCP_TOOL_APPROVAL_CANCEL: &str = "Cancel";
struct McpToolApprovalKey {
server: String,
connector_id: Option<String>,
link_id: Option<String>,
tool_name: String,
}
@@ -1636,6 +1637,7 @@ fn session_mcp_tool_approval_key(
Some(McpToolApprovalKey {
server: invocation.server.clone(),
connector_id,
link_id: metadata.and_then(|metadata| metadata.link_id.clone()),
tool_name: invocation.tool.clone(),
})
}