Skip to content

Conversation

nsheaps
Copy link
Contributor

@nsheaps nsheaps commented Aug 21, 2025

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

It would normally print as much would fit in the default buffer of the child_process (controlled by maxBuffer, which defaults to 8192 characters), and would fail to print the rest because the node child_process buffer was at it's limit. When the process is spawn instead of execd, the data buffer passing is all that sends stuff back and forth, unless you set stdio to inherit in which case console.out in the child process would print directly to stdout instead of to a pipe. Since the output isn't needed, we don't need to keep it as a pipe.

You can see this in their openapi spec, which powers their MCP server.

Validated with:

npm run prettier-fix && npm run build && npm run test && npm run test-cli && npm run test:e2e 
npm -w cli exec -- node build/cli.js --cli --config ~/path/to/.mcp.json --server notion --method tools/list
npx --from 'github:nsheaps/inspector' --cli --config ~/path/to/.mcp.json --server notion --method tools/list

Prior to the change, running the second command would truncate the response

# 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"
      ]
    },

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.
@nsheaps nsheaps marked this pull request as ready for review August 21, 2025 01:23
@nsheaps
Copy link
Contributor Author

nsheaps commented Aug 21, 2025

You can see @ashwin-ant made a similar fix here: https://github.com/anthropics/claude-code-action/pull/473/files

Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nsheaps , I don't have Notion but I was able to test this locally by creating a temporary reproduction script that overflowed the limit.

@olaservo olaservo merged commit e1d311c into modelcontextprotocol:main Sep 1, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants