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 #pragma warning disable MCPEXP002 suppressions in test files
Add #pragma warning disable MCPEXP002 suppression in sample (EverythingServer/Program.cs)
Update docs/list-of-diagnostics.md: remove MCPEXP003, consolidate MCPEXP002 to cover both subclassing and RunSessionHandler, document the MCPEXP001 vs MCPEXP002 grouping
Update Experimentals.cs class-level remarks to explain the MCPEXP001/MCPEXP002 distinction
Fix wording in Experimentals.cs: "and RunSessionHandler" → "or referencing RunSessionHandler"
Add note to HttpServerTransportOptions.RunSessionHandler doc comment about HttpContext coming from the initiating request and potentially being unusable after McpServer.RunAsync starts
Build succeeds (0 warnings, 0 errors)
Original prompt
This section details on the original issue you should resolve
<issue_title>Make RunSessionHandler experimental and revisit design</issue_title>
<issue_description>The line to resolve services from the HttpContext here is unsafe because it comes from the initialize request that normally has already completed. I also think there's an issue where if you write a RunSessionHandler intentionally to complete early, it does not forcibly end the session. At the same time, having access to the HttpContext when a session starts before you call McpServer.RunAsync could be useful, so I don't want to prevent people from doing that in 1.0
For these reasons, and because we want to release 1.0, I think we should make the RunSessionHandler API experimental. We might have to delete it and replace it with something else. In some cases ConfigureSessionOptions might be the better option, so we should suggest that in the experimental warning. We should also mention that the API may be deleted or change signatures.
.WithHttpTransport(options =>
{
// Use RunSessionHandler to clean up streams when a session ends
options.RunSessionHandler = async (httpContext, mcpServer, cancellationToken) =>
{
try
{
await mcpServer.RunAsync(cancellationToken);
}
finally
{
// Delete all streams associated with this session when it ends
if (!string.IsNullOrEmpty(mcpServer.SessionId))
{
var eventStreamStore = httpContext.RequestServices.GetRequiredService<SessionTrackingEventStreamStore>();
await eventStreamStore.DeleteStreamsForSessionAsync(mcpServer.SessionId);
}
}
};
```</issue_description>
<agent_instructions>Try to follow all the conventions in the repo for marking RunSessionHandler experimental.</agent_instructions>
## Comments on the Issue (you are @copilot in this section)
<comments>
</comments>
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.
@copilot Reuse the MCPEXP002 diagnostic ID. This defines the precedent (that should get new comments in Experimentals.cs) that MCPEXP001 is for experimental MCP spec features while MCPEXP002 is for experimental APIs in the SDK unrelated to the MCP specification itself. That should be explained in the list-of-diagnostics.md too.
@copilot Reuse the MCPEXP002 diagnostic ID. This defines the precedent (that should get new comments in Experimentals.cs) that MCPEXP001 is for experimental MCP spec features while MCPEXP002...
Done in 8498b79. RunSessionHandler now reuses MCPEXP002 instead of introducing MCPEXP003. The Experimentals.cs class-level remarks now explain the grouping (MCPEXP001 = experimental MCP spec features; MCPEXP002 = experimental SDK APIs unrelated to the spec), and list-of-diagnostics.md has been updated to consolidate the MCPEXP002 row to cover both subclassing and RunSessionHandler with that distinction called out.
CopilotAI
changed the title
Mark RunSessionHandler experimental (MCPEXP003)
Mark RunSessionHandler experimental (MCPEXP002)
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
breaking-changeThis issue or PR introduces a breaking change
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MCPEXP002diagnostic ID constants tosrc/Common/Experimentals.csforRunSessionHandler(reusingMCPEXP002instead of addingMCPEXP003)[Experimental]attribute toRunSessionHandlerproperty inHttpServerTransportOptions.cswith updated doc commentExperimentals.csas a linked file inModelContextProtocol.AspNetCore.csproj#pragma warning disable MCPEXP002suppressions in internal source usages (SseHandler.cs,StreamableHttpHandler.cs)#pragma warning disable MCPEXP002suppressions in test files#pragma warning disable MCPEXP002suppression in sample (EverythingServer/Program.cs)docs/list-of-diagnostics.md: removeMCPEXP003, consolidateMCPEXP002to cover both subclassing andRunSessionHandler, document theMCPEXP001vsMCPEXP002groupingExperimentals.csclass-level remarks to explain theMCPEXP001/MCPEXP002distinctionExperimentals.cs: "andRunSessionHandler" → "or referencingRunSessionHandler"HttpServerTransportOptions.RunSessionHandlerdoc comment aboutHttpContextcoming from the initiating request and potentially being unusable afterMcpServer.RunAsyncstartsOriginal prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.