Skip to content

Commit 592a355

Browse files
Keep Stateless as a non-obsolete convenience property
Retain the bool as shorthand for the Stateless and Stateful session modes, while SessionMode remains available for selecting hybrid behavior. Remove the MCP9008 diagnostic and related obsolete documentation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 056310a commit 592a355

5 files changed

Lines changed: 3 additions & 11 deletions

File tree

docs/concepts/stateless/stateless.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The `SessionMode` property is the single most important setting for forward-proo
4343
4444
<!-- mlc-disable-next-line -->
4545
> [!NOTE]
46-
> The older `bool` <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.Stateless> property is obsolete ([`MCP9008`](xref:list-of-diagnostics#obsolete-apis)) because it cannot express hybrid mode. It remains a compatibility proxy over `SessionMode`: assigning `true` selects `Stateless` and assigning `false` selects `Stateful`, while reading it returns `true` only for `Stateless`. Both properties update the same underlying value, so the last assignment wins.
46+
> The `bool` <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.Stateless> property remains a convenient shorthand for the two most common modes: assigning `true` selects `Stateless` and assigning `false` selects `Stateful`, while reading it returns `true` only for `Stateless`. Use `SessionMode` when you need `StatefulForInitializeClients`. Both properties update the same underlying value, so the last assignment wins.
4747
4848
### The 2026-07-28 protocol revision
4949

@@ -466,7 +466,7 @@ builder.Services.AddMcpServer()
466466
| Property | Type | Default | Description |
467467
|----------|------|---------|-------------|
468468
| <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.SessionMode> | <xref:ModelContextProtocol.AspNetCore.HttpServerSessionMode> | `Stateless` | Selects how the server tracks state between requests: `Stateless` (no sessions), `Stateful` (sessions for every client, `2026-07-28` refused), or `StatefulForInitializeClients` ([hybrid](#hybrid-mode-sessions-for-initialize-clients-only)). |
469-
| <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.Stateless> | `bool` | `true` | _Obsolete (`MCP9008`)._ Compatibility proxy over `SessionMode`: `true` maps to `Stateless`, `false` maps to `Stateful`, and hybrid mode reads as `false`. Use `SessionMode` instead. |
469+
| <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.Stateless> | `bool` | `true` | Convenience proxy over `SessionMode`: `true` maps to `Stateless`, `false` maps to `Stateful`, and hybrid mode reads as `false`. Use `SessionMode` to select hybrid mode. |
470470
| <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.IdleTimeout> | `TimeSpan` | 2 hours | _Stateful only (`MCP9006`)._ Duration of inactivity before a session is closed. Checked every 5 seconds. |
471471
| <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.MaxIdleSessionCount> | `int` | 10,000 | _Stateful only (`MCP9006`)._ Maximum idle sessions before the oldest are forcibly terminated. |
472472
| <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.ConfigureSessionOptions> | `Func<HttpContext, McpServerOptions, CancellationToken, Task>?` | `null` | Per-session callback to customize `McpServerOptions` with access to `HttpContext`. In stateless mode (including all `2026-07-28` requests), this runs on every HTTP request. |

docs/list-of-diagnostics.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ When APIs are marked as obsolete, a diagnostic is emitted to warn users that the
4646
| `MCP9005` | In place | The Roots, Sampling, and Logging features are deprecated as of specification version 2026-07-28 and may be removed in a future version. See [SEP-2577](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2577) for more information. |
4747
| `MCP9006` | In place | The stateful Streamable HTTP configuration knobs on <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions>`EventStreamStore`, `SessionMigrationHandler`, `PerSessionExecutionContext`, `IdleTimeout`, and `MaxIdleSessionCount` — only apply when the request is served with a session. Starting with the `2026-07-28` protocol revision, Streamable HTTP no longer supports sessions, and the SDK now defaults `SessionMode` to `HttpServerSessionMode.Stateless`. These knobs remain available for back-compat with the legacy stateful Streamable HTTP transport but new code should target the stateless path. |
4848
| `MCP9007` | In place | `AuthorizationRedirectDelegate` and `ClientOAuthOptions.AuthorizationRedirectDelegate` are retained for source and binary compatibility but cannot provide the authorization-response state or RFC 9207 issuer. State and issuer validation are skipped when these APIs are used. Use `ClientOAuthOptions.AuthorizationCallbackHandler` for response-bound, issuer-aware authorization flows. |
49-
| `MCP9008` | In place | <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.Stateless> is a two-value flag that cannot express <xref:ModelContextProtocol.AspNetCore.HttpServerSessionMode.StatefulForInitializeClients>. Use <xref:ModelContextProtocol.AspNetCore.HttpServerTransportOptions.SessionMode> instead. `Stateless` remains a compatibility proxy over `SessionMode`: `true` maps to `Stateless` and `false` maps to `Stateful`. See [Stateless and stateful mode](xref:stateless#hybrid-mode-sessions-for-initialize-clients-only) for details. |

src/Common/Obsoletions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,4 @@ internal static class Obsoletions
5050
public const string AuthorizationRedirectDelegate_DiagnosticId = "MCP9007";
5151
public const string AuthorizationRedirectDelegate_Message = "AuthorizationRedirectDelegate cannot provide the RFC 9207 issuer and is retained for compatibility only. Use AuthorizationCallbackHandler instead.";
5252
public const string AuthorizationRedirectDelegate_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis";
53-
54-
public const string StatelessProperty_DiagnosticId = "MCP9008";
55-
public const string StatelessProperty_Message = "HttpServerTransportOptions.Stateless cannot express the hybrid session mode. Use HttpServerTransportOptions.SessionMode instead.";
56-
public const string StatelessProperty_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#obsolete-apis";
5753
}

src/ModelContextProtocol.AspNetCore/HttpServerTransportOptions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,13 @@ public class HttpServerTransportOptions
101101
/// set to <see langword="false"/> only when you need to support legacy clients that rely on session affinity.
102102
/// </value>
103103
/// <remarks>
104-
/// This property is a compatibility proxy over <see cref="SessionMode"/>. Reading it returns
104+
/// This property is a convenience proxy over <see cref="SessionMode"/>. Reading it returns
105105
/// <see langword="true"/> only when <see cref="SessionMode"/> is <see cref="HttpServerSessionMode.Stateless"/>,
106106
/// so <see cref="HttpServerSessionMode.StatefulForInitializeClients"/> reads as <see langword="false"/>.
107107
/// Assigning <see langword="true"/> selects <see cref="HttpServerSessionMode.Stateless"/> and assigning
108108
/// <see langword="false"/> selects <see cref="HttpServerSessionMode.Stateful"/>. Because both properties
109109
/// update the same underlying value, the last assignment wins when both are configured.
110110
/// </remarks>
111-
[Obsolete(Obsoletions.StatelessProperty_Message, DiagnosticId = Obsoletions.StatelessProperty_DiagnosticId, UrlFormat = Obsoletions.StatelessProperty_Url)]
112111
public bool Stateless
113112
{
114113
get => SessionMode is HttpServerSessionMode.Stateless;

tests/ModelContextProtocol.AspNetCore.Tests/HttpServerTransportOptionsTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public void SessionMode_DefaultsToStateless()
88
Assert.Equal(HttpServerSessionMode.Stateless, new HttpServerTransportOptions().SessionMode);
99
}
1010

11-
#pragma warning disable MCP9008 // Stateless is obsolete; these tests verify the compatibility proxy.
1211
[Theory]
1312
[InlineData(true, HttpServerSessionMode.Stateless)]
1413
[InlineData(false, HttpServerSessionMode.Stateful)]
@@ -41,5 +40,4 @@ public void AssigningBothProperties_DoesNotThrow_AndLastAssignmentWins()
4140
options.Stateless = true;
4241
Assert.Equal(HttpServerSessionMode.Stateless, options.SessionMode);
4342
}
44-
#pragma warning restore MCP9008
4543
}

0 commit comments

Comments
 (0)