mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 03:24:42 -07:00
Add support for running available commands prior to MCP servers loading (#15596)
This commit is contained in:
@@ -274,6 +274,35 @@ describe('Server Config (config.ts)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should not await MCP initialization', async () => {
|
||||
const config = new Config({
|
||||
...baseParams,
|
||||
checkpointing: false,
|
||||
});
|
||||
|
||||
const { McpClientManager } = await import(
|
||||
'../tools/mcp-client-manager.js'
|
||||
);
|
||||
let mcpStarted = false;
|
||||
|
||||
(McpClientManager as unknown as Mock).mockImplementation(() => ({
|
||||
startConfiguredMcpServers: vi.fn().mockImplementation(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
mcpStarted = true;
|
||||
}),
|
||||
getMcpInstructions: vi.fn(),
|
||||
}));
|
||||
|
||||
await config.initialize();
|
||||
|
||||
// Should return immediately, before MCP finishes (50ms delay)
|
||||
expect(mcpStarted).toBe(false);
|
||||
|
||||
// Wait for it to eventually finish to avoid open handles
|
||||
await new Promise((resolve) => setTimeout(resolve, 60));
|
||||
expect(mcpStarted).toBe(true);
|
||||
});
|
||||
|
||||
describe('getCompressionThreshold', () => {
|
||||
it('should return the local compression threshold if it is set', async () => {
|
||||
const config = new Config({
|
||||
|
||||
@@ -796,12 +796,14 @@ export class Config {
|
||||
this,
|
||||
this.eventEmitter,
|
||||
);
|
||||
const initMcpHandle = startupProfiler.start('initialize_mcp_clients');
|
||||
await Promise.all([
|
||||
await this.mcpClientManager.startConfiguredMcpServers(),
|
||||
await this.getExtensionLoader().start(this),
|
||||
]);
|
||||
initMcpHandle?.end();
|
||||
// We do not await this promise so that the CLI can start up even if
|
||||
// MCP servers are slow to connect.
|
||||
Promise.all([
|
||||
this.mcpClientManager.startConfiguredMcpServers(),
|
||||
this.getExtensionLoader().start(this),
|
||||
]).catch((error) => {
|
||||
debugLogger.error('Error initializing MCP clients:', error);
|
||||
});
|
||||
|
||||
if (this.skillsSupport) {
|
||||
this.getSkillManager().setAdminSettings(this.adminSkillsEnabled);
|
||||
|
||||
Reference in New Issue
Block a user