Skip to main content
Glama

fill_by_uid

Fill text into web form inputs using element UIDs from browser snapshots for automated testing and data entry.

Instructions

Fill text input/textarea by UID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesInput element UID from snapshot
valueYesText to fill

Implementation Reference

  • MCP tool handler: validates uid/value args, gets Firefox instance via getFirefox(), calls firefox.fillByUid(uid, value), returns success/error response with UID error handling.
    export async function handleFillByUid(args: unknown): Promise<McpToolResponse> {
      try {
        const { uid, value } = args as { uid: string; value: string };
    
        if (!uid || typeof uid !== 'string') {
          throw new Error('uid parameter is required and must be a string');
        }
    
        if (value === undefined || typeof value !== 'string') {
          throw new Error('value parameter is required and must be a string');
        }
    
        const { getFirefox } = await import('../index.js');
        const firefox = await getFirefox();
    
        try {
          await firefox.fillByUid(uid, value);
          return successResponse(`✅ fill ${uid}`);
        } catch (error) {
          throw handleUidError(error as Error, uid);
        }
      } catch (error) {
        return errorResponse(error as Error);
      }
    }
  • Tool schema definition: specifies name 'fill_by_uid', description, and inputSchema requiring uid (string) and value (string).
    export const fillByUidTool = {
      name: 'fill_by_uid',
      description: 'Fill text input/textarea by UID.',
      inputSchema: {
        type: 'object',
        properties: {
          uid: {
            type: 'string',
            description: 'Input element UID from snapshot',
          },
          value: {
            type: 'string',
            description: 'Text to fill',
          },
        },
        required: ['uid', 'value'],
      },
    };
  • src/index.ts:131-147 (registration)
    Registration of fill_by_uid handler in the central toolHandlers Map, mapping 'fill_by_uid' to tools.handleFillByUid.
      ['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:175-180 (registration)
    Registration of fillByUidTool in the allTools array for listTools response.
    tools.clickByUidTool,
    tools.hoverByUidTool,
    tools.fillByUidTool,
    tools.dragByUidToUidTool,
    tools.fillFormByUidTool,
    tools.uploadFileByUidTool,
  • Core implementation: Resolves UID to WebElement using snapshot resolveUid callback, clears the input field, sends the value via sendKeys, waits for events.
    async fillByUid(uid: string, value: string): Promise<void> {
      if (!this.resolveUid) {
        throw new Error('fillByUid: resolveUid callback not set. Ensure snapshot is initialized.');
      }
      const el = await this.resolveUid(uid);
    
      try {
        await el.clear();
      } catch {
        // Some inputs may not support clear(); fall back to select-all + delete
        await el.sendKeys(Key.chord(Key.CONTROL, 'a'), Key.DELETE);
      }
    
      await el.sendKeys(value);
    
      // Wait for events to propagate
      await this.waitForEventsAfterAction();
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'Fill text input/textarea' which implies a write operation, but doesn't disclose behavioral traits such as whether it requires page interaction, if it triggers events, error handling, or performance considerations. This is a significant gap for a mutation tool with zero annotation coverage.

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 extremely concise with a single sentence: 'Fill text input/textarea by UID.' It is front-loaded and wastes no words, making it easy to parse quickly. Every part of the sentence earns its place by specifying the action and target.

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

Completeness2/5

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

Given the complexity of a web automation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after filling (e.g., does it submit, return success/failure), error cases, or dependencies like needing a snapshot. For a tool that modifies page state, more context is needed to guide effective 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?

The input schema has 100% description coverage, with clear documentation for 'uid' and 'value'. The description adds no additional meaning beyond what the schema provides, such as examples or context for UID usage. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, but the description doesn't compensate or enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

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

The description states the action ('Fill') and target ('text input/textarea by UID'), which is clear but somewhat vague. It distinguishes from siblings like 'click_by_uid' or 'upload_file_by_uid' by specifying text filling, but doesn't clarify if it's for forms, single fields, or other contexts. The purpose is understandable but lacks specificity about the exact use case.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention when to choose 'fill_by_uid' over 'fill_form_by_uid' (a sibling tool), or prerequisites like needing a snapshot or UID. The description assumes context without explicit instructions, leaving the agent to infer usage from the name alone.

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

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