| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…responses _handle_post_request unconditionally overwrote self._request_streams[request_id], so a second concurrent POST reusing an in-flight request's id would silently take over that request's stream and both callers would race for a single response. Reject the second request with a 409 duplicate-request-id error instead of overwriting the existing in-flight entry, for both the JSON and SSE response modes. Fixes modelcontextprotocol#3137
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/mcp/server/streamable_http.py">
<violation number="1" location="src/mcp/server/streamable_http.py:553">
P1: Duplicate SSE requests can still overwrite each other's streams when resumability is enabled. The check happens before awaiting `_mint_priming_event`, but that user-provided async event-store call leaves no request entry registered; another same-ID POST can pass the check and both requests subsequently assign `_request_streams[request_id]`. Consider reserving the ID before the await (and cleaning it up if priming fails), or rechecking immediately after priming before registering the streams.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Sorry, something went wrong.
| request_id = str(message.id) | ||
|
|
||
| if self.is_json_response_enabled: | ||
| if request_id in self._request_streams: |
There was a problem hiding this comment.
P1: Duplicate SSE requests can still overwrite each other's streams when resumability is enabled. The check happens before awaiting _mint_priming_event, but that user-provided async event-store call leaves no request entry registered; another same-ID POST can pass the check and both requests subsequently assign _request_streams[request_id]. Consider reserving the ID before the await (and cleaning it up if priming fails), or rechecking immediately after priming before registering the streams.
Prompt for AI agentsCheck if this issue is valid — if so, understand the root cause and fix it. At src/mcp/server/streamable_http.py, line 553:
<comment>Duplicate SSE requests can still overwrite each other's streams when resumability is enabled. The check happens before awaiting `_mint_priming_event`, but that user-provided async event-store call leaves no request entry registered; another same-ID POST can pass the check and both requests subsequently assign `_request_streams[request_id]`. Consider reserving the ID before the await (and cleaning it up if priming fails), or rechecking immediately after priming before registering the streams.</comment>
<file context>
@@ -550,6 +550,13 @@ async def _handle_post_request(self, scope: Scope, request: Request, receive: Re
request_id = str(message.id)
if self.is_json_response_enabled:
+ if request_id in self._request_streams:
+ response = self._create_error_response(
+ "Duplicate request id: a request with this id is already in flight on this session.",
</file context>
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #3137
Test plan
Disclosure
This change was written with AI assistance (Claude Code); I reviewed the diff and can answer questions about it.