Skip to main content
Glama

browser_click

Click elements on web pages to automate interactions. Specify target elements and click options like double-click or button type 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

Implementation Reference

  • Handler function that resolves the element locator from the provided reference and parameters, generates corresponding Playwright code for click or double-click, and executes the action while waiting for completion.
    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(`await page.${await generateLocator(locator)}.dblclick(${buttonAttr});`); else 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 }); }); },
  • Schema definition for the browser_click tool, including name, title, description, input schema (clickSchema which extends elementSchema), and type.
    schema: { name: 'browser_click', title: 'Click', description: 'Perform click on a web page', inputSchema: clickSchema, type: 'destructive', },
  • src/tools.ts:36-52 (registration)
    Registration of all tools including the browser_click tool (via ...snapshot import at line 27), collected into allTools array used by filteredTools and browser backend.
    export const allTools: Tool<any>[] = [ ...common, ...console, ...dialogs, ...evaluate, ...files, ...install, ...keyboard, ...navigate, ...network, ...mouse, ...pdf, ...screenshot, ...snapshot, ...tabs, ...wait, ];
  • Specific input schema for click tool options, extending the shared elementSchema.
    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'), });
  • In the BrowserServerBackend constructor, tools are set using filteredTools which includes browser_click, and later exposed via tools() and called in callTool.
    this._tools = filteredTools(config);

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

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