Repository navigation
Add support for MCP dynamic tool update by notifications/tools/list_changed - #14375
Conversation
Summary of ChangesHello @Adib234, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Model Context Protocol (MCP) integration by enabling dynamic tool updates. It allows the CLI to automatically detect and incorporate new tools provided by an MCP server in real-time, eliminating the need for manual restarts and ensuring that users always have access to the latest tool definitions during their session. This improves the responsiveness and usability of the tool ecosystem. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for dynamic tool updates from MCP servers, which is a great feature. The implementation correctly uses the tools/list_changed notification to trigger a refresh of the tool registry. The changes are well-tested. I've found one potential race condition in the tool refresh logic that could lead to a stale state if multiple notifications are processed concurrently. I've suggested a fix to serialize the refresh operations.
|
Size Change: +3.63 kB (+0.02%) Total Size: 21.5 MB
ℹ️ View Unchanged
|
jackwotherspoon
left a comment
There was a problem hiding this comment.
Does this PR add support for MCP notifications or just a single type of notification?
Single type of notification. Only for tools update from an MCP server. |
Add 2 tests to test timeouts being triggered in discoverTools and onToolsUpdated call Remove some doc Add abort signal for timeouts
Following PR google-gemini#14375 I tried to make the Resource refreshing consistent with the tools logic. I added coalescence/debounce feature to prevent overwhelming the client and the server in case of frequent updates
Following PR google-gemini#14375 I tried to make the Resource refreshing consistent with the tools logic. I added coalescence/debounce feature to prevent overwhelming the client and the server in case of frequent updates
Summary
Support for MCP server dynamic tool updates via the notifications/tools/list_changed notification mechanism.
Details
This PR uses the event handler for notifications in the
model-context-protocolpackage to update the tool registry if an MCP server has a new tool. We don't need a restart to include new tools from an MCP server, they can happen during a user's session.Related Issues
Related to #13850
How to Validate
Setup a MCP server that initially has 1 tool, and then after 5 seconds it has 2 tools
Code for script -> https://paste.googleplex.com/6170557420797952
What it looks like in the CLI (initially there was 1 tool for test-server, but after an update there's 2)
Pre-Merge Checklist