Add StreamableHttpHandler and WithHttpTransport (#291)
* Simplify ModelContextProtocol.AspNetCore README * Add StreamableHttpHandler * Use "docker info" in CheckIsDockerAvailable * Call WithHttpTransport in samples, tests and README * Cleanup test namespaces * Add CanConnect_WithMcpClient_AfterCustomizingRoute test * Simplify relative URI handling * Handle request made directly to the MapMcp route pattern * Add Messages_FromNewUser_AreRejected test * Fix README * Shorten UserIdClaim ValueTuple names * Remove MaxReconnectAttempts and ReconnectDelay from SseClientTransportOptions - Add proper AdditionalHeaders support
This commit is contained in:
parent
bca5d2609d
commit
9c124b1770
1 changed files with 597 additions and 324 deletions
|
|
@ -0,0 +1,24 @@
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using ModelContextProtocol.Server;
|
||||
|
||||
namespace ModelContextProtocol.AspNetCore;
|
||||
|
||||
/// <summary>
|
||||
/// 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-03-26/basic/transports#streamable-http"/>
|
||||
/// </summary>
|
||||
public class HttpServerTransportOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets an optional asynchronous callback to configure per-session <see cref="McpServerOptions"/>
|
||||
/// with access to the <see cref="HttpContext"/> of the request that initiated the session.
|
||||
/// </summary>
|
||||
public Func<HttpContext, McpServerOptions, CancellationToken, Task>? ConfigureSessionOptions { get; set; }
|
||||
|
||||
/// <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>
|
||||
public Func<HttpContext, IMcpServer, CancellationToken, Task>? RunSessionHandler { get; set; }
|
||||
}
|
||||
Loading…
Reference in a new issue