mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 11:04:42 -07:00
fix(core): reduce intrusive MCP errors and deduplicate diagnostics (#20232)
This commit is contained in:
@@ -367,6 +367,7 @@ import {
|
||||
SimpleExtensionLoader,
|
||||
} from '../utils/extensionLoader.js';
|
||||
import { McpClientManager } from '../tools/mcp-client-manager.js';
|
||||
import { type McpContext } from '../tools/mcp-client.js';
|
||||
import type { EnvironmentSanitizationConfig } from '../services/environmentSanitization.js';
|
||||
import { getErrorMessage } from '../utils/errors.js';
|
||||
import {
|
||||
@@ -580,7 +581,7 @@ export interface ConfigParameters {
|
||||
};
|
||||
}
|
||||
|
||||
export class Config {
|
||||
export class Config implements McpContext {
|
||||
private toolRegistry!: ToolRegistry;
|
||||
private mcpClientManager?: McpClientManager;
|
||||
private allowedMcpServers: string[];
|
||||
@@ -1769,6 +1770,33 @@ export class Config {
|
||||
return this.mcpClientManager;
|
||||
}
|
||||
|
||||
setUserInteractedWithMcp(): void {
|
||||
this.mcpClientManager?.setUserInteractedWithMcp();
|
||||
}
|
||||
|
||||
/** @deprecated Use getMcpClientManager().getLastError() directly */
|
||||
getLastMcpError(serverName: string): string | undefined {
|
||||
return this.mcpClientManager?.getLastError(serverName);
|
||||
}
|
||||
|
||||
emitMcpDiagnostic(
|
||||
severity: 'info' | 'warning' | 'error',
|
||||
message: string,
|
||||
error?: unknown,
|
||||
serverName?: string,
|
||||
): void {
|
||||
if (this.mcpClientManager) {
|
||||
this.mcpClientManager.emitDiagnostic(
|
||||
severity,
|
||||
message,
|
||||
error,
|
||||
serverName,
|
||||
);
|
||||
} else {
|
||||
coreEvents.emitFeedback(severity, message, error);
|
||||
}
|
||||
}
|
||||
|
||||
getAllowedMcpServers(): string[] | undefined {
|
||||
return this.allowedMcpServers;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user