Fix: Respect explicit listChanged: false capability setting#1513
Merged
mattzcarey merged 2 commits intomainfrom Feb 10, 2026
Merged
Fix: Respect explicit listChanged: false capability setting#1513mattzcarey merged 2 commits intomainfrom
mattzcarey merged 2 commits intomainfrom
Conversation
Changed McpServer to check existing capabilities before setting listChanged to true, allowing users to explicitly set listChanged: false for tools, resources, and prompts. Made Server.getCapabilities() public to enable this check.
|
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
KKonstantinov
approved these changes
Feb 10, 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
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.
Problem
When instantiating
McpServerwithcapabilities.tools.listChangedset tofalse, the setting was being overwritten totruewhen registering a tool viaregisterTool().This prevents servers from opting out of list change notifications, which may be desirable for stateless server implementations.
Fixes #1488
Solution
Changed the
registerCapabilitiescalls insetToolRequestHandlers(),setResourceRequestHandlers(), andsetPromptRequestHandlers()to use nullish coalescing, only defaulting totruewhen not explicitly set:Design Decisions
Made
Server.getCapabilities()public - This was the minimal change needed to allowMcpServerto check existing capability values. The method already existed as private; we simply changed visibility.Defaulting at registration time - We considered moving the default elsewhere (e.g., constructor), but
listChanged: trueonly makes sense when tools/resources/prompts are actually registered. Keeping the default at registration time preserves this semantic.Nullish coalescing (
?? true) - This ensures:false→ staysfalsetrue→ staystrueundefined) → defaults totrue(backwards compatible)No breaking changes - Existing code that doesn't set
listChangedcontinues to getlistChanged: trueas before.Test Plan
Added 4 tests:
should default tools.listChanged to true when not explicitly setshould respect tools.listChanged: false when explicitly setshould respect resources.listChanged: false when explicitly setshould respect prompts.listChanged: false when explicitly set