Skip to main content
Glama

fill

Type text into input fields or select options from dropdown menus on web pages for browser automation and testing.

Instructions

Type text into a input, text area or select an option from a element.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesThe uid of an element on the page from the page content snapshot
valueYesThe value to fill in

Implementation Reference

  • Core handler logic for filling form elements. Retrieves element handle, checks if combobox and selects option accordingly, otherwise fills directly.
    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 content and filling with the actual 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}"`);
      }
    }
  • Zod schema defining input parameters: uid of the element and value to fill.
    schema: {
      uid: z
        .string()
        .describe(
          'The uid of an element on the page from the page content snapshot',
        ),
      value: z.string().describe('The value to fill in'),
    },
  • Tool handler wrapper that performs the fill action within waitForEventsAfterAction and updates response.
    handler: async (request, response, context) => {
      await context.waitForEventsAfterAction(async () => {
        await fillFormElement(
          request.params.uid,
          request.params.value,
          context as McpContext,
        );
      });
      response.appendResponseLine(`Successfully filled out the element`);
      response.setIncludeSnapshot(true);
    },
  • Registration of the 'fill' tool using defineTool, including name, description, schema, and handler.
    export const fill = defineTool({
      name: 'fill',
      description: `Type text into a input, text area or select an option from a <select> element.`,
      annotations: {
        category: ToolCategories.INPUT_AUTOMATION,
        readOnlyHint: false,
      },
      schema: {
        uid: z
          .string()
          .describe(
            'The uid of an element on the page from the page content snapshot',
          ),
        value: z.string().describe('The value to fill in'),
      },
      handler: async (request, response, context) => {
        await context.waitForEventsAfterAction(async () => {
          await fillFormElement(
            request.params.uid,
            request.params.value,
            context as McpContext,
          );
        });
        response.appendResponseLine(`Successfully filled out the element`);
        response.setIncludeSnapshot(true);
      },
    });
Behavior2/5

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

Annotations indicate readOnlyHint=false, implying a mutation, which aligns with the description's action of typing or selecting. However, the description adds minimal behavioral context beyond this, failing to disclose traits like potential side effects (e.g., triggering events), error conditions (e.g., invalid UID), or interaction specifics (e.g., how it handles different element types), leaving gaps in transparency.

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 function without unnecessary words. It is front-loaded with the core action and resources, making it highly concise and well-structured for quick understanding.

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 tool's complexity (interactive mutation on web elements) and lack of output schema, the description is insufficient. It omits critical context like expected outcomes (e.g., success confirmation), error handling, or dependencies (e.g., requiring a page snapshot), making it incomplete for safe and effective use by an agent.

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?

With 100% schema description coverage, the input schema fully documents the two parameters (uid and value). The description does not add any meaningful semantics beyond the schema, such as examples or constraints, so it meets the baseline for adequate but unenriched parameter information.

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 ('Type text into' and 'select an option') and the target resources ('input, text area or select element'), making the purpose specific and understandable. However, it does not explicitly distinguish this tool from sibling tools like 'fill_form', which might handle form-level interactions, leaving room for ambiguity in sibling differentiation.

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. It lacks context such as prerequisites (e.g., needing a page snapshot), exclusions (e.g., not for non-interactive elements), or comparisons to siblings like 'fill_form', leaving the agent without clear usage instructions.

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