-
Notifications
You must be signed in to change notification settings - Fork 745
Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
When using the Aspire Dashboard MCP server with AI assistants (Claude Code, Cursor, etc.), sessions frequently become invalid with 404 "Session not found" errors. This occurs when:
- The Aspire AppHost restarts but the AI client doesn't
- The MCP session times out (default 2 hours, but checked every 5 seconds)
- Any interruption in the SSE streaming connection
This is a significant developer experience issue - users must manually reset their MCP client connections after every AppHost restart.
Describe the solution you'd like
The MCP C# SDK's HttpServerTransportOptions has a Stateless property that eliminates session management entirely:
If true, SessionId will be null, and the "MCP-Session-Id" header will not be used, the RunSessionHandler will be called once for each request, and the "/sse" endpoint will be disabled.
Current code in McpExtensions.cs:
.WithHttpTransport() // No options passed
Proposed change:
- Add Stateless property to McpOptions:
public bool Stateless { get; set; } = false;
- Pass it to WithHttpTransport:
.WithHttpTransport(options =>
{
options.Stateless = dashboardOptions.Mcp.Stateless;
})
- Users can then configure via environment variable:
Dashboard__Mcp__Stateless=true
Additional context
Reference: Simon Doy's article on MCP stateless mode describes this exact issue and solution for Copilot Studio. Relation to CLI MCP (#12394): The upcoming CLI MCP server will face the same challenge - if the CLI connects to a dashboard that restarts, its session becomes invalid. The Aspire CLI MCP spec mentions using a Unix socket backchannel to obtain credentials, but the underlying HTTP transport will still have session state issues unless stateless mode is available.
Trade-offs of stateless mode:
- Eliminates session management issues
- Allows dashboard restarts without breaking clients
- Disables SSE endpoint (no server-initiated messages)
- Disables client sampling and roots capabilities
For most Aspire MCP use cases (querying resources, logs, traces), stateless mode is sufficient since all operations are client-initiated.