FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add client callbacks for list_changed notifications by omar-y-abdi · Pull Request #2281 · modelcontextprotocol/python-sdk · GitHub

Add client callbacks for list_changed notifications - #2281

Open
omar-y-abdi wants to merge 3 commits into
modelcontextprotocol:mainfrom
omar-y-abdi:fix/handle-list-changed-notifications
Open

Add client callbacks for list_changed notifications#2281
omar-y-abdi wants to merge 3 commits into
modelcontextprotocol:mainfrom
omar-y-abdi:fix/handle-list-changed-notifications

Conversation

Copy link
Copy Markdown

Fixes #2107.

ClientSession._received_notification silently dropped ToolListChangedNotification, ResourceListChangedNotification, and PromptListChangedNotification via a catch-all pass. This adds optional callback parameters (tools_list_changed_callback, resources_list_changed_callback, prompts_list_changed_callback) following the existing logging_callback pattern, so clients can react when the server signals that its tool, resource, or prompt lists have changed.

Changes:

  • Added ListChangedFnT protocol type and default no-op callback in session.py
  • Added three new optional callback params to ClientSession.init
  • Added match cases in _received_notification for the three notification types
  • Wired the callbacks through the Client dataclass in client.py
  • Added 4 tests: one for each notification type plus a negative test

The ClientSession._received_notification method silently dropped
ToolListChangedNotification, ResourceListChangedNotification, and
PromptListChangedNotification. Add optional callback parameters
following the existing logging_callback pattern so clients can
react when the server signals that its tool, resource, or prompt
lists have changed.

Github-Issue: modelcontextprotocol#2107
…hods

These methods are now exercised by the new list_changed callback tests,
so the strict-no-cover CI check rejects the pragma.

Github-Issue: modelcontextprotocol#2107
Kludex self-assigned this Apr 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle list_changed notifications instead of dropping them

2 participants


Back | FazBrowse Home | New Git URL