mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
feat(browser): add sensitive action controls and read-only noise reduction (#22867)
This commit is contained in:
@@ -63,6 +63,7 @@ class McpToolInvocation extends BaseToolInvocation<
|
||||
params: Record<string, unknown>,
|
||||
messageBus: MessageBus,
|
||||
private readonly shouldDisableInput: boolean,
|
||||
private readonly blockFileUploads: boolean = false,
|
||||
) {
|
||||
super(
|
||||
params,
|
||||
@@ -114,6 +115,16 @@ class McpToolInvocation extends BaseToolInvocation<
|
||||
|
||||
async execute(signal: AbortSignal): Promise<ToolResult> {
|
||||
try {
|
||||
// Hard block for file uploads if configured
|
||||
if (this.blockFileUploads && this.toolName === 'upload_file') {
|
||||
const errorMsg = 'File uploads are blocked by configuration.';
|
||||
return {
|
||||
llmContent: `Error: ${errorMsg}`,
|
||||
returnDisplay: `Error: ${errorMsg}`,
|
||||
error: { message: errorMsg },
|
||||
};
|
||||
}
|
||||
|
||||
// Suspend the input blocker for interactive tools so
|
||||
// chrome-devtools-mcp's interactability checks pass.
|
||||
// Only toggles pointer-events CSS — no DOM change, no flicker.
|
||||
@@ -197,6 +208,7 @@ class McpDeclarativeTool extends DeclarativeTool<
|
||||
parameterSchema: unknown,
|
||||
messageBus: MessageBus,
|
||||
private readonly shouldDisableInput: boolean,
|
||||
private readonly blockFileUploads: boolean = false,
|
||||
) {
|
||||
super(
|
||||
name,
|
||||
@@ -227,6 +239,7 @@ class McpDeclarativeTool extends DeclarativeTool<
|
||||
params,
|
||||
this.messageBus,
|
||||
this.shouldDisableInput,
|
||||
this.blockFileUploads,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -249,6 +262,7 @@ export async function createMcpDeclarativeTools(
|
||||
browserManager: BrowserManager,
|
||||
messageBus: MessageBus,
|
||||
shouldDisableInput: boolean = false,
|
||||
blockFileUploads: boolean = false,
|
||||
): Promise<McpDeclarativeTool[]> {
|
||||
// Get dynamically discovered tools from the MCP server
|
||||
const mcpTools = await browserManager.getDiscoveredTools();
|
||||
@@ -272,6 +286,7 @@ export async function createMcpDeclarativeTools(
|
||||
schema.parametersJsonSchema,
|
||||
messageBus,
|
||||
shouldDisableInput,
|
||||
blockFileUploads,
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user