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
|
|
@ -411,7 +411,7 @@ To enable authorization support, call `AddAuthorizationFilters()` when configuri
|
|||
|
||||
```csharp
|
||||
services.AddMcpServer()
|
||||
.WithHttpTransport(o => o.Stateless = true)
|
||||
.WithHttpTransport(o => o.SessionMode = HttpServerSessionMode.Stateless)
|
||||
.AddAuthorizationFilters() // Enable authorization filter support
|
||||
.WithTools<WeatherTools>();
|
||||
```
|
||||
|
|
@ -511,7 +511,7 @@ This allows you to implement logging, metrics, or other cross-cutting concerns t
|
|||
|
||||
```csharp
|
||||
services.AddMcpServer()
|
||||
.WithHttpTransport(o => o.Stateless = true)
|
||||
.WithHttpTransport(o => o.SessionMode = HttpServerSessionMode.Stateless)
|
||||
.WithRequestFilters(requestFilters =>
|
||||
{
|
||||
requestFilters.AddListToolsFilter(next => async (context, cancellationToken) =>
|
||||
|
|
@ -546,6 +546,8 @@ services.AddMcpServer()
|
|||
To use authorization features, you must configure authentication and authorization in your ASP.NET Core application and call `AddAuthorizationFilters()`:
|
||||
|
||||
```csharp
|
||||
using ModelContextProtocol.AspNetCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddAuthentication("Bearer")
|
||||
|
|
@ -556,7 +558,7 @@ builder.Services.AddAuthorization();
|
|||
builder.Services.AddMcpServer()
|
||||
.WithHttpTransport(options =>
|
||||
{
|
||||
options.Stateless = true;
|
||||
options.SessionMode = HttpServerSessionMode.Stateless;
|
||||
})
|
||||
.AddAuthorizationFilters() // Required for authorization support
|
||||
.WithTools<WeatherTools>()
|
||||
|
|
|
|||
Loading…
Reference in a new issue