Skip to main content
Glama

browser_drag_and_drop

Automate drag-and-drop interactions between web elements using Selenium WebDriver for browser automation and testing workflows.

Instructions

Perform drag and drop between two elements

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
byYesLocator strategy to find element
valueYesValue for the locator strategy
timeoutNoMaximum time to wait for element in milliseconds
targetByYesLocator strategy to find target element
targetValueYesValue for the target locator strategy

Implementation Reference

  • MCP tool handler that receives parameters and calls ActionService.dragAndDrop
    async ({ by, value, targetBy, targetValue, timeout = 15000 }) => {
      try {
        const driver = stateManager.getDriver();
        const actionService = new ActionService(driver);
        await actionService.dragAndDrop({ by, value, timeout }, { by: targetBy, value: targetValue, timeout });
        return {
          content: [{ type: 'text', text: 'Drag and drop completed' }],
        };
      } catch (e) {
        return {
          content: [
            {
              type: 'text',
              text: `Error performing drag and drop: ${(e as Error).message}`,
            },
          ],
        };
      }
    }
  • Input schema definition for the browser_drag_and_drop tool using Zod
    {
      ...locatorSchema,
      targetBy: z
        .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink'])
        .describe('Locator strategy to find target element'),
      targetValue: z.string().describe('Value for the target locator strategy'),
    },
  • Registration of the browser_drag_and_drop tool with McpServer
    server.tool(
      'browser_drag_and_drop',
      'Perform drag and drop between two elements',
      {
        ...locatorSchema,
        targetBy: z
          .enum(['id', 'css', 'xpath', 'name', 'tag', 'class', 'link', 'partialLink'])
          .describe('Locator strategy to find target element'),
        targetValue: z.string().describe('Value for the target locator strategy'),
      },
      async ({ by, value, targetBy, targetValue, timeout = 15000 }) => {
        try {
          const driver = stateManager.getDriver();
          const actionService = new ActionService(driver);
          await actionService.dragAndDrop({ by, value, timeout }, { by: targetBy, value: targetValue, timeout });
          return {
            content: [{ type: 'text', text: 'Drag and drop completed' }],
          };
        } catch (e) {
          return {
            content: [
              {
                type: 'text',
                text: `Error performing drag and drop: ${(e as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • Core implementation of drag and drop using Selenium WebDriver actions
    async dragAndDrop(sourceParams: LocatorParams, targetParams: LocatorParams): Promise<void> {
      const sourceLocator = LocatorFactory.createLocator(sourceParams.by, sourceParams.value);
      const targetLocator = LocatorFactory.createLocator(targetParams.by, targetParams.value);
    
      const sourceElement = await this.driver.wait(until.elementLocated(sourceLocator), sourceParams.timeout || 15000);
      const targetElement = await this.driver.wait(until.elementLocated(targetLocator), targetParams.timeout || 15000);
    
      const actions = this.driver.actions({ bridge: true });
      await actions.dragAndDrop(sourceElement, targetElement).perform();
    }
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It only states the action without any details on side effects (e.g., whether it triggers events, changes state), error conditions, performance implications, or what happens if elements aren't found. For a mutation tool with zero annotation coverage, this is a significant gap.

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 directly states the tool's function without unnecessary words. It's front-loaded and wastes no space, making it easy to parse quickly.

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-and-drop operation (a mutation with potential side effects), no annotations, and no output schema, the description is inadequate. It lacks information on behavioral traits, error handling, or result format, leaving the agent under-informed 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%, with all parameters well-documented in the schema itself (e.g., locator strategies, timeout). The description adds no additional parameter semantics beyond implying two elements are involved, which is already clear from the parameter names (by/value vs targetBy/targetValue). Baseline 3 is appropriate when the schema does the heavy lifting.

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 ('Perform drag and drop') and the target ('between two elements'), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like browser_click or browser_double_click in terms of interaction type, though the name itself suggests the distinction. The purpose is clear but lacks explicit sibling differentiation.

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. It doesn't mention prerequisites (e.g., elements must be visible), compare to other interaction methods, or specify scenarios where drag-and-drop is appropriate over other actions. This leaves the agent with minimal context for tool selection.

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/pshivapr/selenium-mcp'

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