Reuse MCP connections across runtime refreshes (#34952)

## Why

Refreshing MCP runtime state should not restart an unchanged, ready server or
relist its tools.

## What changed

- Reconcile refreshed MCP configuration against the published connection set
  and reuse connections whose transport, environment, authentication, OAuth
  credentials, and client capabilities are unchanged.
- Keep tool filters, timeouts, metadata, and plugin provenance in the published
  server view so those settings can change without reconnecting.
- Update elicitation authority in place for reused connections, and reconnect
  when connection-defining inputs or live OAuth credentials change.

## Testing

Added coverage for unchanged-server reuse, view-only and elicitation-policy
updates, connection identity changes, OAuth credential changes, and avoiding
redundant tool listing.

GitOrigin-RevId: f04f5db5fbdde127b6a14f6aa9673112c0b557e7
This commit is contained in:
jif authored and copyberry committed 2026-07-23 14:55:31 +00:00
1 parent 808d3c2702
commit e19e65317a
26 files changed
+1954 -811

No files matched your search

@@ -70,8 +70,7 @@ impl AppsRequestProcessor {
);
let startup_timeout = mcp_servers
.get(CODEX_APPS_MCP_SERVER_NAME)
.and_then(|server| server.configured_config())
.and_then(|config| config.startup_timeout_sec)
.and_then(|server| server.config().startup_timeout_sec)
.unwrap_or(CONNECTOR_RUNTIME_REFRESH_TIMEOUT);
let runtime_context = McpRuntimeContext::new(
self.thread_manager.environment_manager(),