Skip to main content
Glama

browser.drag_drop

Automate drag-and-drop interactions in web browsers by specifying source and target elements or coordinates for testing and automation workflows.

Instructions

Drag from one element or coordinate to another. Provide source_selector OR (source_x, source_y), and target_selector OR (target_x, target_y).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
source_selectorNo
source_xNo
source_yNo
target_selectorNo
target_xNo
target_yNo

Implementation Reference

  • The handler implementation for browser.drag_drop in the MCP tool gateway.
    async def _drag_drop(self, payload: DragDropInput) -> dict[str, Any]:
        session = await self.manager.get_session(payload.session_id)
    
        # Resolve source coordinates
        if payload.source_selector:
            box = await session.page.locator(payload.source_selector).first.bounding_box()
            sx = box["x"] + box["width"] / 2 if box else 0
            sy = box["y"] + box["height"] / 2 if box else 0
        elif payload.source_x is not None and payload.source_y is not None:
            sx, sy = payload.source_x, payload.source_y
        else:
            raise ValueError("Provide source_selector or source_x/source_y")
    
        # Resolve target coordinates
        if payload.target_selector:
            box = await session.page.locator(payload.target_selector).first.bounding_box()
            tx = box["x"] + box["width"] / 2 if box else 0
            ty = box["y"] + box["height"] / 2 if box else 0
        elif payload.target_x is not None and payload.target_y is not None:
            tx, ty = payload.target_x, payload.target_y
        else:
            raise ValueError("Provide target_selector or target_x/target_y")
    
        await session.page.mouse.move(sx, sy)
        await session.page.mouse.down()
        await session.page.mouse.move(tx, ty, steps=10)
        await session.page.mouse.up()
        return {"session_id": payload.session_id, "from": {"x": sx, "y": sy}, "to": {"x": tx, "y": ty}}
  • Input model schema for browser.drag_drop tool.
    class DragDropInput(SessionIdInput):
        source_selector: str | None = Field(default=None, max_length=2000)
        source_x: float | None = None
        source_y: float | None = None
        target_selector: str | None = Field(default=None, max_length=2000)
        target_x: float | None = None
        target_y: float | None = None
  • Registration of the browser.drag_drop tool within McpToolGateway.
        name="browser.drag_drop",
        description=(
            "Drag from one element or coordinate to another. "
            "Provide source_selector OR (source_x, source_y), "
            "and target_selector OR (target_x, target_y)."
        ),
        input_model=DragDropInput,
        handler=self._drag_drop,
    ),
Behavior2/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 fails to mention error conditions (what happens if elements aren't found), side effects (JavaScript events triggered), return values, or whether the operation waits for elements to be ready. Significant gaps remain.

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

Conciseness5/5

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

The description consists of exactly two high-information sentences with no redundancy. The first sentence establishes purpose; the second immediately clarifies the parameter logic. Efficiently front-loaded.

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

Completeness3/5

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

For a 7-parameter interaction tool with conditional parameter logic and no output schema, the description covers the basic operation and parameter relationships but remains incomplete regarding behavioral edge cases, coordinate system details, and failure modes.

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

Parameters4/5

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

Given 0% schema description coverage, the description provides essential semantic information by explaining the XOR relationship between selector and coordinate parameters for both source and target. This compensates significantly for the schema's lack of field descriptions.

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

Purpose4/5

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

The description clearly identifies the action (drag) and targets (element or coordinate), providing specific verbs and resources. However, it does not explicitly differentiate this tool from siblings like 'browser.execute_action' that might handle complex interactions.

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

Usage Guidelines3/5

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

The description provides clear parameter constraints ('source_selector OR (source_x, source_y)'), guiding correct invocation syntax. However, it lacks guidance on when to use drag-drop versus alternative interaction methods or what prerequisites (e.g., visible elements) are required.

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/LvcidPsyche/auto-browser'

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