browser_click
Click web page elements during browser automation. Specify target elements, choose single or double click, select mouse buttons, and add modifier keys for precise interaction control.
Instructions
Perform click on a web page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| element | Yes | Human-readable element description used to obtain permission to interact with the element | |
| ref | Yes | Exact target element reference from the page snapshot | |
| doubleClick | No | Whether to perform a double click instead of a single click | |
| button | No | Button to click, defaults to left | |
| modifiers | No | Modifier keys to press |
Implementation Reference
- src/tools/snapshot.ts:59-75 (handler)Handler function that performs the click action: resolves locator from current tab's snapshot using params (element ref), generates Playwright click code snippet, defines action to execute locator.click(), and configures snapshot/network wait.handle: async (context, params) => { const tab = context.currentTabOrDie(); const locator = tab.snapshotOrDie().refLocator(params); const code = [ `// Click ${params.element}`, `await page.${await generateLocator(locator)}.click();` ]; return { code, action: () => locator.click(), captureSnapshot: true, waitForNetwork: true, }; }, });
- src/tools/snapshot.ts:44-57 (schema)Zod schemas defining input for browser_click: shared elementSchema (element description and ref from snapshot), referenced in tool schema with name, title, description, and destructive type.const elementSchema = z.object({ element: z.string().describe('Human-readable element description used to obtain permission to interact with the element'), ref: z.string().describe('Exact target element reference from the page snapshot'), }); const click = defineTool({ capability: 'core', schema: { name: 'browser_click', title: 'Click', description: 'Perform click on a web page', inputSchema: elementSchema, type: 'destructive', },
- src/tools.ts:36-52 (registration)Registers browser_click by spreading the snapshot module (which exports browser_click among others) into the snapshotTools array, used for MCP toolset.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...video, ...wait(true), ];
- src/connection.ts:29-33 (registration)Final MCP registration: selects snapshotTools (including browser_click) into filtered tools list based on config, initializes Context and McpServer with tools for handling ListTools and CallTool requests.export function createConnection(config: FullConfig, browserContextFactory: BrowserContextFactory): Connection { const allTools = config.vision ? visionTools : snapshotTools; const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability)); validateConfig(config); const context = new Context(tools, config, browserContextFactory);