Skip to main content
Glama
pvinis
by pvinis

playwright_drag

Use this tool to drag and drop web elements to a target location using CSS selectors for precise interaction within a browser environment.

Instructions

Drag an element to a target location

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceSelectorYesCSS selector for the element to drag
targetSelectorYesCSS selector for the target location

Implementation Reference

  • The DragTool class and its execute method implement the core logic for the 'playwright_drag' tool, using Playwright to locate elements by selectors, get their bounding boxes, and perform a mouse drag operation from source to target.
    export class DragTool extends BrowserToolBase {
      /**
       * Execute the drag tool
       */
      async execute(args: any, context: ToolContext): Promise<ToolResponse> {
        return this.safeExecute(context, async (page) => {
          const sourceElement = await page.waitForSelector(args.sourceSelector);
          const targetElement = await page.waitForSelector(args.targetSelector);
          
          const sourceBound = await sourceElement.boundingBox();
          const targetBound = await targetElement.boundingBox();
          
          if (!sourceBound || !targetBound) {
            return createErrorResponse("Could not get element positions for drag operation");
          }
    
          await page.mouse.move(
            sourceBound.x + sourceBound.width / 2,
            sourceBound.y + sourceBound.height / 2
          );
          await page.mouse.down();
          await page.mouse.move(
            targetBound.x + targetBound.width / 2,
            targetBound.y + targetBound.height / 2
          );
          await page.mouse.up();
          
          return createSuccessResponse(`Dragged element from ${args.sourceSelector} to ${args.targetSelector}`);
        });
      }
    }
  • The tool definition object including name, description, and input schema for 'playwright_drag'.
    {
      name: "playwright_drag",
      description: "Drag an element to a target location",
      inputSchema: {
        type: "object",
        properties: {
          sourceSelector: { type: "string", description: "CSS selector for the element to drag" },
          targetSelector: { type: "string", description: "CSS selector for the target location" }
        },
        required: ["sourceSelector", "targetSelector"],
      },
    },
  • Switch case in handleToolCall that registers and dispatches the 'playwright_drag' tool call to dragTool.execute.
    case "playwright_drag":
      return await dragTool.execute(args, context);
  • Instantiation of the DragTool instance during tool initialization.
    if (!dragTool) dragTool = new DragTool(server);
  • src/tools.ts:422-422 (registration)
    Inclusion of 'playwright_drag' in the BROWSER_TOOLS array for conditional browser launching.
    "playwright_drag",
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but lacks details on what happens during the drag (e.g., mouse events, timing, error handling), whether it waits for animations, or what the expected outcome is. This is a significant gap for a mutation tool with zero annotation coverage.

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 is a single, efficient sentence that front-loads the core action without unnecessary words. Every part earns its place by directly stating the tool's function, making it highly concise and well-structured.

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

Completeness2/5

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

Given the complexity of a drag operation (a mutation with potential side effects), no annotations, and no output schema, the description is incomplete. It doesn't cover behavioral aspects like success/failure states, visual feedback, or error conditions, which are crucial for an AI agent to use it correctly.

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?

The description doesn't add meaning beyond the input schema, which has 100% coverage with clear descriptions for both parameters. The baseline is 3 since the schema does the heavy lifting, but the description doesn't compensate with extra context like selector best practices or interaction details.

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 states the action ('drag') and the resource ('an element to a target location'), making the purpose immediately understandable. It distinguishes from siblings like playwright_click or playwright_hover by specifying the drag interaction, though it doesn't explicitly contrast with other movement-related tools.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing a page loaded), exclusions, or comparisons to similar tools like playwright_click for simpler interactions, leaving usage context unclear.

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

Related 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/pvinis/mcp-playwright-stealth'

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