Add McpClient/Session methods using .Protocol types (#1063)

This commit is contained in:
Stephen Toub 2025-12-05 13:45:12 -05:00 • committed by GitHub
commit 4a84412331
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1116 additions and 639 deletions

View file

@ -35,7 +35,7 @@ public abstract class HttpServerIntegrationTests : LoggedTest, IClassFixture<Sse
// Act
await using var client = await GetClientAsync();
await client.PingAsync(null, TestContext.Current.CancellationToken);
await client.PingAsync(cancellationToken: TestContext.Current.CancellationToken);
// Assert
Assert.NotNull(client);
@ -139,7 +139,7 @@ public abstract class HttpServerIntegrationTests : LoggedTest, IClassFixture<Sse
// act
await using var client = await GetClientAsync();
IList<McpClientResource> allResources = await client.ListResourcesAsync(null, TestContext.Current.CancellationToken);
IList<McpClientResource> allResources = await client.ListResourcesAsync(cancellationToken: TestContext.Current.CancellationToken);
// The everything server provides 100 test resources
Assert.Equal(100, allResources.Count);
@ -190,7 +190,7 @@ public abstract class HttpServerIntegrationTests : LoggedTest, IClassFixture<Sse
// act
await using var client = await GetClientAsync();
var prompts = await client.ListPromptsAsync(null, TestContext.Current.CancellationToken);
var prompts = await client.ListPromptsAsync(cancellationToken: TestContext.Current.CancellationToken);
// assert
Assert.NotNull(prompts);

View file

@ -88,7 +88,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
mcpServer.RegisterNotificationHandler("test/notification", async (notification, cancellationToken) =>
{
Assert.Equal("Hello from client!", notification.Params?["message"]?.GetValue<string>());
await mcpServer.SendNotificationAsync("test/notification", new Envelope { Message = "Hello from server!" }, serializerOptions: JsonContext.Default.Options, cancellationToken: cancellationToken);
await mcpServer.SendNotificationAsync("test/notification", new Envelope { Message = "Hello from server!" }, serializerOptions: JsonContext.Default.Options, cancellationToken);
});
return mcpServer.RunAsync(cancellationToken);
};