Skip to content

Commit dfa8c05

Browse files
committed
Route Context.report_progress() to the originating request stream
Context.report_progress() called send_progress_notification() without related_request_id, so on Streamable HTTP the progress notification was routed to the standalone GET stream instead of the originating POST's SSE response. If the client had not yet opened (or never opens) the GET stream, the notification was silently dropped. Context.log(), elicit(), and elicit_url() already pass related_request_id=self.request_id; this brings report_progress() in line.
1 parent 777b8d0 commit dfa8c05

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/mcp/server/fastmcp/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ async def report_progress(self, progress: float, total: float | None = None, mes
11771177
progress=progress,
11781178
total=total,
11791179
message=message,
1180+
related_request_id=self.request_id,
11801181
)
11811182

11821183
async def read_resource(self, uri: str | AnyUrl) -> Iterable[ReadResourceContents]:

tests/issues/test_176_progress_token.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ async def test_progress_token_zero_first_call():
3636

3737
# Verify progress notifications
3838
assert mock_session.send_progress_notification.call_count == 3, "All progress notifications should be sent"
39-
mock_session.send_progress_notification.assert_any_call(progress_token=0, progress=0.0, total=10.0, message=None)
40-
mock_session.send_progress_notification.assert_any_call(progress_token=0, progress=5.0, total=10.0, message=None)
41-
mock_session.send_progress_notification.assert_any_call(progress_token=0, progress=10.0, total=10.0, message=None)
39+
mock_session.send_progress_notification.assert_any_call(
40+
progress_token=0, progress=0.0, total=10.0, message=None, related_request_id="test-request"
41+
)
42+
mock_session.send_progress_notification.assert_any_call(
43+
progress_token=0, progress=5.0, total=10.0, message=None, related_request_id="test-request"
44+
)
45+
mock_session.send_progress_notification.assert_any_call(
46+
progress_token=0, progress=10.0, total=10.0, message=None, related_request_id="test-request"
47+
)

0 commit comments

Comments
 (0)