Skip to content

Conversation

@4t145
Copy link
Collaborator

@4t145 4t145 commented Jun 18, 2025

close connection on client side after received response.

Motivation and Context

fix #266

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

cc @howardjohn

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

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 issue #266 by closing the client's connection after receiving a response in the streamable HTTP client.

  • Added a new boolean parameter (close_on_response) to control stream closure
  • Introduced a conditional break in the SSE stream loop upon receiving a response
  • Updated Worker spawn calls to pass the appropriate flag based on context
Comments suppressed due to low confidence (1)

crates/rmcp/src/transport/streamable_http_client.rs:237

  • Consider adding tests to verify that the SSE stream is properly closed when a response is received and close_on_response is true.
            if close_on_response && is_response {

@jokemanfire jokemanfire merged commit 4c34b64 into modelcontextprotocol:main Jun 18, 2025
11 checks passed
@github-actions github-actions bot mentioned this pull request Jul 2, 2025
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.

Streamable HTTP connection leak

2 participants