Wrap each request in a service scope (#276)
* Wrap each request in a service scope * Change request/notification delegates to return ValueTask * Address feedback
This commit is contained in:
parent
f1cc2d81de
commit
f4c87f5e2f
2 changed files with 477 additions and 306 deletions
|
|
@ -381,7 +381,7 @@ public class McpClientExtensionsTests : ClientServerTestBase
|
|||
(notification, cancellationToken) =>
|
||||
{
|
||||
Assert.True(channel.Writer.TryWrite(JsonSerializer.Deserialize<LoggingMessageNotificationParams>(notification.Params, McpJsonUtilities.DefaultOptions)));
|
||||
return Task.CompletedTask;
|
||||
return default;
|
||||
}))
|
||||
{
|
||||
logger.LogTrace("Trace {Message}", "message");
|
||||
|
|
|
|||
|
|
@ -41,18 +41,19 @@ public class McpClientFactoryTests
|
|||
{
|
||||
Sampling = new SamplingCapability
|
||||
{
|
||||
SamplingHandler = (c, p, t) => Task.FromResult(
|
||||
new CreateMessageResult {
|
||||
SamplingHandler = async (c, p, t) =>
|
||||
new CreateMessageResult
|
||||
{
|
||||
Content = new Content { Text = "result" },
|
||||
Model = "test-model",
|
||||
Role = Role.User,
|
||||
StopReason = "endTurn"
|
||||
}),
|
||||
},
|
||||
},
|
||||
Roots = new RootsCapability
|
||||
{
|
||||
ListChanged = true,
|
||||
RootsHandler = (t, r) => Task.FromResult(new ListRootsResult { Roots = [] }),
|
||||
RootsHandler = async (t, r) => new ListRootsResult { Roots = [] },
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue