From c0c340a16954cf59d1b132cc5b0809e258c10f2d Mon Sep 17 00:00:00 2001 From: Gabriel Peal Date: Thu, 17 Jul 2025 17:22:08 -0700 Subject: [PATCH] --wip-- [skip ci] --- codex-rs/mcp-server/src/message_processor.rs | 35 ++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/codex-rs/mcp-server/src/message_processor.rs b/codex-rs/mcp-server/src/message_processor.rs index bf6f42e569..0ee259cb95 100644 --- a/codex-rs/mcp-server/src/message_processor.rs +++ b/codex-rs/mcp-server/src/message_processor.rs @@ -329,21 +329,26 @@ impl MessageProcessor { tracing::info!("tools/call -> params: {:?}", params); let CallToolRequestParams { name, arguments } = params; - // We only support the "codex" tool for now. - if name != "codex" { - // Tool not found – return error result so the LLM can react. - let result = CallToolResult { - content: vec![CallToolResultContent::TextContent(TextContent { - r#type: "text".to_string(), - text: format!("Unknown tool '{name}'"), - annotations: None, - })], - is_error: Some(true), - }; - self.send_response::(id, result); - return; + match name.as_str() { + "codex" => self.handle_codex_tool_call(id, arguments), + "codex/experimental/approve_patch" => self.handle_approve_patch(id, arguments), + _ => { + // Tool not found – return error result so the LLM can react. + let result = CallToolResult { + content: vec![CallToolResultContent::TextContent(TextContent { + r#type: "text".to_string(), + text: format!("Unknown tool '{name}'"), + annotations: None, + })], + is_error: Some(true), + }; + self.send_response::(id, result); + } } + } + fn handle_codex_tool_call(&self, id: RequestId, arguments: Option) { + // If no arguments are provided, we cannot proceed. let (initial_prompt, config): (String, CodexConfig) = match arguments { Some(json_val) => match serde_json::from_value::(json_val) { Ok(tool_cfg) => match tool_cfg.into_config(self.codex_linux_sandbox_exe.clone()) { @@ -404,6 +409,10 @@ impl MessageProcessor { }); } + /// TODO: Migrate this to MCP elicitations. + fn handle_approve_patch(&self, id: RequestId, arguments: Option) { + } + fn handle_set_level( &self, params: ::Params,