Add AspNetCoreSseServer sample (#81)

* Add AspNetCoreSseMcpTransport sample

* Fix build errors after rebase

* React to McpServerFactory changes

* Make Utf8JsonWriter non thread static

* Fix test errors caused by not rebasing the HttpLister changes on factory overhaul commit
This commit is contained in:
Stephen Halter 2025-03-18 03:56:44 -07:00 • committed by GitHub
commit 90dfc35fbd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -280,9 +280,9 @@ public class McpServerTests
await Can_Handle_Requests(
serverCapabilities: null,
method: "completion/complete",
configureOptions: options => options with
configureOptions: options =>
{
GetCompletionHandler = (request, ct) =>
options.GetCompletionHandler = (request, ct) =>
Task.FromResult(new CompleteResult
{
Completion = new()
@ -291,7 +291,7 @@ public class McpServerTests
Total = 2,
HasMore = true
}
})
});
},
assertResult: response =>
{
@ -518,14 +518,11 @@ public class McpServerTests
await Throws_Exception_If_No_Handler_Assigned(new ServerCapabilities { Tools = new() }, "tools/call", "CallTool handler not configured");
}
private async Task Can_Handle_Requests(ServerCapabilities? serverCapabilities, string method, Func<McpServerOptions, McpServerOptions>? configureOptions, Action<object> assertResult)
private async Task Can_Handle_Requests(ServerCapabilities? serverCapabilities, string method, Action<McpServerOptions>? configureOptions, Action<object> assertResult)
{
await using var transport = new TestServerTransport();
var options = CreateOptions(serverCapabilities);
if (configureOptions is not null)
{
options = configureOptions(options);
}
configureOptions?.Invoke(options);
await using var server = new McpServer(transport, options, _loggerFactory.Object, _serviceProvider);