-
Notifications
You must be signed in to change notification settings - Fork 574
Closed
Description
Problem
The StreamableHttpClientSessionTransport class automatically sends a DELETE request to terminate the session when the transport is disposed (in the DisposeAsync method). This behavior cannot be controlled by the consumer and may not always be desired.
Also, a consumer may need multiple transports to share the same session id. How could that be implemented?
Current Behavior
public override async ValueTask DisposeAsync()
{
// ...
// Send DELETE request to terminate the session. Only send if we have a session ID, per MCP spec.
if (!string.IsNullOrEmpty(SessionId))
{
await SendDeleteRequest();
}
// ...
}Requested Enhancement
Provide a way to control whether the DELETE request should be sent automatically on disposal. This could be implemented as:
- Add a boolean property/option (e.g.,
AutoTerminateSession) toSseClientTransportOptionsthat defaults totruefor backward compatibility - Add a separate public method like
TerminateSessionAsync()that can be called explicitly
Use Case
There are scenarios where:
- The session should persist beyond the transport's lifetime
- Session termination should be handled at a different layer
- Multiple transports might share the same session
- The application wants to handle session cleanup differently based on the disposal reason
Metadata
Metadata
Assignees
Labels
No labels