Default draft protocol support: sessionless + handshake-less (SEP-2575 + SEP-2567) (#1610)
This commit is contained in:
parent
3368bb7349
commit
6c323e783b
1 changed files with 5704 additions and 712 deletions
|
|
@ -58,7 +58,11 @@ public sealed class McpServerResourceRoutingTests(ITestOutputHelper testOutputHe
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asserts that the given URI does NOT match the template.
|
||||
/// 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
|
||||
/// 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"/>.
|
||||
/// </summary>
|
||||
private async Task AssertNoMatchAsync(
|
||||
string uriTemplate,
|
||||
|
|
@ -71,7 +75,7 @@ public sealed class McpServerResourceRoutingTests(ITestOutputHelper testOutputHe
|
|||
var ex = await Assert.ThrowsAsync<McpProtocolException>(async () =>
|
||||
await client.ReadResourceAsync(uri, null, TestContext.Current.CancellationToken));
|
||||
|
||||
Assert.Equal(McpErrorCode.ResourceNotFound, ex.ErrorCode);
|
||||
Assert.Equal(McpErrorCode.InvalidParams, ex.ErrorCode);
|
||||
}
|
||||
|
||||
// Unknown-resource-URI responses are version-gated: older clients keep the legacy
|
||||
|
|
@ -79,7 +83,7 @@ public sealed class McpServerResourceRoutingTests(ITestOutputHelper testOutputHe
|
|||
// moves to the standard JSON-RPC code see -32602 (McpErrorCode.InvalidParams).
|
||||
[Theory]
|
||||
[InlineData("2025-11-25", McpErrorCode.ResourceNotFound)]
|
||||
[InlineData("DRAFT-2026-v1", McpErrorCode.InvalidParams)]
|
||||
[InlineData("2026-07-28", McpErrorCode.InvalidParams)]
|
||||
public async Task ResourceNotFound_ErrorCode_IsVersionGated(string serverProtocolVersion, McpErrorCode expectedCode)
|
||||
{
|
||||
var resource = McpServerResource.Create(
|
||||
|
|
@ -130,7 +134,9 @@ 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));
|
||||
Assert.Equal(McpErrorCode.ResourceNotFound, mcpEx.ErrorCode);
|
||||
// Draft 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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue