Skip to content

fix: stop MCP server stderr from corrupting the TUI - #237

Open
wowi42 wants to merge 1 commit into
gi-dellav:mainfrom
wowi42:fix/mcp-child-stderr
Open

fix: stop MCP server stderr from corrupting the TUI#237
wowi42 wants to merge 1 commit into
gi-dellav:mainfrom
wowi42:fix/mcp-child-stderr

Conversation

@wowi42

@wowi42 wowi42 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

A chatty MCP server (e.g. codebase-memory-mcp) floods the terminal with its debug logs and breaks the TUI display.

Root cause

TokioChildProcess's builder defaults the child's stderr to Stdio::inherit(), so anything an MCP server writes to stderr goes straight to the user's terminal and paints over the alt-screen TUI. (stdout is the JSON-RPC protocol channel and is unaffected.)

Fix

Spawn command-transport MCP servers with stderr: Stdio::piped() and drain the pipe into tracing (debug level, prefixed with the server name), which writes to zerostack's log file instead of the terminal. Draining also keeps a very verbose server from deadlocking on a full pipe buffer, and preserves diagnostics for MCP troubleshooting.

Verification

  • cargo test (715 passed), cargo test --no-default-features (600), cargo clippy --all-features and --no-default-features with -D warnings — all clean.
  • Live pty test with a fake MCP server spamming 50 stderr lines at startup: zero lines leaked into the TUI after the fix (all leaked before).

rmcp's child-process builder defaults stderr to Stdio::inherit(), so a
chatty MCP server (e.g. codebase-memory-mcp) writes its debug logs
straight to the user's terminal, painting over the alt-screen TUI.

Pipe the child's stderr instead and drain it into tracing (which logs
to the log file, not the terminal), server-prefixed at debug level.
Draining also prevents a verbose server from deadlocking on a full
pipe buffer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant