Tighten draft protocol negotiation boundaries (#1692)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com>
This commit is contained in:
Stephen Halter 2026-07-12 14:30:49 -07:00 • committed by GitHub
commit fd38f51e27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -483,7 +483,7 @@ public class McpClientTests : ClientServerTestBase
[Fact]
public async Task AsClientLoggerProvider_MessagesSentToClient()
{
await using McpClient client = await CreateMcpClientForServer();
await using McpClient client = await CreateMcpClientForServer(new McpClientOptions { ProtocolVersion = McpProtocolVersions.November2025ProtocolVersion });
ILoggerProvider loggerProvider = Server.AsClientLoggerProvider();
Assert.Throws<ArgumentNullException>("categoryName", () => loggerProvider.CreateLogger(null!));
@ -765,7 +765,7 @@ public class McpClientTests : ClientServerTestBase
[Fact]
public async Task SetLoggingLevelAsync_WithRequestParams_SetsLevel()
{
await using McpClient client = await CreateMcpClientForServer();
await using McpClient client = await CreateMcpClientForServer(new McpClientOptions { ProtocolVersion = McpProtocolVersions.November2025ProtocolVersion });
// Should not throw
await client.SetLoggingLevelAsync(
@ -795,9 +795,9 @@ public class McpClientTests : ClientServerTestBase
[Fact]
public async Task ServerCanPingClient()
{
// ping is a legacy-only RPC (removed in the 2026-07-28 protocol per SEP-2575), so pin the client
// to a legacy protocol version to exercise the server-initiated ping round-trip.
await using McpClient client = await CreateMcpClientForServer(new() { ProtocolVersion = "2025-11-25" });
// ping is available only on initialize-handshake revisions (removed in the 2026-07-28 protocol
// per SEP-2575), so pin the client to exercise the server-initiated ping round-trip.
await using McpClient client = await CreateMcpClientForServer(new() { ProtocolVersion = McpProtocolVersions.November2025ProtocolVersion });
var pingRequest = new JsonRpcRequest { Method = RequestMethods.Ping };
var response = await Server.SendRequestAsync(pingRequest, TestContext.Current.CancellationToken);