-
Notifications
You must be signed in to change notification settings - Fork 568
Description
Is your feature request related to a problem? Please describe.**
We use McpClientFactory.CreateAsync to get an MCPClient instance to interact with the MCP server. Each time McpClientFactory.CreateAsync is invoked, a fresh session is established. In our case, this results in different sessions being created for different turns within the same conversation.
We need a way to reuse the same session across successive turns.
Describe the solution you'd like
Persistent Sessions
Provide an option during McpClient instantiation (e.g., a flag or parameter) to prevent sending a session deletion request to the MCP server when the McpClient instance is disposed. This allows the server-side session to remain active after the client object is disposed.
Session Resumption Capability
Introduce a mechanism to resume an existing session on subsequent turns. For example:
- Allow passing a previously obtained
sessionId(along with negotiated protocol version and capabilities) intoMcpClientFactory.CreateAsync, or - Introduce a new method such as
ResumeSessionAsync.
This would allow the client to reconnect to an existing session instead of starting a new one.
Session State Persistence
Support capturing and reusing session state between turns. This could work in two ways:
-
SDK-Provided Serialization:
Provide a method or property to retrieve the session details (sessionId, protocol version, negotiated capabilities) in a serialized form that can be persisted and later supplied to resume the session. -
Caller-Managed Persistence:
Document and support a workflow where the application persists the session details itself and passes them back into the SDK to resume the session.