Skip to main content
Glama
freema
by freema

click_by_uid

Click or double-click web elements in Firefox using unique identifiers for browser automation, testing, and scraping tasks.

Instructions

Click element by UID. Set dblClick for double-click.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesElement UID from snapshot
dblClickNoDouble-click (default: false)

Implementation Reference

  • Tool schema definition with name 'click_by_uid', description, and input schema requiring 'uid' (string) and optional 'dblClick' (boolean).
    export const clickByUidTool = {
      name: 'click_by_uid',
      description: 'Click element by UID. Set dblClick for double-click.',
      inputSchema: {
        type: 'object',
        properties: {
          uid: {
            type: 'string',
            description: 'Element UID from snapshot',
          },
          dblClick: {
            type: 'boolean',
            description: 'Double-click (default: false)',
          },
        },
        required: ['uid'],
      },
    };
  • MCP tool handler: validates arguments, imports and calls getFirefox(), executes firefox.clickByUid(uid, dblClick), handles UID errors with user-friendly messages, returns success or error response.
    export async function handleClickByUid(args: unknown): Promise<McpToolResponse> {
      try {
        const { uid, dblClick } = args as { uid: string; dblClick?: boolean };
    
        if (!uid || typeof uid !== 'string') {
          throw new Error('uid parameter is required and must be a string');
        }
    
        const { getFirefox } = await import('../index.js');
        const firefox = await getFirefox();
    
        try {
          await firefox.clickByUid(uid, dblClick);
          return successResponse(`✅ ${dblClick ? 'dblclick' : 'click'} ${uid}`);
        } catch (error) {
          throw handleUidError(error as Error, uid);
        }
      } catch (error) {
        return errorResponse(error as Error);
      }
    }
  • src/index.ts:130-147 (registration)
    Registration of click_by_uid handler in the toolHandlers Map used by the MCP server to route CallToolRequest to handleClickByUid.
      // Input
      ['click_by_uid', tools.handleClickByUid],
      ['hover_by_uid', tools.handleHoverByUid],
      ['fill_by_uid', tools.handleFillByUid],
      ['drag_by_uid_to_uid', tools.handleDragByUidToUid],
      ['fill_form_by_uid', tools.handleFillFormByUid],
      ['upload_file_by_uid', tools.handleUploadFileByUid],
    
      // Screenshot
      ['screenshot_page', tools.handleScreenshotPage],
      ['screenshot_by_uid', tools.handleScreenshotByUid],
    
      // Utilities
      ['accept_dialog', tools.handleAcceptDialog],
      ['dismiss_dialog', tools.handleDismissDialog],
      ['navigate_history', tools.handleNavigateHistory],
      ['set_viewport_size', tools.handleSetViewportSize],
    ]);
  • src/index.ts:174-181 (registration)
    Registration of clickByUidTool schema in the allTools array returned by ListToolsRequest.
    // Input
    tools.clickByUidTool,
    tools.hoverByUidTool,
    tools.fillByUidTool,
    tools.dragByUidToUidTool,
    tools.fillFormByUidTool,
    tools.uploadFileByUidTool,
  • Low-level implementation in DomInteractions class: resolves UID to WebElement, waits for visibility, performs click or doubleClick using Selenium actions, waits for event propagation.
    async clickByUid(uid: string, dblClick = false): Promise<void> {
      if (!this.resolveUid) {
        throw new Error('clickByUid: resolveUid callback not set. Ensure snapshot is initialized.');
      }
      const el = await this.resolveUid(uid);
      await this.driver.wait(until.elementIsVisible(el), 5000).catch(() => {});
    
      if (dblClick) {
        await this.driver.actions({ async: true }).doubleClick(el).perform();
      } else {
        await el.click();
      }
    
      // Wait for events to propagate
      await this.waitForEventsAfterAction();
    }

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/freema/firefox-devtools-mcp'

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