mirror of
https://github.com/openai/codex.git
synced 2026-11-07 20:30:33 +00:00
Expose cached MCP tools before server startup (#35590)
## Why Cached MCP definitions can be supplied to inference without waiting for the server to finish initializing. ## What changed - Publish cached tools while startup is still in progress, clearing their potentially stale read-only hint. - Wait for the selected server to start before executing a tool call, then prepare the call against the refreshed live binding. - Keep cached tools visible in a binding even when no live client is available, while rejecting attempts to prepare those calls. ## Testing - Cover cached-tool visibility before startup and replacement with live tool metadata afterward. - Verify cached definitions reach inference before MCP initialization and that calls unavailable in the live catalog return the expected model-visible error. GitOrigin-RevId: 3aae8f474c344ccdc5e08fe321bbad21d85bffd1
This commit is contained in:
@@ -240,6 +240,21 @@ impl McpRuntime {
|
||||
}
|
||||
}
|
||||
|
||||
/// Captures the current runtime after its selected server has finished startup.
|
||||
pub async fn current_binding_for_call(&self, server: &str) -> Option<Arc<McpBinding>> {
|
||||
let current = self.current.load_full();
|
||||
let config = Arc::clone(current.config.as_ref()?);
|
||||
if !current.connections.wait_for_server_startup(server).await {
|
||||
return None;
|
||||
}
|
||||
Some(Arc::new(
|
||||
current
|
||||
.connections
|
||||
.capture_binding_with_metadata(config, current.plugins_available)
|
||||
.await,
|
||||
))
|
||||
}
|
||||
|
||||
/// Returns the latest published configuration without waiting for clients.
|
||||
pub fn current_config(&self) -> Option<Arc<McpConfig>> {
|
||||
self.current.load().config.clone()
|
||||
|
||||
Reference in New Issue
Block a user