Follow-ups to #1610: de-draft 2026-07-28 terminology, renumber error codes, ProtocolVersion floor (#1671)

This commit is contained in:
Stephen Halter 2026-06-25 14:07:52 -07:00 • committed by GitHub
commit d6b1615988
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 785 additions and 898 deletions

View file

@ -74,7 +74,7 @@ public class McpServerBuilderExtensionsMessageFilterTests(ITestOutputHelper test
{
List<string> messageTypes = [];
// Under the draft protocol the client performs a server/discover + tools/list exchange (no
// Under the 2026-07-28 protocol the client performs a server/discover + tools/list exchange (no
// fire-and-forget initialized notification), so the tools/list request is a deterministic
// synchronization point. Gate recording to it and signal once the filter finishes so a
// regression that invokes the filter pipeline more than once per message surfaces as an extra entry.
@ -112,7 +112,7 @@ public class McpServerBuilderExtensionsMessageFilterTests(ITestOutputHelper test
[Fact]
public async Task AddIncomingMessageFilter_Multiple_Filters_Execute_In_Order()
{
// Under the draft protocol the client performs a server/discover + tools/list exchange (no
// Under the 2026-07-28 protocol the client performs a server/discover + tools/list exchange (no
// fire-and-forget initialized notification), so the tools/list request is a deterministic
// synchronization point. Gate the filter logging to it and signal once the outermost filter
// finishes so the assertions observe a complete, stable log.
@ -393,7 +393,7 @@ public class McpServerBuilderExtensionsMessageFilterTests(ITestOutputHelper test
var clientOptions = new McpClientOptions
{
// This test observes the legacy outgoing flow on the server side: the initialize response and
// the server->client sampling/createMessage request. Under the draft protocol those are replaced
// the server->client sampling/createMessage request. Under the 2026-07-28 protocol those are replaced
// by server/discover and implicit MRTR (InputRequiredResult), which is covered by MrtrIntegrationTests.
// Pin to the latest stable version to keep exercising the legacy server->client request path here.
ProtocolVersion = LatestStableVersion,

View file

@ -1,4 +1,4 @@
using Microsoft.Extensions.AI;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -128,12 +128,12 @@ public partial class McpServerBuilderExtensionsPromptsTests : ClientServerTestBa
[Fact]
public async Task Can_Be_Notified_Of_Prompt_Changes()
{
// Under the draft revision, list-changed notifications are delivered only over a
// Under the 2026-07-28 protocol, list-changed notifications are delivered only over a
// subscriptions/listen stream (covered by SubscriptionsListenTests). This test pins the
// legacy revision to keep coverage of the session-wide broadcast that legacy clients still rely on.
await using McpClient client = await CreateMcpClientForServer(new McpClientOptions
{
ProtocolVersion = McpSession.LatestProtocolVersion,
ProtocolVersion = McpHttpHeaders.November2025ProtocolVersion,
});

View file

@ -1,4 +1,4 @@
using Microsoft.Extensions.AI;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -162,12 +162,12 @@ public partial class McpServerBuilderExtensionsResourcesTests : ClientServerTest
[Fact]
public async Task Can_Be_Notified_Of_Resource_Changes()
{
// Under the draft revision, list-changed notifications are delivered only over a
// Under the 2026-07-28 protocol, list-changed notifications are delivered only over a
// subscriptions/listen stream (covered by SubscriptionsListenTests). This test pins the
// legacy revision to keep coverage of the session-wide broadcast that legacy clients still rely on.
await using McpClient client = await CreateMcpClientForServer(new McpClientOptions
{
ProtocolVersion = McpSession.LatestProtocolVersion,
ProtocolVersion = McpHttpHeaders.November2025ProtocolVersion,
});

View file

@ -1,4 +1,4 @@
using Microsoft.Extensions.AI;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -188,12 +188,12 @@ public partial class McpServerBuilderExtensionsToolsTests : ClientServerTestBase
[Fact]
public async Task Can_Be_Notified_Of_Tool_Changes()
{
// Under the draft revision, list-changed notifications are delivered only over a
// Under the 2026-07-28 protocol, list-changed notifications are delivered only over a
// subscriptions/listen stream (covered by SubscriptionsListenTests). This test pins the
// legacy revision to keep coverage of the session-wide broadcast that legacy clients still rely on.
await using McpClient client = await CreateMcpClientForServer(new McpClientOptions
{
ProtocolVersion = McpSession.LatestProtocolVersion,
ProtocolVersion = McpHttpHeaders.November2025ProtocolVersion,
});
var tools = await client.ListToolsAsync(cancellationToken: TestContext.Current.CancellationToken);

View file

@ -59,7 +59,7 @@ public sealed class McpServerResourceRoutingTests(ITestOutputHelper testOutputHe
/// <summary>
/// Asserts that the given URI does NOT match the template. Uses the default client, which
/// negotiates the draft protocol revision, so the unknown-resource response carries the
/// negotiates the 2026-07-28 protocol revision, so the unknown-resource response carries the
/// standard JSON-RPC <see cref="McpErrorCode.InvalidParams"/> (-32602). The version-gated
/// legacy mapping to <see cref="McpErrorCode.ResourceNotFound"/> (-32002) is covered by
/// <see cref="ResourceNotFound_ErrorCode_IsVersionGated"/>.
@ -79,7 +79,7 @@ public sealed class McpServerResourceRoutingTests(ITestOutputHelper testOutputHe
}
// Unknown-resource-URI responses are version-gated: older clients keep the legacy
// -32002 (McpErrorCode.ResourceNotFound), and clients on the draft protocol version that
// -32002 (McpErrorCode.ResourceNotFound), and clients on the 2026-07-28 protocol version that
// moves to the standard JSON-RPC code see -32602 (McpErrorCode.InvalidParams).
[Theory]
[InlineData("2025-11-25", McpErrorCode.ResourceNotFound)]
@ -134,7 +134,7 @@ public sealed class McpServerResourceRoutingTests(ITestOutputHelper testOutputHe
// Literal template braces in URI should not match (template literal is not a valid URI)
var mcpEx = await Assert.ThrowsAsync<McpProtocolException>(async () => await client.ReadResourceAsync("test://params{?a1,a2,a3}", null, TestContext.Current.CancellationToken));
// Draft maps an unmatched resource URI to InvalidParams (-32602); the legacy -32002 ResourceNotFound
// The 2026-07-28 protocol maps an unmatched resource URI to InvalidParams (-32602); the legacy -32002 ResourceNotFound
// mapping is covered by the version-gated ResourceNotFound_ErrorCode_IsVersionGated theory.
Assert.Equal(McpErrorCode.InvalidParams, mcpEx.ErrorCode);
Assert.Equal("Request failed (remote): Unknown resource URI: 'test://params{?a1,a2,a3}'", mcpEx.Message);