Docs edit pass (MCP.AspNetCore and a few other files) (#1034)
Co-authored-by: Stephen Toub <stoub@microsoft.com> Co-authored-by: Mike Kistler <mikekistler@microsoft.com>
This commit is contained in:
parent
6ed728d005
commit
af719fc576
1 changed files with 90 additions and 81 deletions
|
|
@ -4,10 +4,13 @@ using ModelContextProtocol.Server;
|
|||
namespace ModelContextProtocol.AspNetCore;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration options for <see cref="M:McpEndpointRouteBuilderExtensions.MapMcp"/>.
|
||||
/// Represents configuration options for <see cref="M:McpEndpointRouteBuilderExtensions.MapMcp"/>,
|
||||
/// which implements the Streaming HTTP transport for the Model Context Protocol.
|
||||
/// See the protocol specification for details on the Streamable HTTP transport. <see href="https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http"/>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For details on the Streamable HTTP transport, see the <see href="https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http">protocol specification</see>.
|
||||
/// </remarks>
|
||||
public class HttpServerTransportOptions
|
||||
{
|
||||
/// <summary>
|
||||
|
|
@ -18,61 +21,71 @@ public class HttpServerTransportOptions
|
|||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional asynchronous callback for running new MCP sessions manually.
|
||||
/// This is useful for running logic before a sessions starts and after it completes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This callback is useful for running logic before a sessions starts and after it completes.
|
||||
/// </remarks>
|
||||
public Func<HttpContext, McpServer, CancellationToken, Task>? RunSessionHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the server should run in a stateless mode which does not track state between requests
|
||||
/// Gets or sets a value that indicates whether the server runs in a stateless mode that doesn't track state between requests,
|
||||
/// allowing for load balancing without session affinity.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="true"/> if the server runs in a stateless mode; <see langword="false"/> if the server tracks state between requests. The default is <see langword="false"/>.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// If <see langword="true"/>, <see cref="McpSession.SessionId"/> will be null, and the "MCP-Session-Id" header will not be used,
|
||||
/// the <see cref="RunSessionHandler"/> will be called once for for each request, and the "/sse" endpoint will be disabled.
|
||||
/// Unsolicited server-to-client messages and all server-to-client requests are also unsupported, because any responses
|
||||
/// may arrive at another ASP.NET Core application process.
|
||||
/// might arrive at another ASP.NET Core application process.
|
||||
/// Client sampling and roots capabilities are also disabled in stateless mode, because the server cannot make requests.
|
||||
/// Defaults to <see langword="false"/>.
|
||||
/// </remarks>
|
||||
public bool Stateless { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the server should use a single execution context for the entire session.
|
||||
/// Gets or sets a value that indicates whether the server uses a single execution context for the entire session.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <see langword="true"/> if the server uses a single execution context for the entire session; otherwise, <see langword="false"/>. The default is <see langword="false"/>.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// If <see langword="false"/>, handlers like tools get called with the <see cref="ExecutionContext"/>
|
||||
/// belonging to the corresponding HTTP request which can change throughout the MCP session.
|
||||
/// belonging to the corresponding HTTP request, which can change throughout the MCP session.
|
||||
/// If <see langword="true"/>, handlers will get called with the same <see cref="ExecutionContext"/>
|
||||
/// used to call <see cref="ConfigureSessionOptions" /> and <see cref="RunSessionHandler"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Enabling a per-session <see cref="ExecutionContext"/> can be useful for setting <see cref="AsyncLocal{T}"/> variables
|
||||
/// that persist for the entire session, but it prevents you from using IHttpContextAccessor in handlers.
|
||||
/// Defaults to <see langword="false"/>.
|
||||
/// </remarks>
|
||||
public bool PerSessionExecutionContext { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the duration of time the server will wait between any active requests before timing out an MCP session.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The amount of time the server waits between any active requests before timing out an MCP session. The default is 2 hours.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// This is checked in background every 5 seconds. A client trying to resume a session will receive a 404 status code
|
||||
/// This value is checked in the background every 5 seconds. A client trying to resume a session will receive a 404 status code
|
||||
/// and should restart their session. A client can keep their session open by keeping a GET request open.
|
||||
/// Defaults to 2 hours.
|
||||
/// </remarks>
|
||||
public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromHours(2);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets maximum number of idle sessions to track in memory. This is used to limit the number of sessions that can be idle at once.
|
||||
/// Gets or sets maximum number of idle sessions to track in memory. This value is used to limit the number of sessions that can be idle at once.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The maximum number of idle sessions to track in memory. The default is 10,000 sessions.
|
||||
/// </value>
|
||||
/// <remarks>
|
||||
/// Past this limit, the server will log a critical error and terminate the oldest idle sessions even if they have not reached
|
||||
/// their <see cref="IdleTimeout"/> until the idle session count is below this limit. Clients that keep their session open by
|
||||
/// keeping a GET request open will not count towards this limit.
|
||||
/// Defaults to 10,000 sessions.
|
||||
/// Past this limit, the server logs a critical error and terminates the oldest idle sessions, even if they have not reached
|
||||
/// their <see cref="IdleTimeout"/>, until the idle session count is below this limit. Clients that keep their session open by
|
||||
/// keeping a GET request open don't count towards this limit.
|
||||
/// </remarks>
|
||||
public int MaxIdleSessionCount { get; set; } = 10_000;
|
||||
|
||||
/// <summary>
|
||||
/// Used for testing the <see cref="IdleTimeout"/>.
|
||||
/// Gets or sets the time provider that's used for testing the <see cref="IdleTimeout"/>.
|
||||
/// </summary>
|
||||
public TimeProvider TimeProvider { get; set; } = TimeProvider.System;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue