Skip to main content
Glama
AdsPower

AdsPower LocalAPI MCP Server

Official

drag-element

Drag a web element from one location to another using CSS selectors to automate browser interactions through the AdsPower LocalAPI MCP Server.

Instructions

Drag the element

Input Schema

TableJSON 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

Implementation Reference

  • The main handler function for the 'drag-element' tool. It uses Playwright to locate source and target elements by selectors, computes their bounding boxes, and simulates a mouse drag from source to target.
    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 the drag-element tool: selector for the element to drag and targetSelector for the drop target.
    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(),
  • Tool registration call that associates the name 'drag-element' with its description, schema, and wrapped handler function.
    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