Skip to content

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
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bhosmer-ant
Copy link
Contributor

Implements protocol-level session support for modelcontextprotocol/modelcontextprotocol#1359

Completed Phases:

  • ✅ Phase 1: Protocol session foundation with validation, lifecycle, and testing
  • ✅ Phase 2: Server session support with initialization and termination handlers

Remaining Phases:

  • ⏳ Phase 3: Transport layer migration (HTTP/stdio compatibility)
  • ⏳ Phase 4: Client session support
  • ⏳ Phase 5: Backward compatibility testing
  • ⏳ Phase 6: Documentation

Current state: Core session functionality working, all tests passing (13/13)

- 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)
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.

1 participant