Skip to main content
Glama
AdsPower

AdsPower LocalAPI MCP Server

Official

drag-element

Simulate dragging a specified webpage element to a target location using element selectors. Part of AdsPower LocalAPI MCP Server, enabling precise browser interaction for automation.

Instructions

Drag the element

Input Schema

NameRequiredDescriptionDefault
selectorYesThe selector of the element to drag, find from the page source code
targetSelectorYesThe selector of the element to drag to, find from the page source code

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "selector": { "description": "The selector of the element to drag, find from the page source code", "type": "string" }, "targetSelector": { "description": "The selector of the element to drag to, find from the page source code", "type": "string" } }, "required": [ "selector", "targetSelector" ], "type": "object" }

Implementation Reference

  • The main handler function for the 'drag-element' tool. It performs a drag operation by moving the mouse to the center of the source element, pressing down, moving to the target element's center, and releasing.
    async dragElement({ selector, targetSelector }: DragElementParams) { browser.checkConnected(); const sourceElement = await browser.pageInstance!.waitForSelector(selector); const targetElement = await browser.pageInstance!.waitForSelector(targetSelector); const sourceBound = await sourceElement.boundingBox(); const targetBound = await targetElement.boundingBox(); if (!sourceBound || !targetBound) { return `Could not get element positions for drag operation`; } await browser.pageInstance!.mouse.move( sourceBound.x + sourceBound.width / 2, sourceBound.y + sourceBound.height / 2 ); await browser.pageInstance!.mouse.down(); await browser.pageInstance!.mouse.move( targetBound.x + targetBound.width / 2, targetBound.y + targetBound.height / 2 ); await browser.pageInstance!.mouse.up(); return `Dragged element with selector: ${selector} to ${targetSelector} successfully`; }
  • Zod schema defining input parameters for 'drag-element': selector (source element) and targetSelector (destination element).
    dragElementSchema: z.object({ selector: z.string().describe('The selector of the element to drag, find from the page source code'), targetSelector: z.string().describe('The selector of the element to drag to, find from the page source code'), }).strict(),
  • Registers the 'drag-element' tool with the MCP server using the defined schema and wrapped handler from automationHandlers.
    server.tool('drag-element', 'Drag the element', schemas.dragElementSchema.shape, wrapHandler(automationHandlers.dragElement));

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/AdsPower/local-api-mcp-typescript'

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