Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

mouseDrag

Simulate mouse drag actions in browser automation by specifying start and end coordinates for precise control during web scraping and testing.

Instructions

Drag from one coordinate to another

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startXYes
startYYes
endXYes
endYYes

Implementation Reference

  • The core implementation of the mouseDrag tool in the PlaywrightController class. It moves the mouse to start position, presses down, moves to end position, and releases.
    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'); } }
  • The input schema and metadata for the mouseDrag tool, defining required numeric parameters for drag 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:984-996 (registration)
    The dispatch case in the MCP callTool request handler that validates inputs and invokes the mouseDrag handler.
    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:551-551 (registration)
    Registration of the mouseDrag tool in the tools capabilities object passed to the MCP Server.
    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