You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: replace bufio.Scanner with bufio.Reader to support large messages in stdio transport (#603)
The bufio.Scanner has a default 64KB token limit which causes 'token too long'
errors when MCP servers send large messages (e.g., large tool responses, resource
contents, or prompts). This change replaces Scanner with Reader.ReadString('\n')
which can handle arbitrarily large lines.
Changes:
- client/transport/stdio.go: Changed stdout from *bufio.Scanner to *bufio.Reader
- testdata/mockstdio_server.go: Applied same fix to mock server
- client/transport/stdio_test.go: Added TestStdio_LargeMessages with tests for
messages ranging from 1KB to 5MB to ensure the fix works correctly
The original code (pre-commit 4e353ac) used bufio.Reader, but was incorrectly
changed to Scanner claiming it would avoid panics with long lines. This fix
reverts to the Reader approach which actually handles large messages correctly.
Fixes issue where stdio clients fail with 'bufio.Scanner: token too long' error
when communicating with servers that send large responses.
0 commit comments