click
Simulate user clicks on web page elements for browser automation and testing. Specify an element's unique identifier to perform single or double-click actions in Chrome.
Instructions
Clicks on the provided element
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | The uid of an element on the page from the page content snapshot | |
| dblClick | No | Set to true for double clicks. Default is false. |
Implementation Reference
- src/tools/input.ts:33-51 (handler)Handler function for the 'click' tool that retrieves the element by UID, performs the click (or double-click) using Puppeteer's locator.click(), waits for events, updates response, and disposes the handle.handler: async (request, response, context) => { const uid = request.params.uid; const handle = await context.getElementByUid(uid); try { await context.waitForEventsAfterAction(async () => { await handle.asLocator().click({ count: request.params.dblClick ? 2 : 1, }); }); response.appendResponseLine( request.params.dblClick ? `Successfully double clicked on the element` : `Successfully clicked on the element`, ); response.setIncludeSnapshot(true); } finally { void handle.dispose(); } },
- src/tools/input.ts:22-32 (schema)Input schema for the 'click' tool using Zod: required 'uid' string and optional 'dblClick' boolean.schema: { uid: z .string() .describe( 'The uid of an element on the page from the page content snapshot', ), dblClick: z .boolean() .optional() .describe('Set to true for double clicks. Default is false.'), },
- src/main.ts:307-320 (registration)Registration of all tools including 'click' from inputTools: tools from input.ts are spread into the tools array via Object.values(inputTools) and each tool is registered with the MCP server using registerTool, which wraps the handler.const tools = [ ...Object.values(consoleTools), ...Object.values(emulationTools), ...Object.values(inputTools), ...Object.values(networkTools), ...Object.values(pagesTools), ...Object.values(performanceTools), ...Object.values(screenshotTools), ...Object.values(scriptTools), ...Object.values(snapshotTools), ]; for (const tool of tools) { registerTool(tool as unknown as ToolDefinition); }
- src/main.ts:32-32 (registration)Import of input tools module which exports the 'click' tool definition.import * as inputTools from './tools/input.js';