Skip to main content
Glama

browser_click

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, ];

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