Add server-side Streamable HTTP transport support#330
Merged
halter73 merged 9 commits intomodelcontextprotocol:mainfrom Apr 19, 2025
Merged
Add server-side Streamable HTTP transport support#330halter73 merged 9 commits intomodelcontextprotocol:mainfrom
halter73 merged 9 commits intomodelcontextprotocol:mainfrom
Conversation
- Changes IJsonRpcMessage to an abstract base class so RelatedTransport will always be available - Streamable HTTP supports multiple concurrent HTTP request with their own indpendent SSE response streams - RelatedTransport indicates the source or destination of the JsonRpcMessage - Changes the default RequestId to a JSON number for better compatibility with MCP servers in the wild
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a Streamable HTTP transport for the MCP server with updates to message type handling and session management. Key changes include refactoring JSON-RPC message types from interface/record to abstract classes, updating HTTP endpoint implementations, and adding an idle session background service for cleanup.
Reviewed Changes
Copilot reviewed 44 out of 44 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Protocol/Transport/SseResponseStreamTransport.cs | Updated message types and removed legacy JSON writer helper. |
| Protocol/Transport/SseClientSessionTransport.cs | Replaced interface types with concrete message types for consistency. |
| Protocol/Messages/* | Converted several records and interfaces into classes/abstract classes with unified JSON-RPC properties. |
| AspNetCore/StreamableHttpHandler.cs | Implements Streamable HTTP transport with session management and updated error handling. |
| AspNetCore/* | Various endpoint and session management updates, including idle session cleanup in background service. |
Comments suppressed due to low confidence (2)
src/ModelContextProtocol/AspNetCore/StreamableHttpHandler.cs:80
- The GET endpoint should verify the presence of 'text/event-stream' in the Accept header rather than 'application/json', since the response is expected to be an SSE stream. Update the check to use 'text/event-stream' to correctly validate client support.
if (!acceptHeader.Contains("application/json", StringComparison.Ordinal))
src/ModelContextProtocol/AspNetCore/HttpServerTransportOptions.cs:30
- There is a duplicate word 'minutes' in the documentation comment. Remove the redundant 'minutes' for clarity.
/// minutes.
# Conflicts: # src/ModelContextProtocol/Protocol/Transport/StreamClientSessionTransport.cs # src/ModelContextProtocol/Shared/McpSession.cs
- Use StopOnFinalResponseFilter rather than stopping writer when final JsonResponse is received.
- Add SingleJsonRpcRequest_ThatThrowsIsHandled_WithCompleteSseResponse
stephentoub
approved these changes
Apr 18, 2025
src/ModelContextProtocol/Protocol/Transport/StreamableHttpPostTransport.cs
Show resolved
Hide resolved
This was referenced Apr 20, 2025
This was referenced Jul 24, 2025
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds server-side Streamable HTTP transport support. Client-side support will come in a later PR.
Contributes to #157
Contributes to #158