Skip to content

Conversation

@davenpi
Copy link
Collaborator

@davenpi davenpi commented Jul 28, 2025

What changed?

Implemented complete streamable HTTP client transport from scratch following the MCP specification, plus added consistent close() method to both client and server transport interfaces.

Why?

We needed a robust HTTP transport implementation to enable client sessions to connect to HTTP-based MCP servers. The existing draft was incomplete and didn't handle the complex streaming scenarios required by the spec.

Impact

  • Client sessions can now connect to HTTP-based MCP servers with full spec compliance
  • Handles complex streaming scenarios including SSE streams from POST responses and GET-based server-initiated streams
  • Automatic resource management through ClientStreamManager abstraction with proper background task cleanup
  • Consistent transport interface - both client and server transports now have close() methods for explicit resource cleanup

Testing

  • Manual verification of implementation structure and spec compliance
  • Interface consistency checked across client/server transports
  • Ready for comprehensive testing in next phase

Review notes

  • ClientStreamManager abstraction cleanly handles multiple SSE streams per server
  • Session management is currently on the transport (not ideal but acceptable for now)
  • GET-based server streams implemented for full spec compliance
  • All error handling follows spec requirements (404 session expiry, 405 method not allowed, etc.)

Checklist

  • All new and old tests pass
  • Code follows our style guidelines
  • Documentation updated if needed
  • Breaking changes documented in commit messages

davenpi added 2 commits July 28, 2025 09:35
What changed and why:
- Built complete StreamableHttpClientTransport implementation following
  the MCP streamable HTTP specification
- Added ClientStreamManager abstraction to handle multiple SSE streams
  per server with proper lifecycle management
- Extended ClientTransport interface with close() method for explicit
  resource cleanup
- Supports HTTP POST for message sending, SSE streams for responses,
  GET-based server-initiated streams, and session management

Impact:
- Client sessions can now connect to HTTP-based MCP servers
- Handles complex streaming scenarios with background task management
- Fully spec-compliant with proper error handling for session expiry
  and server capabilities
What changed and why:
- Added abstract close() method to ServerTransport interface for
  explicit resource cleanup, matching the ClientTransport pattern
- Implemented close() in StreamableHttpServerTransport to stop HTTP
  server and clean up sessions and streams
- Updated ServerSession.disconnect_all_clients() to call
  transport.close()
- Fixed stdio transport implementation to include close() method

Impact:
- Consistent transport interface between client and server sides
- Proper resource cleanup when server sessions shut down completely
- Prevents resource leaks in HTTP servers and other transport types
@davenpi davenpi merged commit 807a544 into main Jul 28, 2025
6 checks passed
@davenpi davenpi deleted the feat/client-streamable-http branch July 29, 2025 12:50
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.

2 participants