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,
    ];
Behavior4/5

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

Annotations indicate destructiveHint=true and readOnlyHint=false, which the description aligns with by implying a mutating action ('Perform click'). The description adds minimal behavioral context beyond annotations, but doesn't contradict them. It lacks details on error handling or side effects, but annotations cover key safety aspects.

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, direct sentence with zero wasted words. It's appropriately sized for a simple action and front-loads the core functionality without 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?

For a destructive tool with no output schema, the description is minimally adequate but lacks context about outcomes or errors. Annotations provide safety hints, but the description doesn't address what happens post-click (e.g., page changes, navigation) or integration with other browser tools, leaving gaps in completeness.

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%, providing full parameter documentation. The description adds no parameter-specific information beyond what's in the schema, such as explaining the relationship between 'element' and 'ref' or typical use cases for modifiers. Baseline 3 is appropriate given high schema coverage.

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

Purpose3/5

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

The description 'Perform click on a web page' states the action (click) and target (web page), but is vague about scope and lacks sibling differentiation. It doesn't specify whether this clicks on specific elements or general coordinates, nor how it differs from similar tools like browser_press_key or browser_select_option.

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 browser session or page snapshot), nor does it clarify use cases relative to siblings like browser_hover or browser_press_key for interaction scenarios.

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/Angeluis001/playwright-mcp'

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