feat(project_mcp): handle per-request MCP cancellation in start_repo_session#409
Merged
feat(project_mcp): handle per-request MCP cancellation in start_repo_session#409
Conversation
…session When Goose's 5-minute tool timeout fires, it sends a CancelledNotification to the MCP server. rmcp 0.17 automatically cancels the RequestContext's CancellationToken for that request. Previously, the start_repo_session handler only watched self.cancel_token (the parent project session token) and never noticed per-request cancellation, leaving child sessions running as orphans after timeout. Add the per-request CancellationToken as a parameter to start_repo_session using rmcp's FromContextPart extractor (which extracts RequestContext.ct). Add a new branch in the polling tokio::select! loop that watches this token and cancels the child session via SessionRegistry::cancel when it fires. The existing self.cancel_token branch is preserved for parent project session cancellation. add_project_repo is not modified as it lacks a similar long-running polling loop.
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
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.
Summary
start_repo_sessionto respond to MCP clientCancelledNotification(e.g. Goose's 5-minute per-tool timeout)cancelledoutcomeTest plan
{"outcome": "cancelled", "output": ""}is handled correctly by clients🤖 Generated with Claude Code