Skip to main content
Glama

fill_form_by_uid

Fill multiple web form fields simultaneously using unique identifiers to automate form completion for testing or data entry tasks.

Instructions

Fill multiple form fields at once.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementsYesArray of {uid, value} pairs

Implementation Reference

  • Tool schema definition including inputSchema for validating the 'elements' array of {uid, value} pairs.
    export const fillFormByUidTool = {
      name: 'fill_form_by_uid',
      description: 'Fill multiple form fields at once.',
      inputSchema: {
        type: 'object',
        properties: {
          elements: {
            type: 'array',
            description: 'Array of {uid, value} pairs',
            items: {
              type: 'object',
              properties: {
                uid: {
                  type: 'string',
                  description: 'Field UID',
                },
                value: {
                  type: 'string',
                  description: 'Field value',
                },
              },
              required: ['uid', 'value'],
            },
          },
        },
        required: ['elements'],
      },
    };
  • Primary MCP handler: validates input, retrieves Firefox instance, executes fillFormByUid on Firefox facade, handles UID staleness errors.
    export async function handleFillFormByUid(args: unknown): Promise<McpToolResponse> {
      try {
        const { elements } = args as { elements: Array<{ uid: string; value: string }> };
    
        if (!elements || !Array.isArray(elements) || elements.length === 0) {
          throw new Error('elements parameter is required and must be a non-empty array');
        }
    
        // Validate all elements
        for (const el of elements) {
          if (!el.uid || typeof el.uid !== 'string') {
            throw new Error(`Invalid element: uid is required and must be a string`);
          }
          if (el.value === undefined || typeof el.value !== 'string') {
            throw new Error(`Invalid element for uid "${el.uid}": value must be a string`);
          }
        }
    
        const { getFirefox } = await import('../index.js');
        const firefox = await getFirefox();
    
        try {
          await firefox.fillFormByUid(elements);
          return successResponse(`✅ filled ${elements.length} fields`);
        } catch (error) {
          const errorMsg = (error as Error).message;
          if (errorMsg.includes('stale') || errorMsg.includes('Snapshot') || errorMsg.includes('UID')) {
            throw new Error(`UIDs stale/invalid. Call take_snapshot first.`);
          }
          throw error;
        }
      } catch (error) {
        return errorResponse(error as Error);
      }
    }
  • src/index.ts:131-147 (registration)
    Registration of the fill_form_by_uid handler in the central toolHandlers Map used by the MCP server.
      ['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-181 (registration)
    Registration of fillFormByUidTool (with schema) in the allTools array returned by listTools.
    tools.clickByUidTool,
    tools.hoverByUidTool,
    tools.fillByUidTool,
    tools.dragByUidToUidTool,
    tools.fillFormByUidTool,
    tools.uploadFileByUidTool,
  • Core implementation: Iterates over elements array, resolves each UID to WebElement, calls fillByUid (clear + sendKeys) on each.
    async fillFormByUid(elements: Array<{ uid: string; value: string }>): Promise<void> {
      if (!this.resolveUid) {
        throw new Error(
          'fillFormByUid: resolveUid callback not set. Ensure snapshot is initialized.'
        );
      }
    
      for (const { uid, value } of elements) {
        await this.fillByUid(uid, value);
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. While 'fill' implies a write/mutation operation, the description doesn't address important behavioral aspects: whether this requires specific permissions, what happens if fields don't exist, whether values are validated, if the operation is atomic, or what happens on failure. This is inadequate 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 at just 6 words, front-loading the core purpose without any wasted words. Every word earns its place by communicating the essential action and scope of the operation.

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?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after filling (success indicators, error conditions), doesn't address the relationship with sibling tools, and provides minimal behavioral context. The 100% schema coverage helps with parameters but doesn't compensate for the lack of operational guidance.

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?

Schema description coverage is 100%, so the schema already fully documents the single 'elements' parameter and its structure. The description adds minimal value beyond what's in the schema - it mentions 'multiple form fields' which aligns with the array structure, but provides no additional semantic context about UID format, value constraints, or practical usage examples.

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

Purpose4/5

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

The description clearly states the action ('fill') and resource ('multiple form fields at once'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from its sibling 'fill_by_uid', which appears to be a similar single-field operation, leaving some ambiguity about when to choose one over the other.

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?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'fill_by_uid' (presumably for single fields) and 'click_by_uid' available, there's no indication of appropriate contexts, prerequisites, or exclusions for this bulk operation.

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