Support progress notifications with McpClientTool and McpClientExtensions.CallToolAsync (#312)
This commit is contained in:
parent
90748b1198
commit
227f440ab9
2 changed files with 174 additions and 47 deletions
|
|
@ -33,7 +33,7 @@ public class CancellationTests : ClientServerTestBase
|
|||
[Fact]
|
||||
public async Task PrecancelRequest_CancelsBeforeSending()
|
||||
{
|
||||
var client = await CreateMcpClientForServer();
|
||||
await using var client = await CreateMcpClientForServer();
|
||||
|
||||
bool gotCancellation = false;
|
||||
await using (Server.RegisterNotificationHandler(NotificationMethods.CancelledNotification, (notification, cancellationToken) =>
|
||||
|
|
@ -51,7 +51,7 @@ public class CancellationTests : ClientServerTestBase
|
|||
[Fact]
|
||||
public async Task CancellationPropagation_RequestingCancellationCancelsPendingRequest()
|
||||
{
|
||||
var client = await CreateMcpClientForServer();
|
||||
await using var client = await CreateMcpClientForServer();
|
||||
|
||||
var tools = await client.ListToolsAsync(cancellationToken: TestContext.Current.CancellationToken);
|
||||
var waitTool = tools.First(t => t.Name == nameof(WaitForCancellation));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class NotificationHandlerTests : ClientServerTestBase
|
|||
public async Task RegistrationsAreRemovedWhenDisposed()
|
||||
{
|
||||
const string NotificationName = "somethingsomething";
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
await using IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
const int Iterations = 10;
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ public class NotificationHandlerTests : ClientServerTestBase
|
|||
public async Task MultipleRegistrationsResultInMultipleCallbacks()
|
||||
{
|
||||
const string NotificationName = "somethingsomething";
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
await using IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
const int RegistrationCount = 10;
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ public class NotificationHandlerTests : ClientServerTestBase
|
|||
public async Task MultipleHandlersRunEvenIfOneThrows()
|
||||
{
|
||||
const string NotificationName = "somethingsomething";
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
await using IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
const int RegistrationCount = 10;
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ public class NotificationHandlerTests : ClientServerTestBase
|
|||
public async Task DisposeAsyncDoesNotCompleteWhileNotificationHandlerRuns(int numberOfDisposals)
|
||||
{
|
||||
const string NotificationName = "somethingsomething";
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
await using IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
var handlerRunning = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var releaseHandler = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
|
@ -163,7 +163,7 @@ public class NotificationHandlerTests : ClientServerTestBase
|
|||
public async Task DisposeAsyncCompletesImmediatelyWhenInvokedFromHandler(int numberOfDisposals)
|
||||
{
|
||||
const string NotificationName = "somethingsomething";
|
||||
IMcpClient client = await CreateMcpClientForServer();
|
||||
await using IMcpClient client = await CreateMcpClientForServer();
|
||||
|
||||
var handlerRunning = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
var releaseHandler = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
|
|
|||
Loading…
Reference in a new issue