streamable HTTP client: Don't block on standalone SSE Get#634
Closed
richard-rance wants to merge 1 commit intomodelcontextprotocol:mainfrom
Closed
streamable HTTP client: Don't block on standalone SSE Get#634richard-rance wants to merge 1 commit intomodelcontextprotocol:mainfrom
richard-rance wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
When connecting to an MCP server that supports making SSE GET requests client.Connect gets hung up waiting for the first notification from the server. This change modifies the tests to simulate a server that keeps the stand alone SSE connection open. It then adjusts the connection setup to run the standalone SSE connection in the background.
This was referenced Dec 18, 2025
jba
pushed a commit
that referenced
this pull request
Jan 11, 2026
mcp: add DisableStandaloneSSE option to control standalone SSE stream Currently, StreamableClientTransport always establishes a standalone SSE connection after initialization to receive server-initiated messages. While this is useful for receiving notifications like ToolListChangedNotification, it causes problems in several real-world scenarios: 1. **Unnecessary resource usage**: Many use cases (for me), especially in scientific computing scenarios, only require simple request-response communication. Clients don't need server-initiated notifications, making the persistent SSE connection wasteful. 2. **Server compatibility issues**: Some third-party MCP servers don't properly handle GET requests for SSE streams. When the client automatically tries to establish the SSE connection, it fails or hangs, blocking the entire connection process. This is particularly problematic when using third-party servers that cannot be modified. This issue is similar to what was discussed in issue #634. 3. **Lack of user control**: The MCP specification states that the standalone SSE stream is optional ("The client MAY issue an HTTP GET"), but the current SDK implementation doesn't provide a way to opt out. This implementation is also inconsistent with other MCP SDKs like github.com/mark3labs/mcp-go, which provides getListeningEnabled control (defaults to false, requires explicit enablement). Fixes #728 Co-authored-by: zhaoxin <[email protected]>
Quantumshapeshift
approved these changes
Jan 17, 2026
Author
|
Closing in favor of #729 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When connecting to some MCP servers that supports making SSE GET requests, client.Connect gets hung up waiting for the first notification from the server.
More details in issue #633
Solution
This change modifies the tests to simulate a server that keeps the stand alone SSE connection open. It then adjusts the connection setup to run the standalone SSE connection in the background.
Open question
Work was done 2 weeks ago in #604 / #583 to make some errors from starting the stand alone SSE connection be returned as part of client.Connect. I'm not clear on why that is necessary. Clients are not required to accept SSE messages from servers. Stateless clients will want to opt out of even attempting to create the standalone SSE connection.
This PR undoes some of it so may not be the correct solution.
I'll clean up the tests once I know more.