-
Notifications
You must be signed in to change notification settings - Fork 704
Closed
Description
Description
The StreamableHTTP transport's SSE (Server-Sent Events) parser incorrectly requires both event:
and data:
fields to process an SSE event. According to the W3C SSE specification, the event:
field is optional, and SSE events with only data:
fields should be processed normally.
What happened:
- Server responds with a valid SSE stream containing only
data:
field but noevent:
field - The SSE parser recognizes the
data:
field but doesn't trigger the event handler because noevent:
field was present - This results in
unexpected nil response
error and transport failure
What was expected:
- SSE events with only
data:
fields should be processed normally - The
event:
field should be treated as optional
Code Sample
// Current problematic logic in readSSE function
if line == "" {
// Empty line means end of event
if event != "" && data != "" { // ❌ This incorrectly requires both event AND data
handler(event, data)
event = ""
data = ""
}
continue
}
Logs or Error Messages
========= SSE STREAM READING =========
Starting to read SSE stream...
SSE line received: data: {"jsonrpc":"2.0","id":1,"result":{...}}
-> Parsed data: '{"jsonrpc":"2.0","id":1,"result":{...}}'
Empty line received (event boundary)
SSE stream reached EOF
========= SSE RESPONSE COMPLETED =========
Received nil response from SSE stream # ❌ Event handler never called
transport error: unexpected nil response
Environment
- Go version: 1.23
- mcp-go version: latest
- OS: macOS
- Architecture: arm64
Metadata
Metadata
Assignees
Labels
No labels