mirror of
https://github.com/openai/codex.git
synced 2026-11-07 16:35:32 +00:00
Route hook MCP calls through current connections (#39331)
## What changed - Execute hook-triggered MCP calls through the runtime's latest connection set instead of preparing a separate catalog-bound call. - Keep hook calls from waiting for server startup or reconnecting, and reject disconnected servers immediately. - Apply the shorter of the hook-requested timeout and the server's configured tool timeout. ## Testing - Update connection manager tests to cover non-waiting calls and disabled tool filters. GitOrigin-RevId: 3166b2d1e26d9ae2b8b3a648b4d0897cc260eb93
This commit is contained in:
1 parent
67ed4e717a
commit
d35e5495f9
8 files changed
+84
-269
No files matched your search
@@ -775,7 +775,10 @@ impl CodexThread {
|
||||
self.session
|
||||
.services
|
||||
.mcp_runtime
|
||||
.latest_call_tool(server, tool, arguments, meta)
|
||||
.latest_call_tool(
|
||||
server, tool, arguments, meta, /*requested_timeout*/ None,
|
||||
/*wait_for_server*/ true,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::bail;
|
||||
use codex_hooks::HookMcpCall;
|
||||
use codex_hooks::HookMcpExecutor;
|
||||
@@ -19,22 +18,15 @@ pub(crate) struct CoreHookMcpExecutor {
|
||||
impl HookMcpExecutor for CoreHookMcpExecutor {
|
||||
fn execute(&self, call: HookMcpCall) -> BoxFuture<'_, anyhow::Result<String>> {
|
||||
async move {
|
||||
let prepared_call = self
|
||||
let result = self
|
||||
.runtime
|
||||
.prepare_call_if_connected(&call.server, &call.tool)
|
||||
.await
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"MCP server `{}` or tool `{}` is not connected and available",
|
||||
call.server, call.tool
|
||||
)
|
||||
})?;
|
||||
|
||||
let result = prepared_call
|
||||
.call(
|
||||
.latest_call_tool(
|
||||
&call.server,
|
||||
&call.tool,
|
||||
Some(Value::Object(call.input)),
|
||||
Some(serde_json::json!({ "threadId": self.thread_id.to_string() })),
|
||||
Some(call.timeout),
|
||||
/*wait_for_server*/ false,
|
||||
)
|
||||
.await?;
|
||||
let text = result
|
||||
|
||||
@@ -3594,6 +3594,8 @@ impl Session {
|
||||
Some(serde_json::json!({
|
||||
"threadId": self.thread_id().to_string(),
|
||||
})),
|
||||
/*requested_timeout*/ None,
|
||||
/*wait_for_server*/ true,
|
||||
)
|
||||
.await
|
||||
.ok()
|
||||
|
||||
Reference in new issue
Block a user