mouseDrag
Simulate mouse drag actions by specifying start and end coordinates for precise browser automation tasks using PlayMCP Server.
Instructions
Drag from one coordinate to another
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endX | Yes | ||
| endY | Yes | ||
| startX | Yes | ||
| startY | Yes |
Implementation Reference
- src/controllers/playwright.ts:884-900 (handler)The core handler function that executes the mouse drag operation using Playwright's mouse API: move to start, mouse down, move to end, mouse up.async mouseDrag(startX: number, startY: number, endX: number, endY: number): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Mouse drag', { startX, startY, endX, endY }); await this.state.page.mouse.move(startX, startY); await this.state.page.mouse.down(); await this.state.page.mouse.move(endX, endY); await this.state.page.mouse.up(); this.currentMousePosition = { x: endX, y: endY }; this.log('Mouse drag complete'); } catch (error: any) { console.error('Mouse drag error:', error); throw new BrowserError('Failed to drag mouse', 'Check if coordinates are valid'); } }
- src/server.ts:984-996 (registration)The switch case in callTool handler that validates arguments and invokes the controller's mouseDrag method.case 'mouseDrag': { if (typeof args.startX !== 'number' || typeof args.startY !== 'number' || typeof args.endX !== 'number' || typeof args.endY !== 'number') { return { content: [{ type: "text", text: "Start and end coordinates are required" }], isError: true }; } await playwrightController.mouseDrag(args.startX, args.startY, args.endX, args.endY); return { content: [{ type: "text", text: "Mouse drag completed successfully" }] }; }
- src/server.ts:489-502 (schema)Tool metadata and input schema definition for mouseDrag, specifying required numeric coordinates.const MOUSE_DRAG_TOOL: Tool = { name: "mouseDrag", description: "Drag from one coordinate to another", inputSchema: { type: "object", properties: { startX: { type: "number" }, startY: { type: "number" }, endX: { type: "number" }, endY: { type: "number" } }, required: ["startX", "startY", "endX", "endY"] } };
- src/server.ts:551-551 (registration)Registers the mouseDrag tool in the tools object provided to MCP server capabilities.mouseDrag: MOUSE_DRAG_TOOL,