Skip to main content
Glama

pilot_click

Click web page elements using element references or CSS selectors to automate browser interactions. Supports different mouse buttons and double-click actions for precise control.

Instructions

Click an element by @ref (from snapshot) or CSS selector. Auto-routes clicks to selectOption.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
refYesElement ref (@e3) or CSS selector
buttonNoMouse button
double_clickNoDouble-click instead of single click

Implementation Reference

  • The 'pilot_click' tool is defined and implemented in src/tools/interaction.ts. It resolves the element reference, optionally auto-routes to 'selectOption' if the target is an option element, and performs the click using Playwright's locator or page API.
    server.tool(
      'pilot_click',
      'Click an element by @ref (from snapshot) or CSS selector. Auto-routes <option> clicks to selectOption.',
      {
        ref: z.string().describe('Element ref (@e3) or CSS selector'),
        button: z.enum(['left', 'right', 'middle']).optional().describe('Mouse button'),
        double_click: z.boolean().optional().describe('Double-click instead of single click'),
      },
      async ({ ref, button, double_click }) => {
        await bm.ensureBrowser();
        try {
          const page = bm.getPage();
    
          // Auto-route: if ref points to a <option>, use selectOption
          const role = bm.getRefRole(ref);
          if (role === 'option') {
            const resolved = await bm.resolveRef(ref);
            if ('locator' in resolved) {
              const optionInfo = await resolved.locator.evaluate(el => {
                if (el.tagName !== 'OPTION') return null;
                const option = el as HTMLOptionElement;
                const select = option.closest('select');
                if (!select) return null;
                return { value: option.value, text: option.text };
              });
              if (optionInfo) {
                await resolved.locator.locator('xpath=ancestor::select').selectOption(optionInfo.value, { timeout: 5000 });
                bm.resetFailures();
                return { content: [{ type: 'text' as const, text: `Selected "${optionInfo.text}" (auto-routed from click on <option>) → now at ${page.url()}` }] };
              }
            }
          }
    
          const resolved = await bm.resolveRef(ref);
          const clickOptions: any = { timeout: 5000 };
          if (button) clickOptions.button = button;
          if (double_click) clickOptions.clickCount = 2;
    
          if ('locator' in resolved) {
            await resolved.locator.click(clickOptions);
          } else {
            await page.click(resolved.selector, clickOptions);
          }
          await page.waitForLoadState('domcontentloaded').catch(() => {});
          bm.resetFailures();
          return { content: [{ type: 'text' as const, text: `Clicked ${ref} → now at ${page.url()}` }] };
        } catch (err) {
          bm.incrementFailures();
          const hint = bm.getFailureHint();
          let msg = wrapError(err);
          if (hint) msg += '\n' + hint;
          return { content: [{ type: 'text' as const, text: msg }], isError: true };
        }
      }
    );
Behavior3/5

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

Discloses internal auto-routing behavior to selectOption for option elements, which helps predict tool behavior. Missing side effects (page navigation), error handling, or return value disclosure; annotations absent so description carries full burden.

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 efficient sentences with zero waste. First covers core functionality and parameters; second delivers essential behavioral nuance about auto-routing.

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?

Appropriate for a 3-parameter interaction tool. Covers identification methods, prerequisite (snapshot), and special routing behavior. No output schema exists, but description adequately explains the operation's intent.

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 coverage is 100%, establishing baseline 3. Description adds critical context that @ref values come 'from snapshot', explaining the relationship to pilot_snapshot not stated in schema.

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?

Clear specific verb (Click) + resource (element) + identification methods (@ref or CSS selector). Distinguishes from pilot_select_option by noting auto-routing behavior for <option> elements.

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?

Implies workflow prerequisite by noting @ref comes 'from snapshot'. Provides actionable behavioral guidance via auto-routing note. Lacks explicit 'use X instead for Y' comparison with siblings.

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/TacosyHorchata/Pilot'

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