File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
ModelContextProtocol.AspNetCore
ModelContextProtocol.Core/Server Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -152,8 +152,14 @@ public class HttpServerTransportOptions
152152 /// The amount of time the server waits between any active requests before timing out an MCP session. The default is 2 hours.
153153 /// </value>
154154 /// <remarks>
155+ /// <para>
155156 /// This value is checked in the background every 5 seconds. A client trying to resume a session will receive a 404 status code
156157 /// and should restart their session. A client can keep their session open by keeping a GET request open.
158+ /// </para>
159+ /// <para>
160+ /// Legacy SSE sessions (when <see cref="EnableLegacySse"/> is enabled) are not subject to this timeout — their lifetime is
161+ /// tied to the open GET <c>/sse</c> request, and they are removed immediately when the client disconnects.
162+ /// </para>
157163 /// </remarks>
158164 public TimeSpan IdleTimeout { get ; set ; } = TimeSpan . FromHours ( 2 ) ;
159165
@@ -164,9 +170,16 @@ public class HttpServerTransportOptions
164170 /// The maximum number of idle sessions to track in memory. The default is 10,000 sessions.
165171 /// </value>
166172 /// <remarks>
173+ /// <para>
167174 /// Past this limit, the server logs a critical error and terminates the oldest idle sessions, even if they have not reached
168175 /// their <see cref="IdleTimeout"/>, until the idle session count is below this limit. Sessions with any active HTTP request
169176 /// are not considered idle and don't count towards this limit.
177+ /// </para>
178+ /// <para>
179+ /// Legacy SSE sessions (when <see cref="EnableLegacySse"/> is enabled) are never considered idle because their lifetime is
180+ /// tied to the open GET <c>/sse</c> request. They are not subject to <see cref="IdleTimeout"/> or this limit — they exist
181+ /// exactly as long as the SSE connection is open.
182+ /// </para>
170183 /// </remarks>
171184 public int MaxIdleSessionCount { get ; set ; } = 10_000 ;
172185
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ namespace ModelContextProtocol.Server;
1818/// This transport is used in scenarios where the server needs to push messages to the client in real-time,
1919/// such as when streaming completion results or providing progress updates during long-running operations.
2020/// </para>
21+ /// <para>
22+ /// <b>Backpressure consideration:</b> The SSE transport separates request and response channels — the client POSTs
23+ /// messages to a separate endpoint while responses flow over the SSE stream. If the HTTP handler for incoming
24+ /// messages returns immediately (e.g., <c>202 Accepted</c>) after calling <see cref="OnMessageReceivedAsync"/>,
25+ /// there is no HTTP-level backpressure on handler concurrency. The ASP.NET Core integration disables legacy SSE
26+ /// endpoints by default for this reason. If you are using this type directly, consider holding the POST response
27+ /// open until the handler completes, or applying rate-limiting at the HTTP layer.
28+ /// </para>
2129/// </remarks>
2230/// <param name="sseResponseStream">The response stream to write MCP JSON-RPC messages as SSE events to.</param>
2331/// <param name="messageEndpoint">
You can’t perform that action at this time.
0 commit comments