From c88441b041763ef6c9e6f6d842468cac221a26e8 Mon Sep 17 00:00:00 2001 From: blaenkey Date: Mon, 18 May 2026 08:28:25 -0400 Subject: [PATCH] fix(mcp): route tracing output to stderr to prevent JSON-RPC stdio corruption The ruvector-mcp binary initializes its tracing subscriber without specifying a writer, defaulting to stdout. Under the stdio MCP transport this contaminates the JSON-RPC frame stream with log lines, causing every @modelcontextprotocol/sdk client to throw a Zod parse error on the very first frame. Add .with_writer(std::io::stderr) to both the debug and release tracing subscriber builders in crates/ruvector-cli/src/mcp_server.rs. Verified by stdio smoke test: first line of stdout is now a valid JSON-RPC initialize response with serverInfo.name == "ruvector-mcp", and tracing output appears exclusively on stderr as required by the MCP stdio transport spec. --- crates/ruvector-cli/src/mcp_server.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ruvector-cli/src/mcp_server.rs b/crates/ruvector-cli/src/mcp_server.rs index 4379910293..479ef2f9c9 100644 --- a/crates/ruvector-cli/src/mcp_server.rs +++ b/crates/ruvector-cli/src/mcp_server.rs @@ -48,10 +48,12 @@ async fn main() -> Result<()> { // Initialize logging if cli.debug { tracing_subscriber::fmt() + .with_writer(std::io::stderr) .with_env_filter("ruvector=debug") .init(); } else { tracing_subscriber::fmt() + .with_writer(std::io::stderr) .with_env_filter("ruvector=info") .init(); }