Skip to main content
Glama

click_element

Automate web element interactions by clicking on specific elements using CSS selectors with the MCP Browser Server, streamlining browser automation tasks.

Instructions

Click on an element by CSS selector

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element to click
timeoutNoTimeout in milliseconds

Implementation Reference

  • The main handler function for the click_element tool within the CallToolRequestSchema switch statement. Validates input parameters using ClickElementSchema, performs the click action using Playwright's currentPage.click method, and returns a success confirmation message.
    case 'click_element': { if (!currentPage) { throw new Error('No browser page available. Launch a browser first.'); } const params = ClickElementSchema.parse(args); await currentPage.click(params.selector, { timeout: params.timeout }); return { content: [ { type: 'text', text: `Clicked element: ${params.selector}` } ] }; }
  • Zod schema defining the input validation for the click_element tool: requires a 'selector' string (CSS selector) and optional 'timeout' number (default 5000ms). Used for parsing arguments in the handler.
    const ClickElementSchema = z.object({ selector: z.string(), timeout: z.number().default(5000) });
  • src/index.ts:177-195 (registration)
    Registration of the click_element tool in the ListToolsRequestSchema handler's tools array response. Specifies the tool name, description, and JSON inputSchema matching the Zod schema.
    { name: 'click_element', description: 'Click on an element by CSS selector', inputSchema: { type: 'object', properties: { selector: { type: 'string', description: 'CSS selector for the element to click' }, timeout: { type: 'number', default: 5000, description: 'Timeout in milliseconds' } }, required: ['selector'] } },

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/Wladastic/mcp-browser-server'

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