improved mcp support, including standard "mcpServers" setting with multiple named servers with command/args/env/cwd (#392)

This commit is contained in:
Olcan
2025-05-16 16:29:03 -07:00
committed by GitHub
parent e158a0d59f
commit d9bd2b0e14
5 changed files with 77 additions and 42 deletions

View File

@@ -20,6 +20,7 @@ import { WriteFileTool } from '../tools/write-file.js';
import { WebFetchTool } from '../tools/web-fetch.js';
import { ReadManyFilesTool } from '../tools/read-many-files.js';
import { BaseTool, ToolResult } from '../tools/tools.js';
import { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
export class Config {
private toolRegistry: ToolRegistry;
@@ -35,6 +36,9 @@ export class Config {
private readonly toolDiscoveryCommand: string | undefined,
private readonly toolCallCommand: string | undefined,
private readonly mcpServerCommand: string | undefined,
private readonly mcpServers:
| Record<string, StdioServerParameters>
| undefined,
private readonly userAgent: string,
private userMemory: string = '', // Made mutable for refresh
private geminiMdFileCount: number = 0,
@@ -86,6 +90,10 @@ export class Config {
return this.mcpServerCommand;
}
getMcpServers(): Record<string, StdioServerParameters> | undefined {
return this.mcpServers;
}
getUserAgent(): string {
return this.userAgent;
}
@@ -146,6 +154,7 @@ export function createServerConfig(
toolDiscoveryCommand?: string,
toolCallCommand?: string,
mcpServerCommand?: string,
mcpServers?: Record<string, StdioServerParameters>,
userAgent?: string,
userMemory?: string,
geminiMdFileCount?: number,
@@ -161,6 +170,7 @@ export function createServerConfig(
toolDiscoveryCommand,
toolCallCommand,
mcpServerCommand,
mcpServers,
userAgent ?? 'GeminiCLI/unknown', // Default user agent
userMemory ?? '',
geminiMdFileCount ?? 0,