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
**Description**
Fixesenvoyproxy#2219.
The MCP proxy fails `initialize` with `500 failed to create MCP session
to any backend` and logs `MCP message is not a response: <nil>` when a
backend's `initialize` SSE response begins with a non-response event (an
empty/keep-alive `data:` line) before the JSON-RPC result. Some FastMCP
backends do this depending on the requested `protocolVersion` (e.g.
firecrawl with `2025-11-25`).
Two layers caused it:
1. `sseEventParser.parseEvent` (`internal/mcpproxy/sse.go`) called
`jsonrpc.DecodeMessage` on an empty `data:` line, which errors, so the
whole leading event was returned as a parse error.
2. The initialize reader loop (`internal/mcpproxy/mcpproxy.go`) treated
that non-EOF error as fatal and broke with `rawMsg` still nil, then
reported it as "not a response".
This change:
- Skips empty `data:` lines in the SSE parser (keep-alive/heartbeat
events carry no message to decode). Non-empty but malformed data still
errors as before.
- Makes the initialize reader skip non-response events and keep reading
until it finds the JSON-RPC `*Response`, instead of requiring the first
event to be the response.
**Testing**
- `TestSSEEventParser_EmptyDataLineSkipped` — a leading event with an
empty data line yields an event with no messages and no error; the
following event still decodes.
- `TestNewSession_SSEWithLeadingKeepAlive` — a backend whose initialize
SSE response starts with an empty keep-alive event before the real
response now initializes successfully (this test reproduced the `MCP
message is not a response: <nil>` failure before the fix).
```
go test ./internal/mcpproxy/
go vet ./internal/mcpproxy/
go build ./...
```
Done with AI assistance; I have reviewed every line and understand the
change.
---------
Signed-off-by: pjdurden <prajjwalchittori1@gmail.com>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
Signed-off-by: Daniel Chernovsky <daniel.chernovsky@doubleverify.com>
0 commit comments