feat: handle tools/resources/prompts list_changed notifications#1191
Open
Christian-Sidak wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Conversation
Add handlers for notifications/tools/list_changed, notifications/resources/list_changed, and notifications/prompts/list_changed in the onNotification callback. When a server sends these notifications, the inspector now resets pagination cursors and re-fetches the corresponding lists, enabling dynamic tool/resource/prompt registration use cases such as gateway MCP servers that load/unload capabilities at runtime. Fixes modelcontextprotocol#832
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
notifications/tools/list_changed,notifications/resources/list_changed, andnotifications/prompts/list_changedin theonNotificationcallbackChanges
In
client/src/App.tsx, added three conditional blocks to the existingonNotificationcallback, following the same pattern as the existingnotifications/tasks/list_changedhandler:notifications/tools/list_changed-- resets tool cursor, clears tools, re-fetches vialistTools()notifications/resources/list_changed-- resets resource and template cursors, clears both lists, re-fetches vialistResources()andlistResourceTemplates()notifications/prompts/list_changed-- resets prompt cursor, clears prompts, re-fetches vialistPrompts()The notification schemas (
ToolListChangedNotificationSchema,ResourceListChangedNotificationSchema,PromptListChangedNotificationSchema) are already imported and registered on the MCP client inuseConnection.ts-- this PR adds the missing response logic.Testing
notifications/tools/list_changednotificationBuild passes (
npm run buildsucceeds).Fixes #832