Skip to main content
Glama
nzjami

Playwright MCP

by nzjami

browser_click

Destructive

Click elements on web pages to automate interactions. Specify target elements, choose single or double click, select mouse buttons, and add keyboard modifiers for precise control.

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 core handler logic for the 'browser_click' tool. It sets up snapshot inclusion, resolves the element locator, generates and adds Playwright code snippets to the response for reproducibility, and executes the click (or double-click) using Playwright's locator API.
      handle: async (tab, params, response) => {
        response.setIncludeSnapshot();
    
        const locator = await tab.refLocator(params);
        const button = params.button;
        const buttonAttr = button ? `{ button: '${button}' }` : '';
    
        if (params.doubleClick) {
          response.addCode(`// Double click ${params.element}`);
          response.addCode(`await page.${await generateLocator(locator)}.dblclick(${buttonAttr});`);
        } else {
          response.addCode(`// Click ${params.element}`);
          response.addCode(`await page.${await generateLocator(locator)}.click(${buttonAttr});`);
        }
    
        await tab.waitForCompletion(async () => {
          if (params.doubleClick)
            await locator.dblclick({ button });
          else
            await locator.click({ button });
        });
      },
    });
  • Zod input schema definition for the 'browser_click' tool, extending elementSchema with optional doubleClick and button parameters, and the full tool schema object including name, title, description, and type.
    const clickSchema = elementSchema.extend({
      doubleClick: z.boolean().optional().describe('Whether to perform a double click instead of a single click'),
      button: z.enum(['left', 'right', 'middle']).optional().describe('Button to click, defaults to left'),
    });
    
    const click = defineTabTool({
      capability: 'core',
      schema: {
        name: 'browser_click',
        title: 'Click',
        description: 'Perform click on a web page',
        inputSchema: clickSchema,
        type: 'destructive',
      },
  • Base Zod schema for element selection used by browser_click and other interaction tools.
    export 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'),
    });
  • src/tools.ts:36-52 (registration)
    Collection of all tools including browser_click (via ...snapshot import at line 27), provided as allTools array for registration in the MCP server backend.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];
  • Exports the browser_click tool (as 'click') along with related browser interaction tools from snapshot.ts module.
    export default [
      snapshot,
      click,
      drag,
      hover,
      selectOption,
    ];
Behavior3/5

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

Annotations already provide significant behavioral information (destructiveHint: true, readOnlyHint: false, openWorldHint: true). The description adds minimal value beyond this, only stating the basic action. It doesn't elaborate on what 'destructive' means in this context (e.g., could trigger navigation, form submission, or JavaScript events), nor does it mention rate limits or authentication needs.

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 at just four words, with zero wasted language. It's front-loaded with the core action and target. Every word earns its place, making it efficient for quick understanding.

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 web interaction with 5 parameters) and rich annotations, the description is minimally adequate. However, with no output schema and a potentially complex behavioral impact (destructive actions on web pages), the description could do more to explain typical outcomes or error conditions. It meets minimum requirements but leaves gaps.

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 all parameters are well-documented in the schema itself. The description adds no additional parameter information beyond what's in the schema. The baseline score of 3 reflects adequate parameter documentation through the schema alone, with no extra value from the description.

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 'Perform click on a web page' clearly states the action (click) and target (web page), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like browser_hover or browser_press_key, which also involve web page interactions. The description is specific but lacks sibling distinction.

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 when to choose browser_click over browser_press_key for button presses, or browser_hover for mouse movements without clicking. No context about prerequisites or typical use cases is provided.

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/nzjami/mcpPlaywright'

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