Skip to content

Conversation

alexsee
Copy link
Contributor

@alexsee alexsee commented Jun 15, 2025

This pull request fixes an issue related to report_progress that misses passing the related_request_id which causes notifications not working in stateless_http=True mode.

This issue was also reported for the FastMCP implementation in the Python MCP SDK: modelcontextprotocol/python-sdk#953

I also added a test for stateless_http=True mode introducing a parameterized pytest (not sure if you prefer having this in a separate file or keep it there).

@Copilot Copilot AI review requested due to automatic review settings June 15, 2025 16:24
@github-actions github-actions bot added the tests label Jun 15, 2025
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 addresses an issue in the report_progress functionality by ensuring that the related_request_id is passed along, which fixes notifications not working in stateless_http mode. Key changes include:

  • Adding the related_request_id parameter to the report_progress call in the server context.
  • Updating server initialization and test fixtures to support the stateless_http mode configuration.
  • Introducing a new parameterized pytest for testing the greet tool progress reporting.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/client/test_streamable_http.py Updated test fixtures and added tool testing for progress reporting.
src/fastmcp/server/context.py Modified report_progress to include related_request_id in the payload.
Comments suppressed due to low confidence (2)

src/fastmcp/server/context.py:125

  • Ensure that adding 'related_request_id' to the progress payload does not affect progress handler consumers. Verify that all clients or progress handlers are updated to either handle or ignore this additional parameter as necessary.
related_request_id=self.request_id,

tests/client/test_streamable_http.py:145

  • The test asserts the progress handler receives three parameters, but the updated implementation now passes an extra 'related_request_id'. Adjust the test assertion or confirm that the extra parameter is properly handled (or ignored) in progress handler invocation.
progress_handler.assert_called_once_with(0.5, 1.0, "Greeting in progress")

@jlowin
Copy link
Owner

jlowin commented Jun 15, 2025

Thank you!

@jlowin jlowin merged commit df78b21 into jlowin:main Jun 15, 2025
4 checks passed
@jlowin
Copy link
Owner

jlowin commented Jun 15, 2025

I wonder why the low-level doesn't fill that in by default 🤔 But appreciate the fix!

@alexsee
Copy link
Contributor Author

alexsee commented Jun 15, 2025

I wonder why the low-level doesn't fill that in by default

Thats a very good question and if the server is run in stateful mode, the requests are handled differently through the GET_stream (SSE) that is established. In that case, the related_request_id is not used.

For other logging methods, the related_request_id is actually set and it was added as part of the streaming-http implementation:

For the context class in FastMCP (in this repo), these are also missing as I see.

What I'm not entirely sure is if there are any side effects that I may have introduced due to this change.

@jlowin jlowin added the bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. label Jun 23, 2025
jordicore pushed a commit to jordicore/fastmcp that referenced this pull request Jul 2, 2025
…s-missing-related-request-id

fix: report_progress missing passing related_request_id causes notifications not working in streaming-http
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants