Skip to main content
Glama

click

Click webpage elements by id, visible text, or CSS selector. Returns whether the click had an effect based on pre/post screenshot diff, helping verify interactions.

Instructions

Click by id (from inspect), by visible text, or by CSS selector. Returns {changed: true/false} based on a pre/post screenshot diff — false means the click had no effect.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idNo
textNo
selectorNo

Implementation Reference

  • The click tool handler function. Accepts optional id (from inspect), text (visible text), or selector (CSS). Takes a pre-click screenshot, performs the click (via data-helm-id, CSS selector, getByText, or getByRole fallback), then takes a post-click screenshot to determine if the page changed. Returns {url, changed}.
    async function click(args: { id?: number; text?: string; selector?: string }) {
      const p = requirePage();
      const before = await p.screenshot({ type: 'png' });
    
      if (args.id !== undefined) {
        // Auto-retag if we don't see any helm ids yet (e.g. user called click before inspect).
        const tagged = await p.evaluate(() => document.querySelector('[data-helm-id]') !== null);
        if (!tagged) await tagInteractive(p);
        const loc = p.locator(`[data-helm-id="${args.id}"]`).first();
        if ((await loc.count()) === 0) {
          throw new Error(`No element with helm id=${args.id}. Run inspect() first to refresh ids.`);
        }
        await loc.click({ timeout: 8000 });
      } else if (args.selector) {
        await p.locator(args.selector).first().click({ timeout: 8000 });
      } else if (args.text) {
        // Try text first, fall back to button-by-name.
        try {
          await p.getByText(args.text, { exact: false }).first().click({ timeout: 4000 });
        } catch {
          await p.getByRole('button', { name: args.text }).first().click({ timeout: 4000 });
        }
      } else {
        throw new Error('Provide one of: {id}, {text}, or {selector}.');
      }
    
      // Best-effort wait for navigation/repaint.
      await p.waitForLoadState('domcontentloaded', { timeout: 5000 }).catch(() => {});
      await p.waitForTimeout(150);
    
      const after = await p.screenshot({ type: 'png' });
      return {
        url: p.url(),
        changed: !before.equals(after),
      };
    }
  • src/index.ts:386-399 (registration)
    Registration of the 'click' tool in the TOOLS array declared for ListToolsRequestSchema. Defines the tool name, description, and inputSchema (id, text, selector as optional properties).
    {
      name: 'click',
      description:
        'Click by id (from inspect), by visible text, or by CSS selector. Returns ' +
        '{changed: true/false} based on a pre/post screenshot diff — false means the click had no effect.',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'number' },
          text: { type: 'string' },
          selector: { type: 'string' },
        },
      },
    },
  • Dispatch/call-site in the CallToolRequestSchema handler where the 'click' tool name is routed to the click() function.
      case 'click':        result = await click(args as { id?: number; text?: string; selector?: string }); break;
      case 'type':         result = await type(args as { text: string; id?: number; selector?: string; submit?: boolean }); break;
      case 'navigate':     result = await navigate(args as { url: string }); break;
      case 'wait_for':     result = await waitFor(args as { text?: string; selector?: string; timeoutMs?: number }); break;
      case 'handoff':      result = await handoff(args as { reason: string }); break;
      default:             throw new Error(`Unknown tool: ${name}`);
    }
Behavior4/5

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

Despite no annotations, the description discloses the return value ({changed: true/false}) and its meaning (pre/post screenshot diff), indicating whether the click had effect. This adds behavioral context beyond a simple 'click'.

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 concise sentences: first covers purpose and methods, second covers return value. No unnecessary words, front-loaded with critical info.

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

Completeness4/5

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

Given the simple action and no output schema, the description covers purpose, targeting methods, and return value interpretation. It could mention caveats (e.g., waiting for page load) but is fairly complete for typical 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?

With 0% schema description coverage, the description explains each parameter's meaning ('id from inspect', 'visible text', 'CSS selector'), but lacks details on format, constraints, or precedence rules. It provides basic semantics but not full specification.

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 action (click) and three identification methods (id, visible text, CSS selector). It distinguishes from sibling tools like 'type' or 'attach' by specifying click-specific targeting.

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

Usage Guidelines3/5

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

The description implies usage through the methods but does not explicitly state when to prefer click over other actions (e.g., when to use attach vs click). No exclusions or alternatives are mentioned.

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/flying-pisces/mcp-helm'

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