Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

chore: print stderr from MCP server to test output using eprintln! (#2849)

Michael Bolinf09170b574b5
diff --git a/codex-rs/mcp-server/tests/common/mcp_process.rs b/codex-rs/mcp-server/tests/common/mcp_process.rs
index eae83482d7..14939156bb 100644
--- a/codex-rs/mcp-server/tests/common/mcp_process.rs
+++ b/codex-rs/mcp-server/tests/common/mcp_process.rs
@@ -61,6 +61,7 @@ impl McpProcess {
cmd.stdin(Stdio::piped());
cmd.stdout(Stdio::piped());
+ cmd.stderr(Stdio::piped());
cmd.env("CODEX_HOME", codex_home);
cmd.env("RUST_LOG", "debug");
@@ -77,6 +78,17 @@ impl McpProcess {
.take()
.ok_or_else(|| anyhow::format_err!("mcp should have stdout fd"))?;
let stdout = BufReader::new(stdout);
+
+ // Forward child's stderr to our stderr so failures are visible even
+ // when stdout/stderr are captured by the test harness.
+ if let Some(stderr) = process.stderr.take() {
+ let mut stderr_reader = BufReader::new(stderr).lines();
+ tokio::spawn(async move {
+ while let Ok(Some(line)) = stderr_reader.next_line().await {
+ eprintln!("[mcp stderr] {line}");
+ }
+ });
+ }
Ok(Self {
next_request_id: AtomicI64::new(0),
process,