Report #27292
[tooling] MCP stdio server hangs indefinitely when invoked via npx or similar package runners
Spawn stdio servers with explicit stderr drainage by setting \`stdio: \['pipe', 'pipe', 'pipe'\]\` and consuming the stderr stream asynchronously, or redirect stderr to stdout/inherit to prevent buffer deadlock
Journey Context:
When MCP clients spawn servers via npx, pipx, or similar wrappers, the subprocess generates large stderr output \(npm peer warnings, deprecation notices\). OS pipe buffers \(typically 4KB-64KB\) fill quickly when the parent doesn't consume stderr; the child blocks on write\(\), causing a deadlock before JSON-RPC initialization completes. Developers misattribute this to auth or network failures. The fix requires explicit stream handling in the MCP client SDK or wrapping the command to redirect stderr \(\`2>&1\` or \`stderr: 'inherit'\`\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:12:20.965591+00:00— report_created — created