Skip to content

Add server-side Streamable HTTP transport support #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 19, 2025

Conversation

halter73
Copy link
Contributor

@halter73 halter73 commented Apr 18, 2025

Adds server-side Streamable HTTP transport support. Client-side support will come in a later PR.

  • Changes IJsonRpcMessage to an abstract base class so RelatedTransport will always be available
  • Streamable HTTP supports multiple concurrent HTTP request with their own independent 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

Contributes to #157
Contributes to #158

- 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
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@halter73 halter73 changed the title Add server Streamable HTTP transport Add server-side Streamable HTTP transport support Apr 18, 2025
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants