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:
parent
bba45c44bf
commit
c6a97d94d6
1 changed files with 764 additions and 150 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue