Share Apps tool catalogs without retaining unused snapshots (#45440)

## Why

Idle Apps clients and cached MCP bindings can retain replaced tool definitions. Shared catalog updates can also invalidate prepared calls even when the current definitions match the captured catalog, including after tools are restored while a call awaits approval.

## What changed

- Share immutable tool arrays across equivalent live discovery contexts and reuse storage for equal results. Let unused providers and cached bindings expire.
- Include requested capabilities and initialization results in the sharing scope, and detach servers that disable catalog caching from live sharing.
- Capture catalog snapshots for prepared calls. Accept equivalent shared catalogs regardless of tool-list order, while rejecting changed definitions and calls captured before an explicit refresh on that client.

## Testing

Add regression coverage for shared storage and scope isolation, release of replaced tools and unused bindings, equivalent catalog restoration, explicit refresh invalidation, and an Apps call completing after catalog restoration while awaiting approval.

GitOrigin-RevId: a0516186e4286d0ff13405fafbab6fcf3f1f3773
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-09-14 15:06:28 +00:00
1 parent f3803587c9
commit f8bed26f7b
12 files changed
+556 -132

No files matched your search

+1 -2
View File
@@ -352,8 +352,7 @@ impl McpConnectionSet {
let shares_codex_apps_tools_cache = is_host_owned_codex_apps
&& should_share_codex_apps_tools_cache(&server_name, uses_env_bearer_token);
let codex_apps_tools_cache_context = shares_codex_apps_tools_cache.then(|| {
// Tools/list has no thread selection or UI capabilities. Only equivalent
// transport/auth and listing settings may share executable Apps tools.
// Only equivalent discovery inputs may share executable Apps tools.
let mut transport = configured_config.transport.clone();
if let McpServerTransportConfig::StreamableHttp {
http_headers: Some(headers),