Repository navigation
Closed
Milestone
Description
Describe the bug
GET requests with valid session IDs do not immediately return HTTP headers as required by the MCP specification. Instead, they hang indefinitely until the client disconnects, at which point they return a 204 status.
According to the MCP Streamable HTTP Transport specification:
"The server MUST either return Content-Type: text/event-stream in response to this HTTP GET, or else return HTTP 405 Method Not Allowed, indicating that the server does not offer an SSE stream at this endpoint."
To Reproduce
Steps to reproduce the behavior:
- Run any streamable HTTP MCP server, for example:
func main() {
// Create a minimal MCP server
server := mcp.NewServer(&mcp.Implementation{
Name: "minimal-test-server",
Version: "1.0.0",
}, nil)
handler := mcp.NewStreamableHTTPHandler(func(req *http.Request) *mcp.Server {
return server
}, nil)
port := 8010
log.Printf("Starting minimal reproduction server on localhost:%d", port)
if err := http.ListenAndServe(fmt.Sprintf("localhost:%d", port), handler); err != nil {
log.Fatalf("Server failed: %v", err)
}
}
- Establish session
curl -X POST http://localhost:8010/ \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0.0"}}}' -i
- Extract
Mcp-Session-Idfrom response - Make a GET request
curl -v -H "Accept: text/event-stream" -H "Mcp-Session-Id: <SESSION_ID>" http://localhost:8010/ --max-time 30
Expected behavior
When a client makes a GET request with a valid Mcp-Session-Id header:
- Server should immediately respond with HTTP status 200 and headers including
Content-Type: text/event-stream - Connection should remain open to stream server-sent events
Actual behavior
- Server receives the GET request
- No HTTP response headers are sent immediately
- Request hangs indefinitely
- Only when client disconnects/times out does server respond with status 204
Reacted by Petar Petrov
Reacted by Radoslav Dimitrov
Activity
findleyr commentedon Sep 4, 2025
We do send text/event-stream, and 204 (no content) seems right when there are no messages along the hanging GET.
go-sdk/mcp/streamable.go
Line 749 in a1eb484
If any data is written to the hanging GET, headers should be written along with status 200.
It sounds like the problems is that we need to force a flush of headers.
Can you say more about the problems this caused in practice? Is there a client that blocks until it receives the content-type header?
mcp: flush headers immediately for the hanging GET
mcp: flush headers immediately for the hanging GET
mcp: flush headers immediately for the hanging GET
findleyr commentedon Sep 4, 2025
Indeed, an explicit Flush fixes this. Thank you for the report.
eleftherias commentedon Sep 4, 2025
Block's Goose blocks waiting for the response.
mcp: flush headers immediately for the hanging GET
findleyr commentedon Sep 4, 2025
@eleftherias would very much appreciate if you could verify that this fixes the problem you experienced.
eleftherias commentedon Sep 5, 2025
Thanks @findleyr this fixes the issue
mcp: write SSE comment on standalone stream so HTTP/2 reverse proxies…
mcp: keep a long-running POST stream visibly alive