LangChain MCP Adapter Lacks Support For Server-Sent Notifications And Progress
The Python LangChain MCP adapter does not expose handlers for MCP server notifications (e.g., tool list changes) or progress updates, contrary to the JavaScript SDK. This prevents dynamic tool updates and progress visibility in MCP-based agents.
In `langchain_mcp_adapters/client.py`, `MultiServerMCPClient` creates `ClientSession` instances without passing the `message_handler` and `progress_handler` parameters. Consequently, incoming server notifications and progress messages are silently discarded by the underlying MCP client.
1. Start an MCP server that emits `notifications/tools/list_changed` or progress notifications.
2. Connect to it using `MultiServerMCPClient`.
3. Trigger a tool list change on the server.
4. Observe that the client's cached tool list does not update and no progress callbacks are invoked.
Add optional `notification_handler` and `progress_handler` parameters to `MultiServerMCPClient` and pass them to the underlying `ClientSession`. This allows users to supply callbacks that are invoked for every server notification and progress update. The default value `None` preserves backward compatibility.
Edge Case Audit
Passing handler functions with incorrect signatures will raise runtime errors during message processing. Third-party MCP servers may flood the client with notifications, potentially overwhelming the callback; users should debounce refresh operations. Rollback: revert the constructor to its original signature and remove the two new arguments; existing installations will continue to work unchanged because the new parameters default to `None`.