Repository navigation
fix: preserve user-set listChanged capability in McpServer constructor - #3076
Jihaochang1 wants to merge 3 commits into
Conversation
Fixes modelcontextprotocol#2622 by ensuring that when a user explicitly sets listChanged: false in the constructor options, this value is preserved instead of being unconditionally overridden to true.
🦋 Changeset detectedLatest commit: 18fc231 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Read the diff against
Is the reporter of #2622 only using tools, or do they also set |
|
Thanks for the careful review — all three points were fair, and I've pushed a follow-up commit (18fc231) addressing them:/n/n1. Compile error: You're right,
On your question: the reporter in #2622 only sets One note on the test: |
Follow-up to the listChanged fix, addressing the review comments on modelcontextprotocol#3076: - Keep the constructor-declared capabilities on McpServer itself instead of reading the private Server._capabilities, which does not compile (private access across classes) - Apply the same preservation to the resources and prompts registration, which also unconditionally advertised listChanged: true - Add tests asserting listChanged: false is preserved for tools, resources and prompts, and that the default stays true when unset Signed-off-by: Jihaochang1 <358550956@qq.com>
|
Read 18fc231 (not run). The three fixes do what you describe: the value comes from One thing left that I think belongs in this PR or a note on it: advertising Does anything in the maintainers' discussion on #2622 say whether a server with |
| this.server.registerCapabilities({ | ||
| tools: { | ||
| listChanged: true | ||
| listChanged: this._resolveListChanged('tools') |
There was a problem hiding this comment.
does advertising listChanged: false here also need to stop registerTool from calling sendToolListChanged() (around L1007)? right now a server that opts out still notifies on every register/update/remove, which clients that trusted the capability won't expect
Fixes #2622
Problem
When constructing an McpServer with
capabilities: { tools: { listChanged: false } },the value is silently overridden to
truewhen any tool is registered.Root Cause
In
setToolRequestHandlers(), the code unconditionally calls:This overwrites any user-specified
listChanged: falsesetting.Fix
Check the existing capabilities before overriding:
Testing
Added test case verifying that constructor option takes precedence.
Impact