fix(mcp): avoid probing JSON-RPC stdin for explicit batch input - #293
Open
EricLingRui wants to merge 1 commit into
Open
fix(mcp): avoid probing JSON-RPC stdin for explicit batch input#293EricLingRui wants to merge 1 commit into
EricLingRui wants to merge 1 commit into
Conversation
EricLingRui
force-pushed
the
agent/fix-mcp-batch-stdin-probe
branch
from
August 8, 2026 09:53
fc7d0d8 to
4a0ecf3
Compare
EricLingRui
marked this pull request as ready for review
August 8, 2026 10:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
batchalready has an explicit non-stdin input and the warning is disabledbatch --commands/batch --inputcalls never read from the JSON-RPC transport--input -, and the existing ignored-stdin warning for normal CLI useRoot cause
The MCP server sets
OFFICECLI_BATCH_ALLOW_STDIN_REDIRECT=1because its stdin is the JSON-RPC transport. However, the old batch handler checked that flag only when deciding whether to print a warning, after it had already started a backgroundStdIn.Peek().When the 50 ms wait expired, the blocked task was abandoned but remained alive. Once the client sent its next JSON-RPC request, that task could buffer the request from stdin, leaving the MCP read loop without the expected message. The caller then waited until its tool timeout.
The fix decides whether the ignored-stdin warning is needed before starting the probe. MCP disables that warning, so it no longer creates a competing stdin reader. The mutual-exclusion check also runs before any possible probe.
Validation
Both the baseline (
459b1a47) and patched source were published forlinux-arm64with:I then ran the same MCP sequence against each binary: initialize, send a malformed string-form batch (which returns an error), then immediately send a valid argv-form batch.
Portable reproducer (set
OFFICECLIto the binary under test):The patched output is: