mouseClick
Automate precise mouse clicks at designated screen coordinates using PlayMCP Browser Automation Server. Ideal for web testing, scraping, and interaction 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)Core implementation of the mouseClick tool: performs validation, logs the action, executes page.mouse.click(x, y), updates mouse position, and handles errors.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:971-982 (handler)Tool dispatch handler in callTool: validates input arguments and delegates to playwrightController.mouseClick.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:476-487 (schema)Defines the tool metadata including name, description, and input schema requiring x and y numbers.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:550-563 (registration)Registers the mouseClick tool in the tools object and passes it to the MCP Server capabilities.mouseClick: MOUSE_CLICK_TOOL, mouseDrag: MOUSE_DRAG_TOOL, closeBrowser: CLOSE_BROWSER_TOOL }; const server = new Server( { name: "playmcp-browser", version: "1.0.0", }, { capabilities: { tools, },