Skip to content

Conversation

cioutn
Copy link

@cioutn 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
handler.go Outdated
}

// Check if trying to cancel initialize request
if reqID, ok := requestId.(string); ok && reqID == "initialize" {
Copy link
Collaborator

@bytethm bytethm Jul 28, 2025

Choose a reason for hiding this comment

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

reqID == "initialize" 这条件应该判断不出是否是初始化请求?MCP 应该没规定初始化请求的 reqID 必须是 "initialize"

Copy link
Author

Choose a reason for hiding this comment

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

嗯嗯,谢谢老师指出错误,确实是这样。我更新了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
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