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

@ -8,8 +8,8 @@ namespace ModelContextProtocol.Tests.Server;
/// <summary>
/// Verifies that the built-in <c>ping</c> handler is gated by protocol version.
/// SEP-2575 (the 2026-07-28 revision) removes <c>ping</c>; servers must
/// respond with <c>-32601 MethodNotFound</c>. Legacy protocol versions still
/// support <c>ping</c> per the spec.
/// respond with <c>-32601 MethodNotFound</c>. Initialize-handshake protocol
/// versions still support <c>ping</c> per the spec.
/// </summary>
public sealed class PingProtocolGatingTests : ClientServerTestBase
{
@ -28,7 +28,7 @@ public sealed class PingProtocolGatingTests : ClientServerTestBase
StartServer();
await using var client = await CreateMcpClientForServer(new McpClientOptions
{
ProtocolVersion = McpHttpHeaders.July2026ProtocolVersion,
ProtocolVersion = McpProtocolVersions.July2026ProtocolVersion,
});
var ex = await Assert.ThrowsAsync<McpProtocolException>(async () =>
@ -38,13 +38,13 @@ public sealed class PingProtocolGatingTests : ClientServerTestBase
}
[Fact]
public async Task Ping_OnLegacySession_StillSucceeds()
public async Task Ping_OnInitializeHandshakeSession_StillSucceeds()
{
// Default server config; client pinned to 2025-11-25.
StartServer();
await using var client = await CreateMcpClientForServer(new McpClientOptions
{
ProtocolVersion = "2025-11-25",
ProtocolVersion = McpProtocolVersions.November2025ProtocolVersion,
});
var result = await client.PingAsync(cancellationToken: TestContext.Current.CancellationToken);