Add client-side Streamable HTTP transport support (#356)
This commit is contained in:
parent
7c507bc1d7
commit
e913d80f05
1 changed files with 908 additions and 464 deletions
|
|
@ -0,0 +1,36 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ModelContextProtocol.AspNetCore.Tests;
|
||||
|
||||
public class MapMcpStreamableHttpTests(ITestOutputHelper outputHelper) : MapMcpTests(outputHelper)
|
||||
{
|
||||
protected override bool UseStreamableHttp => true;
|
||||
|
||||
[Theory]
|
||||
[InlineData("/a", "/a")]
|
||||
[InlineData("/a", "/a/")]
|
||||
[InlineData("/a/", "/a/")]
|
||||
[InlineData("/a/", "/a")]
|
||||
[InlineData("/a/b", "/a/b")]
|
||||
public async Task CanConnect_WithMcpClient_AfterCustomizingRoute(string routePattern, string requestPath)
|
||||
{
|
||||
Builder.Services.AddMcpServer(options =>
|
||||
{
|
||||
options.ServerInfo = new()
|
||||
{
|
||||
Name = "TestCustomRouteServer",
|
||||
Version = "1.0.0",
|
||||
};
|
||||
}).WithHttpTransport();
|
||||
await using var app = Builder.Build();
|
||||
|
||||
app.MapMcp(routePattern);
|
||||
|
||||
await app.StartAsync(TestContext.Current.CancellationToken);
|
||||
|
||||
var mcpClient = await ConnectAsync(requestPath);
|
||||
|
||||
Assert.Equal("TestCustomRouteServer", mcpClient.ServerInfo.Name);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue