Send DELETE request when closing a Streamable HTTP session on the client#501
Merged
halter73 merged 6 commits intomodelcontextprotocol:mainfrom Jun 19, 2025
Merged
Send DELETE request when closing a Streamable HTTP session on the client#501halter73 merged 6 commits intomodelcontextprotocol:mainfrom
halter73 merged 6 commits intomodelcontextprotocol:mainfrom
Conversation
halter73
commented
Jun 10, 2025
src/ModelContextProtocol.Core/Client/StreamableHttpClientSessionTransport.cs
Outdated
Show resolved
Hide resolved
stephentoub
reviewed
Jun 10, 2025
src/ModelContextProtocol.Core/Client/StreamableHttpClientSessionTransport.cs
Outdated
Show resolved
Hide resolved
src/ModelContextProtocol.Core/Client/StreamableHttpClientSessionTransport.cs
Outdated
Show resolved
Hide resolved
- Catch and log errors - Send _negotiatedProtocolVersion
…sposed multiple times - This is the same approach we use in McpEndpoint and SseWriter - I went for a minimal change, but I can copy this to TransportBase if we like to use it for all derived types - We could also update AutoDetectingClientSessionTransport.InitializeAsync to avoid this, but we shouldn't have to
Contributor
Author
|
I updated this PR to now log any exceptions that might be thrown while sending the delete request. I also included a fix for #512 so we don't have to wait on the auth PR. I scoped the ODE fix down to the StreamableHttpClientSessionTransport for now, but I could move this down to TransportBase in a later PR if we like the approach. And finally, I also included a workaround for the race in Kestrel I describe in dotnet/aspnetcore#62385 that was causing some of our tests to hang. Until Kestrel is fixed, Kestrel may still think that it's waiting on the client to close the connection during shutdown causing Kestrel to unnecessarily wait an extra 30 seconds when the race condition occurs, but at least the tests should finish. |
stephentoub
reviewed
Jun 19, 2025
src/ModelContextProtocol.Core/Client/StreamableHttpClientSessionTransport.cs
Outdated
Show resolved
Hide resolved
stephentoub
approved these changes
Jun 19, 2025
…onTransport.cs Co-authored-by: Stephen Toub <stoub@microsoft.com>
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.
This updates StreamableHttpClientSessionTransport.DisposeAsyncto send a delete request.
https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http