Add McpSessions.NegotiatedProtocolVersion property. (#794)

This commit is contained in:
Eirik Tsarpalis 2025-09-19 13:11:01 +03:00 • committed by GitHub
commit 7cfe0ef621
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,6 +26,7 @@ internal sealed partial class McpClientImpl : McpClient
private ServerCapabilities? _serverCapabilities;
private Implementation? _serverInfo;
private string? _serverInstructions;
private string? _negotiatedProtocolVersion;
private bool _disposed;
@ -112,6 +113,9 @@ internal sealed partial class McpClientImpl : McpClient
/// <inheritdoc/>
public override string? SessionId => _transport.SessionId;
/// <inheritdoc/>
public override string? NegotiatedProtocolVersion => _negotiatedProtocolVersion;
/// <inheritdoc/>
public override ServerCapabilities ServerCapabilities => _serverCapabilities ?? throw new InvalidOperationException("The client is not connected.");
@ -177,6 +181,8 @@ internal sealed partial class McpClientImpl : McpClient
throw new McpException($"Server protocol version mismatch. Expected {requestProtocol}, got {initializeResponse.ProtocolVersion}");
}
_negotiatedProtocolVersion = initializeResponse.ProtocolVersion;
// Send initialized notification
await this.SendNotificationAsync(
NotificationMethods.InitializedNotification,