Fix: Skip non-message SSE events in processStream#637
Conversation
Fixes modelcontextprotocol#636 - SDK now ignores ping and other non-message events
findleyr
left a comment
There was a problem hiding this comment.
Thanks for the quick fix, and thorough tests!
|
Looks like |
|
Added formatting commit (SHA: 1172815). I ran ok github.com/modelcontextprotocol/go-sdk (cached) |
|
Thanks — I formatted |
Fixes #636
Problem
The StreamableClientTransport tries to JSON-decode ALL SSE events, including ping events sent by servers for keep-alive purposes. This causes errors like 'invalid character 'p' looking for beginning of value' when encountering non-JSON event data.
Solution
Modified processStream to check evt.Name and skip events that are not 'message' events (or unnamed events, which default to 'message' per SSE spec).
Changes
Testing