Add HttpServerSessionMode for hybrid stateful/stateless HTTP serving (#1796)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
This commit is contained in:
pardhu 2026-08-12 23:36:36 -07:00 • committed by GitHub
commit c6a97d94d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,5 @@
using Logging.Tools;
using ModelContextProtocol.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
@ -8,8 +9,8 @@ builder.Services.AddMcpServer()
.WithHttpTransport(options =>
{
// Log streaming requires stateful mode because the server pushes log notifications
// to clients. Set Stateless = false explicitly for forward compatibility.
options.Stateless = false;
// to clients. Set SessionMode = HttpServerSessionMode.Stateful since it's required.
options.SessionMode = HttpServerSessionMode.Stateful;
})
.WithTools<LoggingTools>();
// .WithSetLoggingLevelHandler(async (ctx, ct) => new EmptyResult());