feat(browser): add sensitive action controls and read-only noise reduction (#22867)

This commit is contained in:
cynthialong0-0
2026-03-20 15:34:04 -07:00
committed by GitHub
parent 11ec4ac2f8
commit e8fe43bd69
11 changed files with 342 additions and 1 deletions
@@ -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,
);
});