Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ModelContextProtocol.Core/Client/McpClientImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ public async Task ConnectAsync(CancellationToken cancellationToken = default)

// Validate protocol version
bool isResponseProtocolValid =
_options.ProtocolVersion is { } optionsProtocol ? optionsProtocol == initializeResponse.ProtocolVersion :
McpSessionHandler.SupportedProtocolVersions.Contains(initializeResponse.ProtocolVersion);
McpSessionHandler.SupportedProtocolVersions.Contains(initializeResponse.ProtocolVersion) ||
(_options.ProtocolVersion is { } optionsProtocol && optionsProtocol == initializeResponse.ProtocolVersion);
if (!isResponseProtocolValid)
{
LogServerProtocolVersionMismatch(_endpointName, requestProtocol, initializeResponse.ProtocolVersion);
Expand Down
9 changes: 9 additions & 0 deletions tests/ModelContextProtocol.Tests/Client/McpClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,15 @@ public async Task ReturnsNegotiatedProtocolVersion(string? protocolVersion)
Assert.Equal(protocolVersion ?? "2025-11-25", client.NegotiatedProtocolVersion);
}

[Theory]
[InlineData("2025-11-25", "2025-06-18")]
public async Task AcceptsLowerServerProtocolVersion(string clientVersion, string serverVersion)
{
Server.ServerOptions.ProtocolVersion = serverVersion;
await using McpClient client = await CreateMcpClientForServer(new() { ProtocolVersion = clientVersion });
Assert.Equal(serverVersion, client.NegotiatedProtocolVersion);
}

[Fact]
public async Task EndToEnd_SamplingWithTools_ServerUsesIChatClientWithFunctionInvocation_ClientHandlesSamplingWithIChatClient()
{
Expand Down
Loading