mcp-go
mcp-go copied to clipboard
bug: transport/streamable_http.go context timeout on sse stream
Description
There is a timeout set on the context of the sse stream of streamable_http.go, this leads to the stream timing out every 10 seconds
Code Sample
func (c *StreamableHTTP) listenForever(ctx context.Context) {
c.logger.Infof("listening to server forever")
for {
// Add timeout for individual connection attempts
connectCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
err := c.createGETConnectionToServer(connectCtx)
cancel()
Logs or Error Messages
2025/08/19 21:05:26 ERROR: failed to listen to server. retry in 1 second: failed to handle SSE response: context deadline exceeded
Environment
n/a
Additional Context
I feel like that logic was copied from the SSE transport for which timeout made sense since we were waiting from a response json rpc from the server, but here the SSE is only for receiving requests / notifications and not response
Possible Solution
Remove the timeout, or reset the timeout on new messages, relying on heart beat from server