Skip to content

Conversation

taobaorun
Copy link

Motivation and Context

In the streamable context, repeated GET requests within the same session spawn multiple listening SSE connections, which

can lead the server to create unnecessary SSE

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

@He-Pin
Copy link
Contributor

He-Pin commented Aug 28, 2025

Are you working for TaoBao Group?

String lastId = request.headers().asHttpHeaders().getFirst(HttpHeaders.LAST_EVENT_ID);
return ServerResponse.ok()
.contentType(MediaType.TEXT_EVENT_STREAM)
.body(session.replay(lastId), ServerSentEvent.class);
}
if (listenedStream instanceof McpStreamableServerSessionStream) {
logger.debug("Listening stream for session: {} exists.", sessionId);
Copy link
Contributor

Choose a reason for hiding this comment

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

if(logger.isDebugEnabled) ...

@chemicL
Copy link
Member

chemicL commented Aug 29, 2025

Hey, thanks for the proposal. I see this might be an issue, agreed. However, my worry is that someone might be making a new GET request because the previous one is broken. The way forward that I see is not to reject the new GET request but instead make sure that if one listening stream exists it is properly closed and replaced with this new one instead. WDYT?

@taobaorun
Copy link
Author

Hey, thanks for the proposal. I see this might be an issue, agreed. However, my worry is that someone might be making a new GET request because the previous one is broken. The way forward that I see is not to reject the new GET request but instead make sure that if one listening stream exists it is properly closed and replaced with this new one instead. WDYT?

Thanks for the helpful suggestion—code updated, tested, and confirmed working.

Copy link
Member

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

Thanks! I left my feedback to evolve the implementation towards a more atomic operation.

@taobaorun taobaorun requested a review from chemicL September 1, 2025 16:58
Copy link
Member

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

I left a comment that needs addressing if you'd like to take it forward. Also, I think we need tests to validate that this change is doing what is expected. Let us know if you want to continue making progress here. Thanks!

@taobaorun
Copy link
Author

I left a comment that needs addressing if you'd like to take it forward. Also, I think we need tests to validate that this change is doing what is expected. Let us know if you want to continue making progress here. Thanks!

I will continue to follow up and solve this problem.🤝

@taobaorun taobaorun requested a review from chemicL September 3, 2025 05:57
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.

3 participants