-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement protocol-level sessions for TypeScript SDK #888
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
Draft
bhosmer-ant
wants to merge
11
commits into
main
Choose a base branch
from
basil/sessions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,276
−156
Conversation
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
- Add SessionId type and schema - Add session interfaces (SessionState, SessionOptions) - Add session state to Protocol class - Add session validation and lifecycle methods - Include sessionId in all outgoing JSON-RPC messages - Add InvalidSession error code and handling - Add comprehensive tests for session validation and lifecycle
- Fix session validation to handle all session/sessionless combinations - Update capturedTransport pattern to capture session state - Include sessionId in all response messages using captured state - Update RequestHandlerExtra sessionId type to support SessionId - Remove unused imports from tests Phase 1 complete: Protocol class has full session support
- Simplify server session tests to avoid complex internal mocking - Test session configuration and transport access functionality - Verify session terminate handler registration without method not found error - All session tests now pass (13/13)
- Change SessionId type to string-only for simplicity - Add header-to-protocol sessionId injection with mismatch validation - Remove all session generation and validation logic from transport - Convert HTTP DELETE to session/terminate protocol message - Store legacy session callbacks for server delegation - Transport is now pure HTTP-to-protocol bridge - Update tests for string-only SessionId Phase 3 transport migration complete: all session logic moved to server
- Add getLegacySessionOptions and setSessionState to Transport interface - Implement legacy session options delegation in Protocol connect - Add session state support to InMemoryTransport and StreamableHTTPClientTransport - Client now handles sessionId from InitializeResult and notifies transport - Server delegation system working (debug output shows session creation flow) Note: Some integration tests still failing - require full Phase 4 client implementation
- Don't override existing sessionId in requests/notifications - Add sessionId property support to StreamableHTTPClientTransport - Client session delegation working (confirmed by debug output) - Skip problematic test with timeout issues for later investigation Core client-server session flow now working correctly
- Fix client-side session validation to only validate incoming requests - Don't reset request ID counter when creating session - Move session options from Protocol to Server class - Fix previously skipped sessionId test - All 719 tests now pass
- Test initialize request handling when transport switches mid-flight - Test session validation when new transport attempts re-initialization - Both tests verify correct request routing and session state management
- Restore console.log statements that were incorrectly removed - Add similar logging to new initialize tests for consistency - Fixes lint errors from unused parameters
…r backward compatibility - Constructor now accepts optional options parameter - Preserves backward compatibility for existing code that creates transport without options - Legacy session callbacks are only stored when options are provided - Added regression test to ensure transport can be created without options
- Increased notification interval from 10ms to 50ms for more reliable timing - Increased wait time from 20ms to 75ms to ensure notifications are received - Increased disconnect delay from 10ms to 50ms for cleaner disconnect - Test now passes consistently without flakiness
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.
Protocol-level session support implementation
Implements SEP-1359: Protocol-Level Sessions for MCP
Current state
Protocol-level session support has been implemented with the following components:
Core implementation
Key features
Testing
Remaining tasks
Breaking changes
None - maintains backward compatibility with existing transport-level sessions.