Skip to main content
Glama

click

Click elements on web pages using numbered labels from annotated screenshots to navigate and interact with content.

Instructions

Click an element on the page specified by its numbered label from the annotated screenshot

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelYesThe label of the element to click, as shown in the annotated screenshot

Implementation Reference

  • The main handler function for the 'click' tool. It selects the element by its data-label attribute (set by the marking script), checks for target='_blank' links to handle new tabs by navigating directly, and performs the click or navigation.
    async function handleClick(page: Page, args: any): Promise<CallToolResult> {
      const { label } = args;
      if (!label) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: "Label parameter is required for clicking elements",
            },
          ],
        };
      }
    
      const selector = `[data-label="${label}"]`;
      try {
        // Wait for the element to be visible
        await page.waitForSelector(selector, { visible: true });
    
        // Evaluate if the element has a target="_blank" anchor
        type ClickResult =
          | { hasTargetBlank: true; href: string }
          | { hasTargetBlank: false };
    
        const result = await page.$eval(selector, (element): ClickResult => {
          const anchor = element.closest("a");
          if (anchor && anchor.target === "_blank" && anchor.href) {
            return { hasTargetBlank: true, href: anchor.href };
          }
          return { hasTargetBlank: false };
        });
    
        // If the element navigates to a new tab, go to that href instead
        if (result.hasTargetBlank) {
          await page.goto(result.href);
        } else {
          await page.click(selector);
        }
    
        // Success - no error content
        return {
          isError: false,
          content: [{ type: "text", text: `Clicked element with label ${label}.` }],
        };
      } catch (e) {
        return {
          isError: true,
          content: [
            {
              type: "text",
              text: `Could not find clickable element with label ${label}. Error: ${
                (e as Error).message
              }`,
            },
          ],
        };
      }
    }
  • The schema definition for the 'click' tool, including name, description, and input schema specifying a required 'label' number.
    {
      name: "click",
      description:
        "Click an element on the page specified by its numbered label from the annotated screenshot",
      inputSchema: {
        type: "object",
        properties: {
          label: {
            type: "number",
            description:
              "The label of the element to click, as shown in the annotated screenshot",
          },
        },
        required: ["label"],
      },
    },
  • src/index.ts:922-923 (registration)
    The registration/dispatch point in the main handleToolCall function's switch statement that routes 'click' tool calls to the handleClick handler.
    case "click":
      result = await handleClick(page, args);
  • Type definition used within the handler for the result of evaluating if the clicked element opens in a new tab.
    type ClickResult =
      | { hasTargetBlank: true; href: string }
      | { hasTargetBlank: false };
Behavior2/5

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

With no annotations provided, the description carries the full burden but only states the basic action without disclosing behavioral traits like error handling (e.g., what happens if the label is invalid), side effects (e.g., page navigation), or prerequisites (e.g., requiring a screenshot). This leaves gaps in understanding the tool's behavior beyond the core function.

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 with zero waste, front-loading the core action and resource. Every word earns its place by specifying the tool's purpose without redundancy or unnecessary elaboration.

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

Completeness3/5

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

Given the tool's moderate complexity (single parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the basic action and parameter context but lacks details on behavioral aspects like errors or outcomes, which are needed for full understanding in the absence of annotations.

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?

The description adds minimal meaning beyond the input schema, which already has 100% coverage with a clear parameter description. It reinforces that the label is 'numbered' and from 'annotated screenshot,' but doesn't provide additional syntax or format details, 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.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('click an element') and the resource ('on the page specified by its numbered label from the annotated screenshot'), distinguishing it from siblings like 'type' or 'scroll_down' by focusing on element interaction via labeled screenshots.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'annotated screenshot' and 'numbered label,' guiding when to use this tool for clicking labeled elements. However, it lacks explicit alternatives or exclusions, such as when to use 'type' or 'search' instead for different interactions.

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/steel-dev/steel-mcp-server'

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