fix: stop MCP server stderr from corrupting the TUI - #237
Open
wowi42 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 toStdio::inherit(), so anything an MCP server writes to stderr goes straight to the user's terminal and paints over the alt-screen TUI. (stdoutis the JSON-RPC protocol channel and is unaffected.)Fix
Spawn command-transport MCP servers with
stderr: Stdio::piped()and drain the pipe intotracing(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-featuresand--no-default-featureswith-D warnings— all clean.