Skip to main content
Glama
andytango
by andytango

click

Simulate mouse clicks on web page elements using CSS selectors to automate browser interactions for testing or workflow automation.

Instructions

Click an element on the page

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element
buttonNoMouse button to clickleft
clickCountNoNumber of clicks
delayNoDelay between mousedown and mouseup in ms
timeoutNoTimeout in milliseconds
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • Zod input schema for the click tool defining parameters: selector (required), button (default 'left'), clickCount (1-3, default 1), delay (0-5000ms), timeout, tabId.
    export const clickSchema = z.object({
      selector: selectorSchema,
      button: z.enum(['left', 'right', 'middle']).optional().default('left').describe('Mouse button to click'),
      clickCount: z.number().int().min(1).max(3).optional().default(1).describe('Number of clicks'),
      delay: z.number().int().min(0).max(5000).optional().describe('Delay between mousedown and mouseup in ms'),
      timeout: timeoutSchema,
      tabId: tabIdSchema,
    });
  • Registration of the click tool using server.tool with name 'click', description, and clickSchema.shape as input schema.
    server.tool(
      'click',
      'Click an element on the page',
      clickSchema.shape,
  • The handler function for the click tool: retrieves the page for the tab, waits for the selector to be visible, clicks the element with specified button, count, and delay, handles errors including selector not found.
    async ({ selector, button, clickCount, delay, timeout, tabId }) => {
      const pageResult = await getPageForOperation(tabId);
      if (!pageResult.success) {
        return handleResult(pageResult);
      }
    
      const page = pageResult.data;
      const timeoutMs = timeout ?? getDefaultTimeout();
    
      try {
        // Wait for element to be visible
        const element = await page.waitForSelector(selector, {
          timeout: timeoutMs,
          visible: true,
        });
    
        if (!element) {
          return handleResult(err(selectorNotFound(selector)));
        }
    
        await element.click({
          button: (button ?? 'left') as MouseButton,
          clickCount: clickCount ?? 1,
          delay: delay,
        });
    
        return handleResult(ok({ clicked: true, selector }));
      } catch (error) {
        if (error instanceof Error && error.message.includes('waiting for selector')) {
          return handleResult(err(selectorNotFound(selector)));
        }
        return handleResult(err(normalizeError(error)));
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without disclosing behavioral traits. It doesn't mention potential side effects (e.g., page navigation, form submissions), error conditions (e.g., if selector fails), or performance considerations (e.g., waiting for element). This leaves significant gaps for a tool that interacts with dynamic web content.

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, direct sentence with zero wasted words. It's front-loaded with the core action and target, making it immediately understandable without unnecessary elaboration.

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?

For a tool with 6 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what happens after clicking (e.g., returns success/failure, triggers events), error handling, or interaction with page state. Given the complexity of web automation, more context is needed for safe and effective use.

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 additional meaning beyond implying a 'selector' parameter, which is already covered. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 'Click an element on the page' clearly states the action (click) and target (element on page), which is specific and unambiguous. However, it doesn't differentiate from sibling tools like 'mouse' or 'hover' that also interact with page elements, preventing a perfect score.

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 is provided on when to use this tool versus alternatives like 'mouse' (which might offer more granular control) or 'hover' (for non-click interactions). The description lacks context about prerequisites (e.g., needing an element to be visible) or exclusions, offering minimal usage direction.

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

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/andytango/puppeteer-mcp'

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