Description
The in parses stdout data incorrectly. The event handler assumes each event contains exactly one complete JSON message:
this.process.stdout.on("data", (data) => {
const response = data.toString().trim();
if (!response.startsWith("{")) {
return;
}
const message = JSON.parse(response);
Node.js streams do not guarantee message boundaries. A single event may contain:
- A partial JSON message (split across events)
- Multiple JSON messages concatenated together
- A mix of both
This causes:
JSON.parse throws on partial messages, crashing the client
- Messages are silently dropped when multiple arrive in one chunk (only the first is parsed)
Steps to Reproduce
- Use with any MCP server that sends responses rapidly or sends large responses
- The stdout buffer may deliver partial or batched messages
- crashes or only the first message is parsed
Expected Behavior
The client should buffer incoming data and correctly parse newline-delimited JSON messages, handling partial reads and batched data.
Environment
Additional Context
The JSON-RPC over stdio protocol uses newline-delimited JSON. The fix should accumulate a buffer and split on newlines, parsing complete lines only.
Description
The in parses stdout data incorrectly. The event handler assumes each event contains exactly one complete JSON message:
Node.js streams do not guarantee message boundaries. A single event may contain:
This causes:
JSON.parsethrows on partial messages, crashing the clientSteps to Reproduce
Expected Behavior
The client should buffer incoming data and correctly parse newline-delimited JSON messages, handling partial reads and batched data.
Environment
Additional Context
The JSON-RPC over stdio protocol uses newline-delimited JSON. The fix should accumulate a buffer and split on newlines, parsing complete lines only.