Default draft protocol support: sessionless + handshake-less (SEP-2575 + SEP-2567) (#1610)

This commit is contained in:
Stephen Halter 2026-06-23 21:24:22 -07:00 • committed by GitHub
commit 6c323e783b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
@ -31,7 +31,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
[Fact]
public async Task ConnectAndReceiveMessage_InMemoryServer()
{
Builder.Services.AddMcpServer().WithHttpTransport(options => options.EnableLegacySse = true);
Builder.Services.AddMcpServer().WithHttpTransport(options => { options.EnableLegacySse = true; options.Stateless = false; });
await using var app = Builder.Build();
app.MapMcp();
await app.StartAsync(TestContext.Current.CancellationToken);
@ -84,6 +84,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
.WithHttpTransport(httpTransportOptions =>
{
httpTransportOptions.EnableLegacySse = true;
httpTransportOptions.Stateless = false;
#pragma warning disable MCPEXP002 // RunSessionHandler is experimental
httpTransportOptions.RunSessionHandler = (httpContext, mcpServer, cancellationToken) =>
{
@ -128,7 +129,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
{
firstOptionsCallbackCallCount++;
})
.WithHttpTransport(options => options.EnableLegacySse = true)
.WithHttpTransport(options => { options.EnableLegacySse = true; options.Stateless = false; })
.WithTools<EchoTool>();
Builder.Services.AddMcpServer(options =>
@ -172,7 +173,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
public async Task AdditionalHeaders_AreSent_InGetAndPostRequests()
{
Builder.Services.AddMcpServer()
.WithHttpTransport(options => options.EnableLegacySse = true);
.WithHttpTransport(options => { options.EnableLegacySse = true; options.Stateless = false; });
await using var app = Builder.Build();
@ -219,7 +220,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
public async Task EmptyAdditionalHeadersKey_Throws_InvalidOperationException()
{
Builder.Services.AddMcpServer()
.WithHttpTransport(options => options.EnableLegacySse = true);
.WithHttpTransport(options => { options.EnableLegacySse = true; options.Stateless = false; });
await using var app = Builder.Build();
@ -311,7 +312,7 @@ public partial class SseIntegrationTests(ITestOutputHelper outputHelper) : Kestr
[Fact]
public async Task Completion_ServerShutdown_ReturnsHttpCompletionDetails()
{
Builder.Services.AddMcpServer().WithHttpTransport(options => options.EnableLegacySse = true);
Builder.Services.AddMcpServer().WithHttpTransport(options => { options.EnableLegacySse = true; options.Stateless = false; });
await using var app = Builder.Build();
app.MapMcp();
await app.StartAsync(TestContext.Current.CancellationToken);