Skip to main content
Glama
lewisvoncken

Playwright MCP

by lewisvoncken

browser_click

Destructive

Click web page elements during browser automation. Specify target elements, choose single or double click, select mouse buttons, and add modifier keys for precise interaction 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

  • Handler function that performs the click action: resolves locator from current tab's snapshot using params (element ref), generates Playwright click code snippet, defines action to execute locator.click(), and configures snapshot/network wait.
      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,
        };
      },
    });
  • Zod schemas defining input for browser_click: shared elementSchema (element description and ref from snapshot), referenced in tool schema with name, title, description, and destructive type.
    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'),
    });
    
    const click = defineTool({
      capability: 'core',
      schema: {
        name: 'browser_click',
        title: 'Click',
        description: 'Perform click on a web page',
        inputSchema: elementSchema,
        type: 'destructive',
      },
  • src/tools.ts:36-52 (registration)
    Registers browser_click by spreading the snapshot module (which exports browser_click among others) into the snapshotTools array, used for MCP toolset.
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...video,
      ...wait(true),
    ];
  • Final MCP registration: selects snapshotTools (including browser_click) into filtered tools list based on config, initializes Context and McpServer with tools for handling ListTools and CallTool requests.
    export function createConnection(config: FullConfig, browserContextFactory: BrowserContextFactory): Connection {
      const allTools = config.vision ? visionTools : snapshotTools;
      const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability));
      validateConfig(config);
      const context = new Context(tools, config, browserContextFactory);
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.

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

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