You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
/// Provides methods for configuring HTTP MCP servers via dependency injection.
9
+
/// </summary>
10
+
publicstaticclassHttpMcpServerBuilderExtensions
11
+
{
12
+
/// <summary>
13
+
/// Adds the services necessary for <see cref="M:McpEndpointRouteBuilderExtensions.MapMcp"/>
14
+
/// to handle MCP requests and sessions using the MCP HTTP Streaming transport. For more information on configuring the underlying HTTP server
15
+
/// to control things like port binding custom TLS certificates, see the <see href="https://learn.microsoft.com/aspnet/core/fundamentals/minimal-apis">Minimal APIs quick reference</see>.
/// Configuration options for <see cref="M:McpEndpointRouteBuilderExtensions.MapMcp"/>.
8
+
/// which implements the Streaming HTTP transport for the Model Context Protocol.
9
+
/// See the protocol specification for details on the Streamable HTTP transport. <see href="https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http"/>
10
+
/// </summary>
11
+
publicclassHttpServerTransportOptions
12
+
{
13
+
/// <summary>
14
+
/// Gets or sets an optional asynchronous callback to configure per-session <see cref="McpServerOptions"/>
15
+
/// with access to the <see cref="HttpContext"/> of the request that initiated the session.
@@ -24,136 +12,20 @@ public static class McpEndpointRouteBuilderExtensions
24
12
{
25
13
/// <summary>
26
14
/// Sets up endpoints for handling MCP HTTP Streaming transport.
15
+
/// See <see href="https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http">the protocol specification</see> for details about the Streamable HTTP transport.
27
16
/// </summary>
28
17
/// <param name="endpoints">The web application to attach MCP HTTP endpoints.</param>
29
18
/// <param name="pattern">The route pattern prefix to map to.</param>
thrownewInvalidOperationException("You must call WithHttpTransport(). Unable to find required services. Call builder.Services.AddMcpServer().WithHttpTransport() in application startup code.");
59
24
60
25
varrouteGroup=endpoints.MapGroup(pattern);
61
-
62
-
routeGroup.MapGet("/sse",async context =>
63
-
{
64
-
// If the server is shutting down, we need to cancel all SSE connections immediately without waiting for HostOptions.ShutdownTimeout
0 commit comments