Skip to content

fix(core): complete MCP discovery when configured servers are skipped - #18586

Merged
chrstnb merged 2 commits into
mainfrom
feature-mcp-init-readiness
Feb 11, 2026
Merged

fix(core): complete MCP discovery when configured servers are skipped#18586
chrstnb merged 2 commits into
mainfrom
feature-mcp-init-readiness

Conversation

@LyalinDotCom

Copy link
Copy Markdown
Collaborator

Summary

Fixes an MCP readiness edge case that could block normal prompt execution indefinitely.

When configured MCP servers are all skipped during startup (for example, user-disabled or blocked), discovery could remain in IN_PROGRESS forever. The UI then kept queueing prompts behind "Waiting for MCP servers to initialize...".

Details

  • Update startConfiguredMcpServers() in packages/core/src/tools/mcp-client-manager.ts:
    • after startup attempts complete, if no discovery promise exists, mark discovery as COMPLETED and emit mcp-client-update.
  • Add regression coverage in packages/core/src/tools/mcp-client-manager.test.ts:
    • should mark discovery completed when all configured servers are user-disabled
    • should mark discovery completed when all configured servers are blocked

Behavioral flow:

before: configured servers -> IN_PROGRESS -> all skipped -> no discovery promise -> stuck IN_PROGRESS
after:  configured servers -> IN_PROGRESS -> all skipped -> no discovery promise -> COMPLETE + update event

Related Issues

Fixes #18585

How to Validate

  1. Run focused MCP manager tests:
    • npm run test --workspace @google/gemini-cli-core -- src/tools/mcp-client-manager.test.ts
  2. Run MCP-related core tests:
    • npm run test --workspace @google/gemini-cli-core -- src/tools/mcp-client.test.ts src/tools/mcp-tool.test.ts src/prompts/mcp-prompts.test.ts src/tools/xcode-mcp-fix-transport.test.ts src/code_assist/admin/mcpUtils.test.ts
  3. Run CLI MCP readiness queue tests:
    • npm run test --workspace @google/gemini-cli -- src/ui/hooks/useMcpStatus.test.tsx src/ui/hooks/useMessageQueue.test.tsx
  4. Run full core suite:
    • npm run test --workspace @google/gemini-cli-core

Expected result: all listed suites pass; when all configured MCP servers are skipped, discovery transitions to COMPLETED and prompts are not permanently queued.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@LyalinDotCom
LyalinDotCom requested a review from a team as a code owner February 9, 2026 00:38
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @LyalinDotCom, 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 resolves a critical bug that prevented the MCP discovery process from finalizing when all configured servers were intentionally bypassed. By ensuring that the system correctly transitions to a completed state under these conditions, it prevents the user interface from indefinitely waiting for initialization and unblocks prompt execution.

Highlights

  • Fixes MCP discovery deadlock: Addresses an edge case where MCP discovery could remain 'IN_PROGRESS' indefinitely if all configured servers are skipped (e.g., user-disabled or blocked), leading to blocked prompt execution.
  • Ensures discovery completion: Modifies 'startConfiguredMcpServers()' to explicitly set the discovery state to 'COMPLETED' and emit an 'mcp-client-update' event when no discovery promise is created, indicating all servers were skipped.
  • Adds regression tests: Introduces new test cases in 'mcp-client-manager.test.ts' to verify correct discovery completion when all configured servers are user-disabled or blocked.
Changelog
  • packages/core/src/tools/mcp-client-manager.test.ts
    • Added a test case to ensure discovery completes when all configured servers are user-disabled.
    • Added a test case to ensure discovery completes when all configured servers are blocked.
  • packages/core/src/tools/mcp-client-manager.ts
    • Implemented logic within 'startConfiguredMcpServers' to check if 'discoveryPromise' was created. If not, it explicitly sets 'discoveryState' to 'COMPLETED' and emits an 'mcp-client-update' event.
Activity
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.

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

  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.

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

Copy link
Copy Markdown
Contributor

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 correctly identifies and fixes an important edge case where MCP discovery could remain in an IN_PROGRESS state indefinitely if all configured servers are skipped on startup. The addition of regression tests is also a valuable contribution. The provided critical review comment with a suggested code change makes the logic more robust by checking the discovery state directly, which correctly handles all scenarios. With this change, the fix will be solid.

Comment thread packages/core/src/tools/mcp-client-manager.ts Outdated
@github-actions

github-actions Bot commented Feb 9, 2026

Copy link
Copy Markdown

Size Change: +210 B (0%)

Total Size: 24.3 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 24.3 MB +210 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@gemini-cli gemini-cli Bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Feb 9, 2026
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@chrstnb
chrstnb enabled auto-merge February 11, 2026 16:27
@chrstnb
chrstnb added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit f5dd106 Feb 11, 2026
27 checks passed
@chrstnb
chrstnb deleted the feature-mcp-init-readiness branch February 11, 2026 16:42
kuishou68 pushed a commit to iOfficeAI/gemini-cli-pro that referenced this pull request Feb 27, 2026
…google-gemini#18586)

Co-authored-by: christine betts <chrstn@uw.edu>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
liamhelmer pushed a commit to badal-io/gemini-cli that referenced this pull request Mar 12, 2026
…google-gemini#18586)

Co-authored-by: christine betts <chrstn@uw.edu>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
cocosheng-g pushed a commit that referenced this pull request May 6, 2026
…#18586)

Co-authored-by: christine betts <chrstn@uw.edu>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@sripasg sripasg added the size/s A small PR label Jun 2, 2026
software-0ficial pushed a commit to software-0ficial/gemini-cli that referenced this pull request Jul 9, 2026
…google-gemini#18586)

Co-authored-by: christine betts <chrstn@uw.edu>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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 size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompts queue indefinitely when all configured MCP servers are skipped

3 participants