Pass session id's to MCP endpoints. (#466)
* Pass session id's to MCP endpoints. * Update src/ModelContextProtocol/Client/McpClient.cs Co-authored-by: Stephen Halter <halter73@gmail.com> * Update src/ModelContextProtocol.AspNetCore/StreamableHttpHandler.cs Co-authored-by: Stephen Halter <halter73@gmail.com> * Make init callback asynchronous. * Address feedback. --------- Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
fa017c04c3
commit
d7d9eab3f8
2 changed files with 166 additions and 21 deletions
|
|
@ -25,6 +25,14 @@ namespace ModelContextProtocol.Protocol;
|
|||
/// </remarks>
|
||||
public interface ITransport : IAsyncDisposable
|
||||
{
|
||||
/// <summary>Gets an identifier associated with the current MCP session.</summary>
|
||||
/// <remarks>
|
||||
/// Typically populated in transports supporting multiple sessions such as Streamable HTTP or SSE.
|
||||
/// Can return <see langword="null"/> if the session hasn't initialized or if the transport doesn't
|
||||
/// support multiple sessions (as is the case with STDIO).
|
||||
/// </remarks>
|
||||
string? SessionId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a channel reader for receiving messages from the transport.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -59,6 +59,9 @@ public abstract partial class TransportBase : ITransport
|
|||
/// <summary>Gets the logger used by this transport.</summary>
|
||||
private protected ILogger Logger => _logger;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public virtual string? SessionId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name that identifies this transport endpoint in logs.
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue