Skip to main content
Glama
devskido

Playwright MCP Server

by devskido

playwright_drag

Drag web page elements to specified targets using CSS selectors for browser automation and testing.

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

  • DragTool class implements the core logic for 'playwright_drag' tool using Playwright mouse events to drag from source element to target element.
    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}`);
        });
      }
    }
  • Input schema definition for the 'playwright_drag' tool, specifying sourceSelector and targetSelector as required string parameters.
      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"],
      },
    },
  • Dispatch in handleToolCall switch statement routes 'playwright_drag' calls to dragTool.execute.
    case "playwright_drag":
      return await dragTool.execute(args, context);
  • Instantiation of DragTool instance during tool initialization.
    if (!dragTool) dragTool = new DragTool(server);
  • src/tools.ts:469-469 (registration)
    Inclusion of 'playwright_drag' in 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 full burden for behavioral disclosure. While 'drag' implies a UI interaction that modifies element position, the description doesn't specify whether this requires the page to be in a particular state, what happens if selectors don't match, whether it waits for animations, or what visual feedback occurs. For a mutation tool with zero annotation coverage, this leaves significant behavioral questions unanswered.

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, focused sentence that communicates the core functionality without any wasted words. It's front-loaded with the essential action and doesn't include unnecessary elaboration or repetition. Every word earns its place in conveying the tool's purpose efficiently.

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?

For a UI interaction tool with no annotations and no output schema, the description is insufficiently complete. It doesn't address what happens after the drag operation, whether there's visual feedback, error conditions, or what state the page should be in beforehand. Given that this is a mutation operation (dragging changes UI state) with zero structured metadata about behavior, the description should provide more contextual guidance about how and when to use it effectively.

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%, with both parameters clearly documented in the schema. The description doesn't add any additional semantic context about the parameters beyond what's already in the schema descriptions. It doesn't explain selector syntax expectations, provide examples, or clarify what constitutes a valid 'target location.' With complete schema coverage, the baseline score of 3 is appropriate.

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 resource ('an element to a target location'), making the purpose immediately understandable. It distinguishes itself from other playwright tools by focusing specifically on drag-and-drop functionality rather than clicking, filling, or navigating. However, it doesn't explicitly differentiate from potential similar drag operations that might exist in the sibling set.

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?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites (like needing a page to be loaded), comparison with similar playwright actions, or specific scenarios where dragging is appropriate versus other interaction methods. The agent must infer usage from context alone.

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/devskido/customed-playwright'

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