Skip to main content
Glama
cloudflare

Cloudflare Playwright MCP

Official
by cloudflare

browser_click

Destructive

Simulate single or double clicks on web page elements using human-readable descriptions or exact references. Integrates with Playwright for automated browser testing and Cloudflare Workers.

Instructions

Perform click on a web page

Input Schema

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

Implementation Reference

  • The main handler function that performs the click or double-click action on the target element using Playwright locators derived from the page snapshot. Generates corresponding code snippets and executes the action.
    handle: async (context, params) => {
      const tab = context.currentTabOrDie();
      const locator = tab.snapshotOrDie().refLocator(params);
    
      const code: string[] = [];
      if (params.doubleClick) {
        code.push(`// Double click ${params.element}`);
        code.push(`await page.${await generateLocator(locator)}.dblclick();`);
      } else {
        code.push(`// Click ${params.element}`);
        code.push(`await page.${await generateLocator(locator)}.click();`);
      }
    
      return {
        code,
        action: () => params.doubleClick ? locator.dblclick() : locator.click(),
        captureSnapshot: true,
        waitForNetwork: true,
      };
    },
  • Zod schemas defining the input parameters for the browser_click tool: elementSchema for element description and ref, extended by clickSchema with optional doubleClick boolean.
    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 clickSchema = elementSchema.extend({
      doubleClick: z.coerce.boolean().optional().describe('Whether to perform a double click instead of a single click'),
    });
  • Tool registration using defineTool, specifying name 'browser_click', schema, capability, and handler. This Tool object is exported and included in snapshotTools for MCP server registration.
    const click = defineTool({
      capability: 'core',
      schema: {
        name: 'browser_click',
        title: 'Click',
        description: 'Perform click on a web page',
        inputSchema: clickSchema,
        type: 'destructive',
      },
    
      handle: async (context, params) => {
        const tab = context.currentTabOrDie();
        const locator = tab.snapshotOrDie().refLocator(params);
    
        const code: string[] = [];
        if (params.doubleClick) {
          code.push(`// Double click ${params.element}`);
          code.push(`await page.${await generateLocator(locator)}.dblclick();`);
        } else {
          code.push(`// Click ${params.element}`);
          code.push(`await page.${await generateLocator(locator)}.click();`);
        }
    
        return {
          code,
          action: () => params.doubleClick ? locator.dblclick() : locator.click(),
          captureSnapshot: true,
          waitForNetwork: true,
        };
      },
    });
  • src/tools.ts:35-50 (registration)
    Collects all snapshot tools including those from snapshot.ts (containing browser_click) into snapshotTools array, used for registration in the MCP connection.
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...wait(true),
    ];
  • Selects and filters tools including browser_click based on config, passes to Context, and registers handlers for listTools and callTool in the MCP server.
    const allTools = config.vision ? visionTools : snapshotTools;
    const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability));
    const context = new Context(tools, config, browserContextFactory);
Behavior4/5

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

Annotations provide readOnlyHint=false, destructiveHint=true, and openWorldHint=true, indicating this is a mutating, potentially destructive operation in an open environment. The description doesn't contradict these but adds minimal behavioral context beyond the basic action. It doesn't elaborate on what 'destructive' means in this context (e.g., page state changes).

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?

Extremely concise with a single, clear sentence. No wasted words, though it may be overly brief. Front-loaded with the core action.

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 a complex, destructive tool with no output schema, the description is minimal. It covers the basic purpose but lacks context on usage, behavioral implications beyond annotations, or expected outcomes. Annotations help, but more description would improve completeness for such a critical action.

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 parameter-specific information beyond implying a click action. Baseline 3 is appropriate as the schema carries the burden.

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 basic action (click) and resource (web page), but it's vague about scope and doesn't distinguish from siblings like browser_hover or browser_press_key. It lacks specificity about what kind of click or interaction context.

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 on when to use this tool versus alternatives. It doesn't mention prerequisites like needing a browser snapshot or element reference, nor does it differentiate from similar tools like browser_hover or browser_press_key in the sibling list.

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

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

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