mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-19 02:20:42 -07:00
improved mcp support, including standard "mcpServers" setting with multiple named servers with command/args/env/cwd (#392)
This commit is contained in:
@@ -59,6 +59,7 @@ describe('Server Config (config.ts)', () => {
|
||||
undefined, // toolDiscoveryCommand
|
||||
undefined, // toolCallCommand
|
||||
undefined, // mcpServerCommand
|
||||
undefined, // mcpServers
|
||||
USER_AGENT,
|
||||
USER_MEMORY, // Pass memory here
|
||||
);
|
||||
@@ -83,6 +84,7 @@ describe('Server Config (config.ts)', () => {
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
USER_AGENT,
|
||||
// No userMemory argument
|
||||
);
|
||||
@@ -102,6 +104,7 @@ describe('Server Config (config.ts)', () => {
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
USER_AGENT,
|
||||
USER_MEMORY, // Pass memory here
|
||||
);
|
||||
@@ -125,6 +128,7 @@ describe('Server Config (config.ts)', () => {
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
USER_AGENT,
|
||||
// No userMemory argument
|
||||
);
|
||||
@@ -147,6 +151,7 @@ describe('Server Config (config.ts)', () => {
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
USER_AGENT,
|
||||
USER_MEMORY,
|
||||
);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user