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 Azure.Monitor.OpenTelemetry.AspNetCore;
|
||||
using ModelContextProtocol.AspNetCore;
|
||||
using OpenTelemetry;
|
||||
using OpenTelemetry.Metrics;
|
||||
using OpenTelemetry.Trace;
|
||||
|
|
@ -26,10 +27,10 @@ builder.Services.AddCors(options =>
|
|||
|
||||
// Note: This sample uses SampleLlmTool which calls server.AsSamplingChatClient() to send
|
||||
// a server-to-client sampling request. This requires stateful (session-based) mode. Set
|
||||
// Stateless = false explicitly for forward compatibility in case the default changes.
|
||||
// SessionMode = HttpServerSessionMode.Stateful since sessions are required for sampling.
|
||||
// See https://csharp.sdk.modelcontextprotocol.io/concepts/sessions/sessions.html for details.
|
||||
builder.Services.AddMcpServer()
|
||||
.WithHttpTransport(o => o.Stateless = false)
|
||||
.WithHttpTransport(o => o.SessionMode = HttpServerSessionMode.Stateful)
|
||||
.WithTools<EchoTool>()
|
||||
.WithTools<SampleLlmTool>()
|
||||
.WithTools<WeatherTools>()
|
||||
|
|
|
|||
Loading…
Reference in a new issue