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']
      }
    },
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions clicking but doesn't disclose behavioral traits such as what happens if the element isn't clickable, whether it waits for the element to be visible, error handling, or browser context requirements. The timeout parameter in the schema hints at waiting behavior, but the description doesn't explain this.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to understand at a glance, with every part earning its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of browser automation and lack of annotations or output schema, the description is incomplete. It doesn't cover success/failure outcomes, interaction with sibling tools (e.g., 'wait_for_element'), or contextual details like browser state requirements, leaving gaps for an AI agent to infer behavior.

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 the schema already documents both parameters ('selector' and 'timeout') with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as selector syntax examples or timeout implications, meeting the baseline for high schema coverage.

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 ('Click on') and target ('an element by CSS selector'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from potential sibling interactions like 'type_text' or 'scroll' beyond the basic action, which would require more context about when clicking is preferred over other element interactions.

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 like 'type_text' for input elements or 'scroll' for navigation. With sibling tools like 'wait_for_element' and 'get_element_text' available, there's no indication of prerequisites (e.g., element must be visible) or integration with other tools in the workflow.

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

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