-
Notifications
You must be signed in to change notification settings - Fork 8k
Initialize MCP tools once at start up instead of every time we auth. #3483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @scidomino, 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!
I've refactored the application's startup sequence to initialize Managed Code Platform (MCP) tools and other core services only once at the beginning of the application lifecycle, rather than repeatedly during authentication attempts. This change aims to improve the user experience by providing clearer feedback during startup, preventing confusion between authentication issues and slow MCP server initialization, and addressing a specific bug related to this behavior.
Highlights
- Centralized Initialization: I've consolidated the initialization of core services like FileDiscovery, Git, and MCP tools into a new
config.initialize()
method, ensuring they are set up once at application startup. - Improved User Experience: I've decoupled MCP tool initialization from the authentication flow. This change aims to prevent user confusion by clarifying error messages and providing better feedback when MCP servers are slow to start, addressing issue #2926.
- Refactored Tool Dependencies: I've updated
EditTool
andWriteFileTool
so they no longer directly hold aGeminiClient
instance. Instead, they now retrieve it on demand from theConfig
object, promoting better dependency management and reducing direct coupling. - Configuration Simplification: I've simplified the
createContentGeneratorConfig
function by removing its dependency on theConfig
object for model determination, streamlining its usage.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 is currently in preview and 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 to provide feedback.
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
-
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. ↩
There was a problem hiding this 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 refactors the initialization of MCP tools to occur once at startup, rather than on every authentication. This is a significant architectural improvement that decouples tool initialization from the authentication flow, addressing user confusion with slow or failing MCP servers.
The changes are well-executed, moving initialization logic into a new Config.initialize
method and simplifying the refreshAuth
process. A notable improvement is that tools now fetch the GeminiClient
instance from the Config
on-demand, which resolves a latent bug where tools could hold onto a stale client after re-authentication.
I have one high-severity suggestion regarding error handling during git service initialization to ensure that failures in optional features like checkpointing are not silent.
Code Coverage Summary
CLI Package - Full Text Report
Core Package - Full Text Report
For detailed HTML reports, please see the 'coverage-reports-24.x' artifact from the main CI run. |
TLDR
Initialize MCP tools once at start up instead of every time we auth.
Dive Deeper
Previously we were initializing MCP tools every time we authenticate. This was confusing users with MCP errors because they'd see "Waiting for Auth..." in the start up screen when they had a MCP server that was slow to start up. Even worse, if there was an error with MCP users would assume it was related to Auth.
This change does cause startup to hang while we wait for the MCP servers to start up but I think this is still an improvement. We can add a MCP loading spinner in subsequent PRs.
Reviewer Test Plan
Use the following MCP server in your settings.json to simulate a MCP server that takes a long time to start up.
Testing Matrix
Linked issues / bugs
Fixes #2926