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

@ -78,6 +78,7 @@ dotnet add package ModelContextProtocol.AspNetCore
And add the following code:
```csharp
using ModelContextProtocol.AspNetCore;
using ModelContextProtocol.Server;
using System.ComponentModel;
@ -85,10 +86,10 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMcpServer()
.WithHttpTransport(options =>
{
// Stateless mode is recommended for servers that don't need
// server-to-client requests like sampling or elicitation.
// See the Stateless and Stateful documentation for details.
options.Stateless = true;
// Stateless mode is the default and recommended for servers that
// don't need server-to-client requests like sampling or elicitation.
// See the Stateless and Stateful documentation for details.
options.SessionMode = HttpServerSessionMode.Stateless;
})
.WithToolsFromAssembly();
var app = builder.Build();