Skip to main content
Glama

click

Click an element using its snapshot reference or CSS selector. Use snapshot first to discover element refs.

Instructions

Click an element. Provide either ref (from snapshot) or CSS selector. Use snapshot first to discover element refs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tabIdYesTab ID from create_tab
refNoElement ref from snapshot (e.g. 'e1', 'e2')
selectorNoCSS selector (e.g. 'button.submit', '#login')

Implementation Reference

  • Registration and handler for the 'click' tool. Defines the tool with server.tool('click', ...), parses input (tabId, ref, selector), validates that either ref or selector is provided, then calls deps.client.click() and returns the result (success, navigated, refsAvailable).
    export function registerInteractionTools(server: McpServer, deps: ToolDeps): void {
      server.tool(
        "click",
        "Click an element. Provide either ref (from snapshot) or CSS selector. Use snapshot first to discover element refs.",
        {
          tabId: z.string().min(1).describe("Tab ID from create_tab"),
          ref: z.string().min(1).optional().describe("Element ref from snapshot (e.g. 'e1', 'e2')"),
          selector: z.string().min(1).optional().describe("CSS selector (e.g. 'button.submit', '#login')")
        },
        async (input: unknown) => {
          try {
            const parsed = z
              .object({
                tabId: z.string().min(1).describe("Tab ID from create_tab"),
                ref: z.string().min(1).optional().describe("Element ref from snapshot (e.g. 'e1', 'e2')"),
                selector: z.string().min(1).optional().describe("CSS selector (e.g. 'button.submit', '#login')")
              })
              .refine((data) => Boolean(data.ref || data.selector), {
                message: "Either 'ref' or 'selector' is required"
              })
              .parse(input);
    
            const tracked = getTrackedTab(parsed.tabId);
            const result = await deps.client.click(parsed.tabId, {
              ref: parsed.ref,
              selector: parsed.selector
            }, tracked.userId);
            incrementToolCall(parsed.tabId);
            return okResult({
              success: result.success,
              navigated: result.navigated,
              refsAvailable: result.refsAvailable
            });
          } catch (error) {
            return toErrorResult(error);
          }
        }
      );
  • Input schema for the 'click' tool: tabId (required), ref (optional), selector (optional) with validation that at least one of ref/selector is provided.
    {
      tabId: z.string().min(1).describe("Tab ID from create_tab"),
      ref: z.string().min(1).optional().describe("Element ref from snapshot (e.g. 'e1', 'e2')"),
      selector: z.string().min(1).optional().describe("CSS selector (e.g. 'button.submit', '#login')")
    },
  • src/server.ts:42-42 (registration)
    Registration point - registerInteractionTools(server, deps) is called to register the click tool on the MCP server.
    registerInteractionTools(server, deps);
  • ClickRawResponseSchema - Zod schema for parsing the raw API response from the click endpoint.
    const ClickRawResponseSchema = z
      .object({
        success: z.boolean().optional(),
        navigated: z.boolean().optional(),
        refsAvailable: z.boolean().optional()
      })
      .passthrough();
  • client.click() method - sends a POST request to /tabs/{tabId}/click with ref/selector params and userId, returns parsed ClickResponse.
    async click(tabId: string, params: ClickParams, userId: string): Promise<ClickResponse> {
      const response = await this.requestJson(`/tabs/${encodeURIComponent(tabId)}/click`, {
        method: "POST",
        body: JSON.stringify({ ...params, userId })
      }, ClickRawResponseSchema);
    
      return {
        success: response.success ?? true,
        navigated: response.navigated ?? false,
        refsAvailable: response.refsAvailable
      };
    }
Behavior2/5

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

No annotations provided, so description carries full burden. It only says 'Click an element' without disclosing waiting behavior, navigation triggers, or whether it returns anything. Minimal behavioral info.

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?

Two sentences, no redundant words. Front-loaded with action, then details. Highly efficient.

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?

No output schema, so description should cover return values or side effects. It doesn't. Tool is simple but lacks info on what happens after click (e.g., navigation). Barely adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. Description adds value by advising to use snapshot for ref discovery, supplementing the schema's parameter descriptions.

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 'Click an element' with specific verb and resource. It distinguishes from siblings like batch_click by mentioning ref or selector. No ambiguity.

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?

Explicitly advises to use snapshot first to discover refs. Provides clear context but doesn't contrast with alternatives like hover or type_text.

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/redf0x1/camofox-mcp'

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