Lightweight coding agent that runs in your terminal
Rust
[MCP] Render full MCP errors to the model (#5298)
Gabriel Peal6b0c486861ff
diff --git a/codex-rs/core/src/mcp_tool_call.rs b/codex-rs/core/src/mcp_tool_call.rsindex 7091a05656..21fdaf0026 100644--- a/codex-rs/core/src/mcp_tool_call.rs+++ b/codex-rs/core/src/mcp_tool_call.rs@@ -58,7 +58,10 @@ pub(crate) async fn handle_mcp_tool_call(let result = sess.call_tool(&server, &tool_name, arguments_value.clone()).await- .map_err(|e| format!("tool call error: {e}"));+ .map_err(|e| format!("tool call error: {e:?}"));+ if let Err(e) = &result {+ tracing::warn!("MCP tool call error: {e:?}");+ }let tool_call_end_event = EventMsg::McpToolCallEnd(McpToolCallEndEvent {call_id: call_id.clone(),invocation,diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rsindex 85acaf9b6a..0a3582577d 100644--- a/codex-rs/tui/src/history_cell.rs+++ b/codex-rs/tui/src/history_cell.rs@@ -854,7 +854,12 @@ impl HistoryCell for McpToolCallCell {}}Err(err) => {- let err_line = Line::from(format!("Error: {err}").dim());+ let err_text = format_and_truncate_tool_result(+ &format!("Error: {err}"),+ TOOL_CALL_MAX_LINES,+ width as usize,+ );+ let err_line = Line::from(err_text.dim());let wrapped = word_wrap_line(&err_line,RtOptions::new((width as usize).saturating_sub(4))