browser_click
Simulate single or double clicks on specific web elements using Playwright MCP. Specify target elements and buttons for precise browser interactions.
Instructions
Perform click on a web page
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| button | No | Button to click, defaults to left | |
| doubleClick | No | Whether to perform a double click instead of a single click | |
| 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 |
Implementation Reference
- src/tools/snapshot.ts:59-74 (handler)Handler function that performs the click action on the element locator from page snapshot, generates equivalent Playwright code, and returns execution metadata.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:51-57 (schema)MCP tool schema for 'browser_click' defining name, title, description, input schema (elementSchema), and destructive type.schema: { name: 'browser_click', title: 'Click', description: 'Perform click on a web page', inputSchema: elementSchema, type: 'destructive', },
- src/tools/snapshot.ts:45-47 (schema)Zod input schema for browser_click: requires 'element' (human-readable desc) and 'ref' (snapshot reference).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'), });
- src/tools.ts:36-52 (registration)Registers 'browser_click' tool by spreading the snapshot module export (which includes browser_click) into the snapshotTools array for use in MCP context.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/tools/snapshot.ts:219-226 (registration)Includes 'browser_click' (as 'click') in the module's default export array for registration in parent tools.ts.export default [ snapshot, click, drag, hover, type, selectOption, ];