/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type { Config, MCPServerConfig } from '../config/config.js'; import type { ToolRegistry } from './tool-registry.js'; import { MCPDiscoveryState } from './mcp-client.js'; import type { EventEmitter } from 'node:events'; /** * Manages the lifecycle of multiple MCP clients, including local child processes. * This class is responsible for starting, stopping, and discovering tools from * a collection of MCP servers defined in the configuration. */ export declare class McpClientManager { private clients; private readonly toolRegistry; private readonly cliConfig; private discoveryPromise; private discoveryState; private readonly eventEmitter?; constructor(toolRegistry: ToolRegistry, cliConfig: Config, eventEmitter?: EventEmitter); /** * For all the MCP servers associated with this extension: * * - Removes all its MCP servers from the global configuration object. * - Disconnects all MCP clients from their servers. * - Updates the Gemini chat configuration to load the new tools. */ private unloadExtension; /** * For all the MCP servers associated with this extension: * * - Adds all its MCP servers to the global configuration object. * - Connects MCP clients to each server and discovers their tools. * - Updates the Gemini chat configuration to load the new tools. */ private loadExtension; private disconnectClient; discoverMcpTools(name: string, config: MCPServerConfig): Promise | void; /** * Initiates the tool discovery process for all configured MCP servers. * It connects to each server, discovers its available tools, and registers * them with the `ToolRegistry`. */ discoverAllMcpTools(): Promise; /** * Stops all running local MCP servers and closes all client connections. * This is the cleanup method to be called on application exit. */ stop(): Promise; getDiscoveryState(): MCPDiscoveryState; }