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
|
|
@ -1,4 +1,5 @@
|
|||
using AspNetCoreMcpPerSessionTools.Tools;
|
||||
using ModelContextProtocol.AspNetCore;
|
||||
using ModelContextProtocol.Server;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Reflection;
|
||||
|
|
@ -14,8 +15,8 @@ builder.Services.AddMcpServer()
|
|||
.WithHttpTransport(options =>
|
||||
{
|
||||
// This sample demonstrates per-session tool filtering, which requires stateful mode.
|
||||
// Set Stateless = false explicitly for forward compatibility in case the default changes.
|
||||
options.Stateless = false;
|
||||
// Set SessionMode = HttpServerSessionMode.Stateful since sessions are required.
|
||||
options.SessionMode = HttpServerSessionMode.Stateful;
|
||||
|
||||
// Configure per-session options to filter tools based on route category
|
||||
options.ConfigureSessionOptions = async (httpContext, mcpOptions, cancellationToken) =>
|
||||
|
|
|
|||
Loading…
Reference in a new issue