From 9e47d7d3c13bb7a83741f860d4bfc86c7a5d2078 Mon Sep 17 00:00:00 2001 From: Nathan Heaps Date: Wed, 20 Aug 2025 21:06:06 -0400 Subject: [PATCH] fix: correct stdout buffering issues in spawned processes Adds stdio inheritance to prevent Node.js from dropping console output after 8192 characters due to premature stdout pipe closure before output finishes flushing. Without this, calls like this would truncate after 8192 characters, leading to broken json output: ``` npx --node-options=--inspect -y @modelcontextprotocol/inspector --cli --config .mcp.json --server notion --method tools/list ``` ``` # notion mcp server "notion": { "//": "doppler needs to expose OPENAPI_MCP_HEADERS (and NOTION_TOKEN within it)", "command": "bash", "args": [ "-c", "doppler run -p 'mcp' -c \"user_${MCP_USER:-$USER}\" -- npx -y @notionhq/notion-mcp-server" ] }, ``` You can see this in their [openapi spec](https://github.com/makenotion/notion-mcp-server/blob/main/scripts/notion-openapi.json), which powers their MCP server. --- cli/src/cli.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cli/src/cli.ts b/cli/src/cli.ts index 13c7e492a..3a27ccb1b 100644 --- a/cli/src/cli.ts +++ b/cli/src/cli.ts @@ -104,6 +104,10 @@ async function runWebClient(args: Args): Promise { await spawnPromise("node", [inspectorClientPath, ...startArgs], { signal: abort.signal, echoOutput: true, + // pipe the stdout through here, prevents issues with buffering and + // dropping the end of console.out after 8192 chars due to node + // closing the stdout pipe before the output has finished flushing + stdio: "inherit", }); } catch (e) { if (!cancelled || process.env.DEBUG) throw e; @@ -142,6 +146,10 @@ async function runCli(args: Args): Promise { env: { ...process.env, ...args.envArgs }, signal: abort.signal, echoOutput: true, + // pipe the stdout through here, prevents issues with buffering and + // dropping the end of console.out after 8192 chars due to node + // closing the stdout pipe before the output has finished flushing + stdio: "inherit", }); } catch (e) { if (!cancelled || process.env.DEBUG) {