mouseMove
Move the mouse cursor to precise screen coordinates (x, y) for precise browser automation tasks. Part of the PlayMCP Browser Automation Server for accurate web interaction.
Instructions
Move mouse to specific coordinates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | ||
| y | Yes |
Implementation Reference
- src/controllers/playwright.ts:854-867 (handler)The core handler function that executes the mouse movement logic using Playwright's page.mouse.move API.async mouseMove(x: number, y: number): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Moving mouse', { x, y }); await this.state.page.mouse.move(x, y); this.currentMousePosition = { x, y }; this.log('Mouse move complete'); } catch (error: any) { console.error('Mouse move error:', error); throw new BrowserError('Failed to move mouse', 'Check if coordinates are valid'); } }
- src/server.ts:463-474 (schema)Defines the tool's metadata, including input schema for parameters x and y (numbers).const MOUSE_MOVE_TOOL: Tool = { name: "mouseMove", description: "Move mouse to specific coordinates", inputSchema: { type: "object", properties: { x: { type: "number" }, y: { type: "number" } }, required: ["x", "y"] } };
- src/server.ts:549-549 (registration)Registers the mouseMove tool in the tools object, which is provided to the MCP server's capabilities.mouseMove: MOUSE_MOVE_TOOL,
- src/server.ts:958-969 (handler)MCP callTool request handler case that performs input validation and delegates execution to the Playwright controller.case 'mouseMove': { if (typeof args.x !== 'number' || typeof args.y !== 'number') { return { content: [{ type: "text", text: "X and Y coordinates are required" }], isError: true }; } await playwrightController.mouseMove(args.x, args.y); return { content: [{ type: "text", text: "Mouse moved successfully" }] }; }