Preserve refreshed Apps tools across MCP runtime updates (#35028)

## Why

After a remote plugin install refreshes the Apps tool catalog, a later MCP
runtime publication must not restore the catalog from the previous connection.

## What changed

- Rebuild the MCP runtime with fresh connections when hard-refreshing Apps
  tools, using the latest desired runtime configuration.
- Refresh the Apps catalog on the newly published connection so subsequent
  runtime updates retain it.

## Testing

Extend the remote plugin install test to verify that both newly available and
missing Apps tools remain consistent after an unrelated runtime configuration
refresh.

GitOrigin-RevId: 5b675d53d56379ab67fab09512fc2ad0ffcb8535
This commit is contained in:
jif
2026-07-23 23:10:00 +00:00
committed by copyberry
parent 1ee8f49175
commit 091e4a5d7c
4 changed files with 70 additions and 7 deletions
+12 -1
View File
@@ -141,13 +141,24 @@ impl McpRuntime {
/// Reconciles configured servers and publishes their immutable runtime snapshot.
pub async fn replace(&self, input: McpRuntimeInput) {
let current = self.current.load_full();
self.publish(input, Some(current.connections.as_ref()))
.await;
}
/// Starts fresh connections and returns their complete, refreshed Apps catalog.
pub async fn replace_fresh(&self, input: McpRuntimeInput) -> anyhow::Result<Vec<ToolInfo>> {
self.publish(input, /*previous*/ None).await;
self.latest_hard_refresh_codex_apps_tools_cache().await
}
async fn publish(&self, input: McpRuntimeInput, previous: Option<&McpConnectionSet>) {
let (publish, publication_gate) = McpPublicationGate::pending();
let config = Arc::clone(&input.config);
let plugins_available = input.plugins_available;
let ready_selected_capability_roots = input.ready_selected_capability_roots.clone();
let connections = Arc::new(
McpConnectionSet::new(
Some(current.connections.as_ref()),
previous,
publication_gate,
input,
self.elicitation_router.clone(),