Skip to content

fix(core): disconnect extension-backed MCP clients in stopExtension#26136

Merged
Adib234 merged 1 commit intogoogle-gemini:mainfrom
cocosheng-g:repro-24050
Apr 28, 2026
Merged

fix(core): disconnect extension-backed MCP clients in stopExtension#26136
Adib234 merged 1 commit intogoogle-gemini:mainfrom
cocosheng-g:repro-24050

Conversation

@cocosheng-g
Copy link
Copy Markdown
Contributor

McpClientManager.stopExtension() was passing the server name to disconnectClient() instead of the computed client key. This resulted in extension-backed MCP clients remaining connected even after the extension was unloaded. Fixes #24050

@cocosheng-g cocosheng-g requested a review from a team as a code owner April 28, 2026 17:55
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 an issue where extension-backed MCP clients remained active after an extension was unloaded. By ensuring the correct client key is used during the disconnection process, the manager now properly cleans up resources, preventing potential memory leaks or stale connections.

Highlights

  • Bug Fix: Corrected the disconnection logic in McpClientManager.stopExtension to use the computed client key instead of the server name.
  • Regression Testing: Added a new test case to verify that extension-backed MCP clients are properly disconnected when an extension is stopped.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 ensures that extension-backed MCP clients are correctly disconnected when an extension is stopped. The fix involves using the proper client key derived from the server name and configuration instead of just the name. A new test case has been added to mcp-client-manager.test.ts to verify this behavior and prevent regressions. I have no feedback to provide.

@Adib234 Adib234 enabled auto-merge April 28, 2026 18:00
@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/extensions Issues related to Gemini CLI extensions capability labels Apr 28, 2026
@cocosheng-g cocosheng-g self-assigned this Apr 28, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

55 tests passed successfully on gemini-3-flash-preview.

🧠 Model Steering Guidance

This PR modifies files that affect the model's behavior (prompts, tools, or instructions).

  • ⚠️ Consider adding Evals: No behavioral evaluations (evals/*.eval.ts) were added or updated in this PR. Consider adding a test case to verify the new behavior and prevent regressions.
  • 🚀 Maintainer Reminder: Please ensure that these changes do not regress results on benchmark evals before merging.

This is an automated guidance message triggered by steering logic signatures.

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request Apr 28, 2026
…correctness fixes

- openai/codex#20046 lock InterAgentCommunication commentary-phase contract
- BerriAI/litellm#26710 file content on Bedrock+Anthropic tool-result path
- google-gemini/gemini-cli#26136 disconnect extension-backed MCP clients via clientKey
@Adib234 Adib234 added this pull request to the merge queue Apr 28, 2026
Merged via the queue into google-gemini:main with commit 6d99113 Apr 28, 2026
29 checks passed
TirthNaik-99 pushed a commit to TirthNaik-99/gemini-cli that referenced this pull request May 4, 2026
kimjune01 pushed a commit to kimjune01/gemini-cli-claude that referenced this pull request May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/extensions Issues related to Gemini CLI extensions capability priority/p2 Important but can be addressed in a future release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

McpClientManager.stopExtension does not disconnect extension-backed MCP clients

3 participants