mouseClick
Simulate mouse clicks at precise screen coordinates to automate browser interactions for web testing and scraping tasks.
Instructions
Click at specific coordinates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | ||
| y | Yes |
Implementation Reference
- src/controllers/playwright.ts:869-882 (handler)The main handler function in PlaywrightController that executes the mouse click at the given (x, y) coordinates using the Playwright mouse API.async mouseClick(x: number, y: number): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Clicking at coordinates', { x, y }); await this.state.page.mouse.click(x, y); this.currentMousePosition = { x, y }; this.log('Mouse click complete'); } catch (error: any) { console.error('Mouse click error:', error); throw new BrowserError('Failed to click at coordinates', 'Check if coordinates are valid'); } }
- src/server.ts:476-487 (schema)JSON Schema definition for the mouseClick tool, specifying required numeric x and y coordinates as input.const MOUSE_CLICK_TOOL: Tool = { name: "mouseClick", description: "Click at specific coordinates", inputSchema: { type: "object", properties: { x: { type: "number" }, y: { type: "number" } }, required: ["x", "y"] } };
- src/server.ts:971-982 (registration)Registration in the MCP callTool request handler switch statement, which validates input and invokes the Playwright controller's mouseClick method.case 'mouseClick': { if (typeof args.x !== 'number' || typeof args.y !== 'number') { return { content: [{ type: "text", text: "X and Y coordinates are required" }], isError: true }; } await playwrightController.mouseClick(args.x, args.y); return { content: [{ type: "text", text: "Mouse clicked successfully" }] }; }
- src/server.ts:550-550 (registration)Tool registration entry in the 'tools' dictionary passed to MCP Server capabilities for listTools and callTool discovery.mouseClick: MOUSE_CLICK_TOOL,