diff --git a/codex-rs/codex-mcp/src/connection_manager_tests.rs b/codex-rs/codex-mcp/src/connection_manager_tests.rs index b2d74c7381..819ebca1bc 100644 --- a/codex-rs/codex-mcp/src/connection_manager_tests.rs +++ b/codex-rs/codex-mcp/src/connection_manager_tests.rs @@ -310,6 +310,14 @@ impl ServerHandler for RefreshTestTransportFactory { ) } + async fn call_tool( + &self, + _request: rmcp::model::CallToolRequestParams, + _context: RequestContext, + ) -> Result { + Ok(rmcp::model::CallToolResult::success(Vec::new()).into()) + } + async fn list_resource_templates( &self, _request: Option, diff --git a/codex-rs/codex-mcp/src/runtime.rs b/codex-rs/codex-mcp/src/runtime.rs index 12eae6c961..ce83cbbfa4 100644 --- a/codex-rs/codex-mcp/src/runtime.rs +++ b/codex-rs/codex-mcp/src/runtime.rs @@ -764,6 +764,24 @@ impl McpRuntime { .await } + pub async fn latest_call_tool_without_attribution( + &self, + server: &str, + tool: &str, + arguments: Option, + meta: Option, + ) -> anyhow::Result { + let connections = self.latest_connections(); + connections.validate_tool_call(server, tool, /*environment_id*/ None)?; + connections.wait_for_server_startup(server).await; + connections + .call_tool( + server, tool, /*environment_id*/ None, arguments, meta, + /*requested_timeout*/ None, /*wait_for_server*/ true, + ) + .await + } + /// Calls a tool for the host, retaining attribution while its catalogs stay unchanged. /// Waiting calls capture a binding after the selected server starts; non-waiting calls /// use the cached binding. Missing or changed catalogs leave the namespace unknown. @@ -1226,6 +1244,17 @@ mod tests { ready_environments: HashMap::new(), cached_binding: Mutex::new(None), }); + let runtime = McpRuntime::empty(/*prefix_mcp_tool_names*/ true); + runtime.current.store(Arc::clone(&published)); + runtime + .latest_call_tool_without_attribution( + CODEX_APPS_MCP_SERVER_NAME, + "search", + /*arguments*/ None, + /*meta*/ None, + ) + .await?; + assert!(published.cached_binding.lock().unwrap().is_none()); let before = McpRuntime::binding_from_published_runtime( Arc::clone(&published), /*required_servers*/ &[], diff --git a/codex-rs/core/src/codex_thread.rs b/codex-rs/core/src/codex_thread.rs index 3c18039d13..c37a29aca1 100644 --- a/codex-rs/core/src/codex_thread.rs +++ b/codex-rs/core/src/codex_thread.rs @@ -1369,12 +1369,8 @@ impl CodexThread { self.session .services .mcp_runtime - .latest_call_tool( - server, tool, /*environment_id*/ None, arguments, meta, - /*requested_timeout*/ None, /*wait_for_server*/ true, - ) + .latest_call_tool_without_attribution(server, tool, arguments, meta) .await - .map(|call| call.result) } pub fn enabled(&self, feature: Feature) -> bool {