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));
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure but offers none. It doesn't mention whether this is a read or write operation, what visual feedback occurs, whether it requires specific browser states, potential side effects, or error conditions. The description provides no behavioral context beyond the basic action name.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While technically concise with just three words, this is under-specification rather than effective conciseness. The description doesn't front-load important information and fails to use its limited space to provide any meaningful guidance. Every word should earn its place, but this description provides almost no value beyond the tool name itself.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is completely inadequate. It doesn't explain what 'drag' means in this context, what visual or state changes occur, whether this simulates user interaction or programmatically moves elements, or what happens if selectors are invalid. The description fails to provide the minimal context needed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description adds no additional meaning about what 'selector' and 'targetSelector' represent beyond what's in the schema descriptions. This meets the baseline of 3 when the schema does the heavy lifting, but the description doesn't compensate with any extra context about selector syntax or drag behavior.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Drag the element' is a tautology that essentially restates the tool name 'drag-element' without adding meaningful context. While it does specify the action (drag), it doesn't clarify what resource is being manipulated or distinguish this tool from sibling tools like 'hover-element' or 'click-element' beyond the basic verb difference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There are no indications about prerequisites (e.g., needing an open browser), appropriate contexts, or comparisons to similar sibling tools like 'hover-element' or 'click-element' that might be used for different interaction types.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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