Skip to main content
Glama

fill_form

Fill multiple form elements simultaneously in Chrome DevTools for automated testing and debugging workflows.

Instructions

Fill out multiple form elements at once

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementsYesElements from snapshot to fill out.

Implementation Reference

  • The handler function for the fill_form tool, which fills multiple form elements by calling fillFormElement for each.
    handler: async (request, response, context) => {
      for (const element of request.params.elements) {
        await context.waitForEventsAfterAction(async () => {
          await fillFormElement(
            element.uid,
            element.value,
            context as McpContext,
          );
        });
      }
      response.appendResponseLine(`Successfully filled out the form`);
      response.setIncludeSnapshot(true);
    },
  • Zod schema defining the input parameters for fill_form: an array of {uid, value} objects.
    schema: {
      elements: z
        .array(
          z.object({
            uid: z.string().describe('The uid of the element to fill out'),
            value: z.string().describe('Value for the element'),
          }),
        )
        .describe('Elements from snapshot to fill out.'),
    },
  • Registration of the fill_form tool using defineTool, including name, description, annotations, schema, and handler.
    export const fillForm = defineTool({
      name: 'fill_form',
      description: `Fill out multiple form elements at once`,
      annotations: {
        category: ToolCategories.INPUT_AUTOMATION,
        readOnlyHint: false,
      },
      schema: {
        elements: z
          .array(
            z.object({
              uid: z.string().describe('The uid of the element to fill out'),
              value: z.string().describe('Value for the element'),
            }),
          )
          .describe('Elements from snapshot to fill out.'),
      },
      handler: async (request, response, context) => {
        for (const element of request.params.elements) {
          await context.waitForEventsAfterAction(async () => {
            await fillFormElement(
              element.uid,
              element.value,
              context as McpContext,
            );
          });
        }
        response.appendResponseLine(`Successfully filled out the form`);
        response.setIncludeSnapshot(true);
      },
    });
  • Helper function that fills a single form element, handling comboboxes specially by selecting options.
    async function fillFormElement(
      uid: string,
      value: string,
      context: McpContext,
    ) {
      const handle = await context.getElementByUid(uid);
      try {
        const aXNode = context.getAXNodeByUid(uid);
        if (aXNode && aXNode.role === 'combobox') {
          await selectOption(handle, aXNode, value);
        } else {
          await handle.asLocator().fill(value);
        }
      } finally {
        void handle.dispose();
      }
    }
  • Helper function to select an option in a combobox by matching text and using the real value.
    async function selectOption(
      handle: ElementHandle,
      aXNode: TextSnapshotNode,
      value: string,
    ) {
      let optionFound = false;
      for (const child of aXNode.children) {
        if (child.role === 'option' && child.name === value && child.value) {
          optionFound = true;
          const childHandle = await child.elementHandle();
          if (childHandle) {
            try {
              const childValueHandle = await childHandle.getProperty('value');
              try {
                const childValue = await childValueHandle.jsonValue();
                if (childValue) {
                  await handle.asLocator().fill(childValue.toString());
                }
              } finally {
                void childValueHandle.dispose();
              }
              break;
            } finally {
              void childHandle.dispose();
            }
          }
        }
      }
      if (!optionFound) {
        throw new Error(`Could not find option with text "${value}"`);
      }
    }
Behavior3/5

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

Annotations indicate readOnlyHint=false, implying a write operation, which aligns with 'fill out' in the description. The description adds that it handles 'multiple form elements at once,' suggesting batch behavior, but doesn't detail side effects (e.g., form submission), error handling, or performance implications. With annotations covering the mutation aspect, this is adequate but not rich in behavioral context.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

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

Completeness3/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 output schema and 100% schema coverage, the description is minimal but functional. It covers the core action but lacks context on usage scenarios, error handling, or integration with sibling tools like 'fill'. Given the complexity of batch operations, more guidance would improve completeness.

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%, with the 'elements' parameter fully documented in the schema as an array of objects with 'uid' and 'value'. The description mentions 'multiple form elements' but adds no extra semantic detail beyond what the schema provides, such as how 'uid' relates to form elements or constraints on batch size.

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 out') and target ('multiple form elements at once'), which is specific and actionable. However, it doesn't distinguish itself from the sibling 'fill' tool, which likely serves a similar purpose, leaving some ambiguity about when to use one versus 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 like the 'fill' sibling tool. It lacks context about prerequisites (e.g., needing a form snapshot), exclusions, or specific scenarios where batch filling is preferred over single-element operations.

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/SHAY5555-gif/chrome-devtools-mcp'

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