Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

dragAndDrop

Move elements between locations in web interfaces by specifying source and target selectors for automated browser interactions.

Instructions

Drag and drop from one element to another

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceSelectorYes
targetSelectorYes

Implementation Reference

  • The core implementation of the dragAndDrop tool, using Playwright locators to drag from sourceSelector to targetSelector.
    async dragAndDrop(sourceSelector: string, targetSelector: string): Promise<void> { try { if (!this.isInitialized() || !this.state.page) { throw new Error('Browser not initialized'); } this.log('Performing drag and drop', { sourceSelector, targetSelector }); const sourceLocator = this.state.page.locator(sourceSelector); const targetLocator = this.state.page.locator(targetSelector); await sourceLocator.dragTo(targetLocator); this.log('Drag and drop complete'); } catch (error: any) { console.error('Drag and drop error:', error); throw new BrowserError('Failed to drag and drop', 'Check if both selectors exist and are interactable'); } }
  • The input schema and metadata definition for the dragAndDrop tool.
    const DRAG_AND_DROP_TOOL: Tool = { name: "dragAndDrop", description: "Drag and drop from one element to another", inputSchema: { type: "object", properties: { sourceSelector: { type: "string" }, targetSelector: { type: "string" } }, required: ["sourceSelector", "targetSelector"] } };
  • src/server.ts:537-537 (registration)
    Registration of the dragAndDrop tool in the tools dictionary provided to the MCP server.
    dragAndDrop: DRAG_AND_DROP_TOOL,
  • The dispatch logic in the MCP callTool handler that validates parameters and invokes the controller's dragAndDrop method.
    case 'dragAndDrop': { if (!args.sourceSelector || !args.targetSelector) { return { content: [{ type: "text", text: "Source and target selectors are required" }], isError: true }; } await playwrightController.dragAndDrop(args.sourceSelector as string, args.targetSelector as string); return { content: [{ type: "text", text: "Drag and drop completed successfully" }] }; }

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