Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

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
NameRequiredDescriptionDefault
endXYes
endYYes
startXYes
startYYes

Implementation Reference

  • 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" }] }; }
  • 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,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jomon003/PlayMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server