Skip to content

fix: streamable http server close request channel on response(#266) #270

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

Conversation

4t145
Copy link
Collaborator

@4t145 4t145 commented Jun 18, 2025

Motivation and Context

release related resource when RequestId is removed

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

#268 is for close connection in client side, this pr is for really fix the bug

@github-actions github-actions bot added T-core Core library changes T-transport Transport layer changes labels Jun 18, 2025
@4t145 4t145 marked this pull request as ready for review June 18, 2025 11:47
@4t145 4t145 requested review from jokemanfire and Copilot June 18, 2025 11:47
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where the streamable HTTP server was not properly releasing resources when a RequestId is removed. The key changes include modifying the logic to close the HTTP channel if its resource list is empty or if the resource is an MCP request, and adding a warning log when the channel is not found.

@@ -328,11 +328,19 @@ impl LocalSessionWorker {
if let Some(http_request_id) = self.resource_router.remove(resource) {
tracing::trace!(?resource, http_request_id, "unregister resource");
if let Some(channel) = self.tx_router.get_mut(&http_request_id) {
channel.resources.remove(resource);
if channel.resources.is_empty() {
// It's okey to do so, since we don't handle batch json rcp request anymore
Copy link
Preview

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

There is a spelling mistake in the comment: "okey" should be "okay".

Suggested change
// It's okey to do so, since we don't handle batch json rcp request anymore
// It's okay to do so, since we don't handle batch json rcp request anymore

Copilot uses AI. Check for mistakes.

Co-authored-by: Copilot <[email protected]>
@4t145 4t145 merged commit 8a57765 into modelcontextprotocol:main Jun 18, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-core Core library changes T-transport Transport layer changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants