fix: bound stdio JSON-RPC message size#985
Conversation
|
Rebased on current Validated: gofmt -w mcp\cmd.go mcp\transport.go mcp\transport_test.go
go test ./mcp
go test -race ./mcp
go test ./...
git diff --check origin/main...HEADAll passed after the rebase. |
37c0444 to
00c9bfb
Compare
|
Fresh local re-validation on the current checkout:
The GitHub checks are also green as of the latest run. |
00c9bfb to
b70eb70
Compare
|
Rebased this branch onto the latest upstream Validated locally:
|
|
Nice refactor in the stdio framing path. A few notes from reading the diff:
I ran a quick read-only review against current |
b70eb70 to
880a8de
Compare
|
Thanks for the careful read. I pushed What changed:
Validation:
|
|
Thanks for the follow-up. The payload-vs-line-ending semantics and the CRLF/LF regression tests match what I had in mind. Looks good from my read. |
piyushbag
left a comment
There was a problem hiding this comment.
The follow-up commit addresses the limit-semantics and capped ReadSlice paths from the earlier review. Doc comment, trim-before-check behavior, and regression coverage for LF/CRLF and zero-limit unbounded mode look correct.
Fixes #984.
Summary
Adds an optional
MaxMessageByteslimit for newline-delimited JSON-RPC transports:CommandTransport.MaxMessageBytesbounds frames read from child process stdout.StdioTransport.MaxMessageBytesandIOTransport.MaxMessageBytesexpose the same behavior for server-side stdio and custom IO transports.Validation
go test ./mcp -run "TestIOConnRead|TestIOConnReadMaxMessageBytes|TestBatchFraming"go test ./mcp -run TestCommandTransportTerminateDurationgo test ./...go vet ./...gofmt -l .go run honnef.co/go/tools/cmd/staticcheck@v0.6.1 ./...git diff --check -- mcp\transport.go mcp\cmd.go mcp\transport_test.go