- It allows a single MCP session spanning multiple requests to be handled by different servers without sharing state - It does require the servers share data protection keys, but this is standard for ASP.NET Core cookies and antiforgery as well - It immediately throws for unsupported operations like sampling
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace ModelContextProtocol.AspNetCore.Tests;
|
|
|
|
public class MapMcpStreamableHttpTests(ITestOutputHelper outputHelper) : MapMcpTests(outputHelper)
|
|
{
|
|
protected override bool UseStreamableHttp => true;
|
|
protected override bool Stateless => false;
|
|
|
|
[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(ConfigureStateless);
|
|
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);
|
|
}
|
|
}
|