feat: handle tools/resources/prompts list_changed notifications#1132
Open
herakles-dev wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
feat: handle tools/resources/prompts list_changed notifications#1132herakles-dev wants to merge 1 commit intomodelcontextprotocol:mainfrom
herakles-dev wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
When a server sends list_changed notifications, the inspector now automatically refreshes the corresponding lists. Pagination cursors are reset to ensure a clean re-fetch from the first page. Follows the existing pattern used for tasks/list_changed. Closes modelcontextprotocol#832 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add handling for
notifications/tools/list_changed,notifications/resources/list_changed, andnotifications/prompts/list_changedin the inspector's notification callback. When a server sends these notifications, the inspector now automatically refreshes the corresponding lists — matching the existingtasks/list_changedpattern.This enables dynamic tool/resource/prompt registration use cases (e.g., gateway MCP servers that load/unload tools at runtime).
Type of Change
Changes Made
client/src/App.tsx— Added 3 conditional blocks to theonNotificationcallback:notifications/tools/list_changed→ resets tool cursor, clears tools, re-fetches vialistTools()notifications/resources/list_changed→ resets resource + template cursors, clears both lists, re-fetches vialistResources()+listResourceTemplates()notifications/prompts/list_changed→ resets prompt cursor, clears prompts, re-fetches vialistPrompts()Each handler resets pagination cursors to
undefinedbefore re-fetching to ensure a clean refresh from page 1 (not a paginated continuation).The notification schemas (
ToolListChangedNotificationSchema,ResourceListChangedNotificationSchema,PromptListChangedNotificationSchema) are already imported and registered on the MCP client inuseConnection.ts— this PR adds the missing response logic.Related Issues
Fixes #832
Testing
Test Results and/or Instructions
notifications/tools/list_changednotificationThe implementation follows the exact same pattern as the existing
notifications/tasks/list_changedhandler (line 424), which is already working in production.Checklist
npm run prettier-fix)Breaking Changes
None. This is a purely additive change.
Additional Context
The infrastructure was already 95% complete:
useConnection.ts(lines 29-31)listTools,listResources,listPrompts) already existThe only missing piece was responding to the notifications in the
onNotificationcallback, which this PR adds.