fix: forward proxy server notifications#4191
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b5fa38941
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if not isinstance(client, ProxyClient): | ||
| _install_plain_client_proxy_message_handler(client) | ||
| return client |
There was a problem hiding this comment.
Apply proxy message handler before reusing connected client
When create_proxy() receives a connected plain Client, this branch calls _install_plain_client_proxy_message_handler(client) and then reuses the same connection, but _install_* only mutates client._session_kwargs. For an already-open session, connect_session(**_session_kwargs) has already run, so the active receive loop keeps the old handler and upstream notifications are still not forwarded in this mode. This means connected-client proxying does not get the behavior this change intends unless the client disconnects/reconnects first.
Useful? React with 👍 / 👎.
1b5fa38 to
8b5a32e
Compare
|
Updated to address the connected-client review finding. For a plain Added a regression test for Validation:
|
Summary
Fixes #4161.
This makes FastMCP proxies forward upstream server notifications to the downstream client while a proxied request is active. It covers ordinary MCP notifications such as tool/resource/prompt list changes and resource updates.
For
create_proxy(Client(...)), the wrapper also forwards logging/progress notifications because a plain client does not useProxyClient's proxy log/progress callbacks. ForProxyClient, the existing log/progress callbacks stay in charge, so this only fills the missing ordinary-notification path.To verify
PYTHONUTF8=1 TMP=.tmp/pytest TEMP=.tmp/pytest python -m pytest tests/server/providers/proxy/test_proxy_server.py -qpython -m ruff check fastmcp_slim/fastmcp/server/providers/proxy.py tests/server/providers/proxy/test_proxy_server.pyuv run --frozen ty check fastmcp_slim/fastmcp/server/providers/proxy.py tests/server/providers/proxy/test_proxy_server.pygit diff --checkpython -m py_compile fastmcp_slim/fastmcp/server/providers/proxy.py tests/server/providers/proxy/test_proxy_server.py