Prewarm MCP servers during cloud catalog refresh (#62876)

## Why

A slow cloud skill lookup can delay MCP startup even after the plugin
catalog is ready. If the refresh is canceled while waiting for skills,
it can miss the chance to prewarm those servers before the first turn.

## What changed

Queue MCP prewarm as soon as plugin discovery changes or clears the
catalog. Skill discovery alone leaves the MCP server set unchanged.

At the end of the refresh, queue a retry for eligible MCP startup
failures. If discovery is canceled, check for those failures the next
time the catalog lock is acquired. Reuse pending handshakes and leave
authentication failures and Apps-managed reconnects to their existing
recovery paths.

## Testing

Add regression tests for first-turn tool availability after cancellation,
startup recovery with cloud plugins disabled, and a single retry for a
persistent startup failure.

GitOrigin-RevId: f92162d1629358953d8810d20244e55f07416a01
This commit is contained in:
Jay Chen
2026-11-21 00:54:05 +00:00
committed by copyberry
parent 0bfb8467da
commit 66618f0512
16 changed files with 564 additions and 57 deletions
+8
View File
@@ -691,6 +691,14 @@ impl McpRuntime {
.await
}
/// Checks for completed startup failures eligible for retry without polling any client.
pub fn has_failed_startup_for_retry(&self) -> bool {
self.current
.load()
.connections
.has_failed_startup_for_retry()
}
/// Checks the current generation before retrying servers detected outside the refresh gate.
pub async fn has_authentication_failed_servers(&self, server_names: &[McpServerKey]) -> bool {
!self