mcp: add StreamableHTTPOptions.SessionTimeout#594
Merged
findleyr merged 1 commit intomodelcontextprotocol:mainfrom Oct 23, 2025
Merged
mcp: add StreamableHTTPOptions.SessionTimeout#594findleyr merged 1 commit intomodelcontextprotocol:mainfrom
findleyr merged 1 commit intomodelcontextprotocol:mainfrom
Conversation
a8a2ec8 to
753347d
Compare
neild
reviewed
Oct 20, 2025
| handler := NewStreamableHTTPHandler( | ||
| func(req *http.Request) *Server { return server }, | ||
| &StreamableHTTPOptions{ | ||
| SessionTimeout: 50 * time.Millisecond, |
There was a problem hiding this comment.
This would be a good use for testing/synctest, but it would require limiting the test to only running on Go 1.25+.
Contributor
Author
There was a problem hiding this comment.
Unfortunately, it doesn't work because the test uses httptest.NewServer, which does (real) I/O. Therefore, synctest.Wait never terminates.
022deb2 to
1b00937
Compare
230e352 to
1b00937
Compare
Contributor
Author
|
Staticcheck failures are being addressed in #599. |
jba
previously approved these changes
Oct 22, 2025
Add a timeout option for the streamable HTTP handler that automatically cleans up idle sessions. Also, fix a bug in the streamable client, where we hang on a request even though the client can never get a response (because the HTTP request terminated without a response or Last-Event-Id). Fixes modelcontextprotocol#499
1b00937 to
3188ac5
Compare
findleyr
commented
Oct 22, 2025
Contributor
Author
findleyr
left a comment
There was a problem hiding this comment.
PTAL, the only substantive change was updating the test to have multiple goroutines keeping the session alive (as suggested), but I also had to rebase to pick up the fixes to CI.
jba
approved these changes
Oct 22, 2025
RatStar811
approved these changes
Nov 19, 2025
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.
Add a timeout option for the streamable HTTP handler that automatically cleans up idle sessions.
Also, fix a bug in the streamable client, where we hang on a request even though the client can never get a response (because the HTTP request terminated without a response or Last-Event-Id).
Fixes #499