Skip to main content
Glama
Angeluis001

Playwright MCP

by Angeluis001

browser_click

Destructive

Click elements on web pages to automate browser interactions, supporting single or double clicks with modifier keys and specific mouse buttons.

Instructions

Perform click on a web page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementYesHuman-readable element description used to obtain permission to interact with the element
refYesExact target element reference from the page snapshot
doubleClickNoWhether to perform a double click instead of a single click
buttonNoButton to click, defaults to left
modifiersNoModifier keys to press

Implementation Reference

  • The handler function that executes the browser_click tool. It retrieves the locator from the current tab's snapshot using the provided params and performs the click action via Playwright, while also generating explanatory code and configuring post-action behavior.
    handle: async (context, params) => {
      const tab = context.currentTabOrDie();
      const locator = tab.snapshotOrDie().refLocator(params);
    
      const code = [
        `// Click ${params.element}`,
        `await page.${await generateLocator(locator)}.click();`
      ];
    
      return {
        code,
        action: () => locator.click(),
        captureSnapshot: true,
        waitForNetwork: true,
      };
    },
  • The schema definition for the browser_click tool, including name, title, description, input schema (elementSchema), and type.
    schema: {
      name: 'browser_click',
      title: 'Click',
      description: 'Perform click on a web page',
      inputSchema: elementSchema,
      type: 'destructive',
    },
  • The complete tool definition and registration using defineTool, which is then exported for inclusion in the tools registry.
    const click = defineTool({
      capability: 'core',
      schema: {
        name: 'browser_click',
        title: 'Click',
        description: 'Perform click on a web page',
        inputSchema: elementSchema,
        type: 'destructive',
      },
    
      handle: async (context, params) => {
        const tab = context.currentTabOrDie();
        const locator = tab.snapshotOrDie().refLocator(params);
    
        const code = [
          `// Click ${params.element}`,
          `await page.${await generateLocator(locator)}.click();`
        ];
    
        return {
          code,
          action: () => locator.click(),
          captureSnapshot: true,
          waitForNetwork: true,
        };
      },
    });
  • The Zod schema for the input parameters used by browser_click (and other tools), defining element description and ref.
    const elementSchema = z.object({
      element: z.string().describe('Human-readable element description used to obtain permission to interact with the element'),
      ref: z.string().describe('Exact target element reference from the page snapshot'),
    });
  • Exports the browser_click tool (as 'click') along with other snapshot-related tools for inclusion in the main tools array.
    export default [
      snapshot,
      click,
      drag,
      hover,
      type,
      selectOption,
    ];

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.0
    • addedInput schema / properties / modifiers
      Added value: +{
      +  "description": "Modifier keys to press",
      +  "items": {
      +    "enum": [
      +      "Alt",
      +      "Control",
      +      "ControlOrMeta",
      +      "Meta",
      +      "Shift"
      +    ],
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
  2. First observed

TDQS

B3.3/5.0
Behavior3/5

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

The description adds minimal behavioral context beyond annotations. Annotations already indicate destructiveHint=true (modifies page state) and readOnlyHint=false (not read-only), which aligns with 'perform click' implying interaction. However, the description doesn't elaborate on what 'perform click' entails (e.g., triggering events, navigation) or mention potential side effects like page changes, which would be valuable given the destructive nature. No contradiction with annotations exists.

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 extremely concise with a single sentence ('Perform click on a web page'), which is front-loaded and wastes no words. Every part of the sentence directly contributes to understanding the tool's purpose without redundancy or unnecessary elaboration.

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?

Given the tool's complexity (destructive interaction with 5 parameters) and lack of output schema, the description is minimally adequate. Annotations cover safety aspects (destructive, not read-only), but the description doesn't address return values or error conditions. For a tool that modifies page state, more context on outcomes would be beneficial, though annotations provide some baseline.

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 parameters are fully documented in the schema. The description adds no additional meaning about parameters beyond the schema's details (e.g., element and ref requirements, button options). It doesn't explain why both element and ref are needed or how they interact, leaving the schema to carry the full burden.

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 click') and resource ('on a web page'), making the purpose immediately understandable. It distinguishes itself from siblings like browser_hover, browser_press_key, and browser_drag by specifying clicking rather than hovering, typing, or dragging. However, it doesn't explicitly differentiate from all siblings (e.g., browser_select_option might also involve clicking).

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 when to choose click over other interaction methods like browser_type or browser_press_key, nor does it specify prerequisites (e.g., needing a page snapshot first). The context is implied but not explicitly stated.

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