Skip to content

fix(mcp): Notifications/tools/list_changed support not working#21050

Merged
bdmorgan merged 3 commits intomainfrom
jacob314/mcp_update
Mar 4, 2026
Merged

fix(mcp): Notifications/tools/list_changed support not working#21050
bdmorgan merged 3 commits intomainfrom
jacob314/mcp_update

Conversation

@jacob314
Copy link
Copy Markdown
Contributor

@jacob314 jacob314 commented Mar 4, 2026

Summary

This change was done with TDD with tests that were verified to fail before implementing the code.

  • Improved MCP Context Refresh Mechanism: The MCP context refresh logic has been enhanced to handle rapid, consecutive refresh requests more robustly. It now includes mechanisms for debouncing, queuing trailing executions, and ensuring that all pending refreshes are processed, preventing potential missed updates.
  • Enhanced Robustness for List Changed Notifications: The client now registers notification handlers for 'list_changed' events (for tools, resources, and prompts) even if the server's capabilities do not explicitly declare support for listChanged. This improves resilience against servers that might send notifications without fully adhering to capability declarations.
  • Tool Discovery Verification Retry: A verification retry mechanism has been added to the tool refresh process. If an initial tool discovery yields no tools or no changes, the client will wait briefly and attempt discovery again, addressing potential race conditions where a server might notify of changes before its tool list is fully updated.
  • Updated Unit Tests: Unit tests for mcp-client have been updated to reflect the new robustness logic, including a new test case to verify notification handler setup when listChanged is false, and improvements to how notification callbacks are identified in mocks.

Fixes #19509

@jacob314 jacob314 requested a review from a team as a code owner March 4, 2026 02:49
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the robustness of handling MCP list_changed notifications. The changes to always register notification handlers and to add a retry mechanism for tool discovery are good enhancements to deal with non-compliant or racy MCP servers. I've found a potential issue in the new refresh scheduling logic in mcp-client-manager.ts where a pending refresh request could be lost if the current refresh operation fails.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Size Change: +5.27 kB (+0.02%)

Total Size: 25.9 MB

Filename Size Change
./bundle/gemini.js 25.5 MB +5.27 kB (+0.02%)
ℹ️ View Unchanged
Filename Size
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB
./bundle/sandbox-macos-strict-open.sb 4.82 kB
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB

compressed-size-action

@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. labels Mar 4, 2026
@jacob314 jacob314 force-pushed the jacob314/mcp_update branch from 249c132 to 6d537f0 Compare March 4, 2026 06:54
@google-gemini google-gemini deleted a comment from gemini-code-assist bot Mar 4, 2026
@google-gemini google-gemini deleted a comment from gemini-cli bot Mar 4, 2026
@bdmorgan bdmorgan added this pull request to the merge queue Mar 4, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2026
@bdmorgan bdmorgan added this pull request to the merge queue Mar 4, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2026
@bdmorgan bdmorgan merged commit 352fb0c into main Mar 4, 2026
27 checks passed
@bdmorgan bdmorgan deleted the jacob314/mcp_update branch March 4, 2026 14:46
neeraj-par pushed a commit to neeraj-par/gemini-cli that referenced this pull request Mar 4, 2026
BryanBradfo pushed a commit to BryanBradfo/gemini-cli that referenced this pull request Mar 5, 2026
struckoff pushed a commit to struckoff/gemini-cli that referenced this pull request Mar 6, 2026
kunal-10-cloud pushed a commit to kunal-10-cloud/gemini-cli that referenced this pull request Mar 12, 2026
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
yashodipmore pushed a commit to yashodipmore/geemi-cli that referenced this pull request Mar 21, 2026
SUNDRAM07 pushed a commit to SUNDRAM07/gemini-cli that referenced this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality 🔒 maintainer only ⛔ Do not contribute. Internal roadmap item. priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

notifications/tools/list_changed support not working

2 participants