Skip to content

Commit 1c09ad9

Browse files
nsheapsjesselumarie
authored andcommitted
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.
1 parent 5dffb01 commit 1c09ad9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cli/src/cli.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ async function runWebClient(args: Args): Promise<void> {
106106
await spawnPromise("node", [inspectorClientPath, ...startArgs], {
107107
signal: abort.signal,
108108
echoOutput: true,
109+
// pipe the stdout through here, prevents issues with buffering and
110+
// dropping the end of console.out after 8192 chars due to node
111+
// closing the stdout pipe before the output has finished flushing
112+
stdio: "inherit",
109113
});
110114
} catch (e) {
111115
if (!cancelled || process.env.DEBUG) throw e;
@@ -151,6 +155,10 @@ async function runCli(args: Args): Promise<void> {
151155
env: { ...process.env, ...args.envArgs },
152156
signal: abort.signal,
153157
echoOutput: true,
158+
// pipe the stdout through here, prevents issues with buffering and
159+
// dropping the end of console.out after 8192 chars due to node
160+
// closing the stdout pipe before the output has finished flushing
161+
stdio: "inherit",
154162
});
155163
} catch (e) {
156164
if (!cancelled || process.env.DEBUG) {

0 commit comments

Comments
 (0)