fix(core): create new McpClient on restart to apply updated config#20126
fix(core): create new McpClient on restart to apply updated config#20126scidomino merged 1 commit intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello @h30s, 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 addresses a critical bug where configuration changes for Highlights
Changelog
Activity
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 correctly addresses a bug where updated configurations for MCP servers were ignored on restart or reload. The fix ensures that a new McpClient instance is always created with the latest configuration, instead of reusing a stale one. The accompanying test effectively validates this change. I've added one suggestion to improve the robustness of the client disconnection logic to prevent potential issues with stale clients if the disconnection process fails.
031bd9d to
6aa647e
Compare
|
@scidomino Please take a look whenever you have time. The PR is ready from my side 😊 |
e4204d5
Summary
Fix McpClient instance reuse during server restart/reload that silently ignores updated configurations. Always create a new McpClient with the current config instead of reusing the stale instance.
Details
In
maybeDiscoverMcpServer(), the existingMcpClientwas disconnected but then reused viaexisting ?? new McpClient(...). SinceMcpClientstores itsserverConfigasprivate readonly, any updated configuration (changed command, args, env, timeout) was silently ignored. The fix disconnects and removes the old client, then always constructs a newMcpClientwith the updated config.Related Issues
Fixes #19792
How to Validate
npm test -w @google/gemini-cli-core -- src/tools/mcp-client-manager.test.tsshould create a new McpClient with updated config on restartpasses.npm run typecheck npm run lint npm run testPre-Merge Checklist