Feature: Implement MCP cancellation mechanism - #24
Open
cioutn wants to merge 2 commits into
Open
Conversation
cioutn
commented
Jul 10, 2025
- Support client-initiated request cancellation notifications
- Implement graceful interruption for long-running operations
- Add automatic request cancellation on timeout
- Create resource cleanup mechanism after cancellation
- Handle pending requests on service shutdown
- Support client-initiated request cancellation notifications - Implement graceful interruption for long-running operations - Add automatic request cancellation on timeout - Create resource cleanup mechanism after cancellation - Handle pending requests on service shutdown
bytethm
reviewed
Jul 28, 2025
| } | ||
|
|
||
| // Check if trying to cancel initialize request | ||
| if reqID, ok := requestId.(string); ok && reqID == "initialize" { |
Collaborator
There was a problem hiding this comment.
reqID == "initialize" 这条件应该判断不出是否是初始化请求?MCP 应该没规定初始化请求的 reqID 必须是 "initialize"
Author
There was a problem hiding this comment.
嗯嗯,谢谢老师指出错误,确实是这样。我更新了commit,在handleInitialize时对初始化请求进行标记,麻烦审阅,谢谢!
- Properly identify initialize requests by storing request ID in session data - Replace incorrect string comparison with session-based tracking - Add comprehensive test for initialize request cancellation protection - Add test for automatic timeout cancellation functionality - Ensure compliance with MCP specification: initialize requests MUST NOT be cancelled
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.