Skip to content

Commit 7e703f3

Browse files
halter73Copilot
andcommitted
Explicitly set Stateless in all WithHttpTransport calls
Every WithHttpTransport() call in samples and docs now explicitly sets Stateless = true or Stateless = false. This prepares for a potential future default change and makes the intent clear in code users may copy. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c9e8ea9 commit 7e703f3

File tree

16 files changed

+43
-20
lines changed

16 files changed

+43
-20
lines changed

docs/concepts/completions/completions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Register a completion handler when building the server. The handler receives a r
2626

2727
```csharp
2828
builder.Services.AddMcpServer()
29-
.WithHttpTransport()
29+
.WithHttpTransport(o => o.Stateless = true)
3030
.WithPrompts<MyPrompts>()
3131
.WithResources<MyResources>()
3232
.WithCompleteHandler(async (ctx, ct) =>

docs/concepts/elicitation/samples/server/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
builder.Services.AddMcpServer()
88
.WithHttpTransport(options =>
9-
options.IdleTimeout = Timeout.InfiniteTimeSpan // Never timeout
10-
)
9+
{
10+
// Elicitation requires stateful mode because it sends server-to-client requests.
11+
// Set Stateless = false explicitly for forward compatibility in case the default changes.
12+
options.Stateless = false;
13+
})
1114
.WithTools<InteractiveTools>();
1215

1316
builder.Logging.AddConsole(options =>

docs/concepts/filters.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ To enable authorization support, call `AddAuthorizationFilters()` when configuri
401401

402402
```csharp
403403
services.AddMcpServer()
404-
.WithHttpTransport()
404+
.WithHttpTransport(o => o.Stateless = true)
405405
.AddAuthorizationFilters() // Enable authorization filter support
406406
.WithTools<WeatherTools>();
407407
```
@@ -501,7 +501,7 @@ This allows you to implement logging, metrics, or other cross-cutting concerns t
501501

502502
```csharp
503503
services.AddMcpServer()
504-
.WithHttpTransport()
504+
.WithHttpTransport(o => o.Stateless = true)
505505
.WithRequestFilters(requestFilters =>
506506
{
507507
requestFilters.AddListToolsFilter(next => async (context, cancellationToken) =>

docs/concepts/logging/samples/server/Program.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
builder.Services.AddMcpServer()
88
.WithHttpTransport(options =>
9-
options.IdleTimeout = Timeout.InfiniteTimeSpan // Never timeout
10-
)
9+
{
10+
// Log streaming requires stateful mode because the server pushes log notifications
11+
// to clients. Set Stateless = false explicitly for forward compatibility.
12+
options.Stateless = false;
13+
})
1114
.WithTools<LoggingTools>();
1215
// .WithSetLoggingLevelHandler(async (ctx, ct) => new EmptyResult());
1316

docs/concepts/pagination/pagination.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ When implementing custom list handlers on the server, pagination is supported by
7070

7171
```csharp
7272
builder.Services.AddMcpServer()
73-
.WithHttpTransport()
73+
.WithHttpTransport(o => o.Stateless = true)
7474
.WithListResourcesHandler(async (ctx, ct) =>
7575
{
7676
const int pageSize = 10;

docs/concepts/prompts/prompts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Register prompt types when building the server:
6363

6464
```csharp
6565
builder.Services.AddMcpServer()
66-
.WithHttpTransport()
66+
.WithHttpTransport(o => o.Stateless = true)
6767
.WithPrompts<MyPrompts>()
6868
.WithPrompts<CodePrompts>();
6969
```

docs/concepts/resources/resources.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Register resource types when building the server:
7474

7575
```csharp
7676
builder.Services.AddMcpServer()
77-
.WithHttpTransport()
77+
.WithHttpTransport(o => o.Stateless = true)
7878
.WithResources<MyResources>()
7979
.WithResources<DocumentResources>();
8080
```
@@ -208,7 +208,9 @@ Register subscription handlers when building the server:
208208

209209
```csharp
210210
builder.Services.AddMcpServer()
211-
.WithHttpTransport()
211+
// Subscriptions require stateful mode because the server pushes change notifications
212+
// to clients. Set Stateless = false explicitly for forward compatibility.
213+
.WithHttpTransport(o => o.Stateless = false)
212214
.WithResources<MyResources>()
213215
.WithSubscribeToResourcesHandler(async (ctx, ct) =>
214216
{

docs/concepts/sessions/sessions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ For high-availability deployments, <xref:ModelContextProtocol.AspNetCore.ISessio
303303
builder.Services.AddMcpServer()
304304
.WithHttpTransport(options =>
305305
{
306+
// Session migration is a stateful-mode feature.
307+
options.Stateless = false;
306308
options.SessionMigrationHandler = new MySessionMigrationHandler();
307309
});
308310
```
@@ -329,6 +331,8 @@ The server can store SSE events for replay when clients reconnect using the `Las
329331
builder.Services.AddMcpServer()
330332
.WithHttpTransport(options =>
331333
{
334+
// Session resumability is a stateful-mode feature.
335+
options.Stateless = false;
332336
options.EventStreamStore = new MyEventStreamStore();
333337
});
334338
```

docs/concepts/tasks/tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ builder.Services.AddMcpServer(options =>
6464
// Enable tasks by providing a task store
6565
options.TaskStore = taskStore;
6666
})
67-
.WithHttpTransport()
67+
.WithHttpTransport(o => o.Stateless = true)
6868
.WithTools<MyTools>();
6969
```
7070

@@ -566,7 +566,7 @@ builder.Services.AddMcpServer(options =>
566566
{
567567
options.TaskStore = taskStore;
568568
})
569-
.WithHttpTransport()
569+
.WithHttpTransport(o => o.Stateless = true)
570570
.WithTools<TaskTools>();
571571
```
572572

docs/concepts/tools/tools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Register the tool type when building the server:
3939

4040
```csharp
4141
builder.Services.AddMcpServer()
42-
.WithHttpTransport()
42+
.WithHttpTransport(o => o.Stateless = true)
4343
.WithTools<MyTools>();
4444
```
4545

0 commit comments

Comments
 (0)