Goal
Test what the stdio MCP server does with a JSON-RPC line larger than maxMessageBytes.
Why
internal/mcp/server.go bounds one line at 16 MiB and sizes the scanner buffer accordingly:
const maxMessageBytes = 16 * 1024 * 1024
scanner.Buffer(make([]byte, 0, 64*1024), maxMessageBytes)
maxMessageBytes appears nowhere in internal/mcp/server_test.go. A client that sends an oversized line gets whatever bufio.Scanner does at its limit, and nothing pins whether that is a clean refusal or a silently truncated read that the server then tries to parse.
That distinction matters here more than usual: a truncated line that happens to parse would be a different request than the one sent.
Scope
- Change
internal/mcp/server_test.go only.
- Make the bound overridable in the test the way
maxMatrixResultBytes already is (a var rather than a const) if that is the smallest change; otherwise construct an oversized line directly.
- Cover:
- a line over the bound;
- whether the server emits a response, and if so which;
- whether the stream continues or ends after it.
- Assert what the server does today rather than changing it. If the current behaviour is judged wrong, say so in the pull request and stop there.
Acceptance criteria
Contributor learning
Line-oriented transports, bufio.Scanner limits, and the difference between refusing an input and processing a prefix of it.
Goal
Test what the stdio MCP server does with a JSON-RPC line larger than
maxMessageBytes.Why
internal/mcp/server.gobounds one line at 16 MiB and sizes the scanner buffer accordingly:maxMessageBytesappears nowhere ininternal/mcp/server_test.go. A client that sends an oversized line gets whateverbufio.Scannerdoes at its limit, and nothing pins whether that is a clean refusal or a silently truncated read that the server then tries to parse.That distinction matters here more than usual: a truncated line that happens to parse would be a different request than the one sent.
Scope
internal/mcp/server_test.goonly.maxMatrixResultBytesalready is (avarrather than aconst) if that is the smallest change; otherwise construct an oversized line directly.Acceptance criteria
env GO111MODULE=on go test ./internal/mcpandgo test ./...pass.git commit -s.Contributor learning
Line-oriented transports,
bufio.Scannerlimits, and the difference between refusing an input and processing a prefix of it.