Skip to content

Add onsessionclosed hook to StreamableHTTPServerTransport #743

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 3 commits into from
Jul 7, 2025

Conversation

jerome3o-anthropic
Copy link
Member

Summary

• Added onsessionclosed callback hook to StreamableHTTPServerTransport
• Hook is triggered when server closes session due to DELETE request
• Enables cleanup of resources associated with the session
• Refactored from initial ondelete hook to more descriptive onsessionclosed

Test plan

  • Verify the hook is called when DELETE request is made
  • Confirm sessionId is properly passed to the callback
  • Test that existing functionality is unaffected

🤖 Generated with Claude Code

jerome3o-anthropic and others added 2 commits July 7, 2025 14:44
Adds optional ondelete callback that fires when DELETE request is received, providing the sessionId for cleanup handling.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…sport

- Renamed ondelete callback to onsessionclosed for better clarity
- Moved callback from public property to private field following options pattern
- Added comprehensive JSDoc documentation explaining the callback's purpose
- Updated DELETE request handler to use the new callback structure

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jerome3o-anthropic jerome3o-anthropic requested a review from ihrpr July 7, 2025 14:00
Copy link
Contributor

@ihrpr ihrpr left a comment

Choose a reason for hiding this comment

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

Please can you add tests

…PServerTransport

• Tests callback is called when session is closed via DELETE
• Tests system works correctly when callback is not provided
• Tests callback is not called for invalid session DELETE requests
• Tests correct session ID is passed when multiple sessions exist
• Follows existing test patterns and includes proper cleanup

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jerome3o-anthropic jerome3o-anthropic requested a review from ihrpr July 7, 2025 14:20
@jerome3o-anthropic
Copy link
Member Author

Please can you add tests

ah yep - sorry they weren't pushed

Copy link
Contributor

@ihrpr ihrpr left a comment

Choose a reason for hiding this comment

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

LGTM

@ihrpr ihrpr merged commit 7d7896f into main Jul 7, 2025
5 checks passed
@ihrpr ihrpr deleted the jerome/feature/ondelete-shttp-hook branch July 7, 2025 16:11
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