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 |
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