Skip to main content
Glama
andytango
by andytango

fill

Enter text into web form fields using CSS selectors to automate data input during browser automation tasks.

Instructions

Fill a text input or textarea with a value

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for the element
valueYesText value to fill
clearFirstNoClear the field before filling
timeoutNoTimeout in milliseconds
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • The core handler function that executes the 'fill' tool: waits for the element, clears it if requested, types the value using Puppeteer, handles errors.
      const pageResult = await getPageForOperation(tabId);
      if (!pageResult.success) {
        return handleResult(pageResult);
      }
    
      const page = pageResult.data;
      const timeoutMs = timeout ?? getDefaultTimeout();
    
      try {
        const element = await page.waitForSelector(selector, {
          timeout: timeoutMs,
        });
    
        if (!element) {
          return handleResult(err(selectorNotFound(selector)));
        }
    
        if (clearFirst ?? true) {
          // Triple-click to select all, then delete
          await element.click({ clickCount: 3 });
          await page.keyboard.press('Backspace');
        }
    
        await element.type(value);
    
        return handleResult(ok({ filled: true, selector, value }));
      } catch (error) {
        if (error instanceof Error && error.message.includes('waiting for selector')) {
          return handleResult(err(selectorNotFound(selector)));
        }
        return handleResult(err(normalizeError(error)));
      }
    }
  • Registration of the 'fill' tool on the MCP server, including name, description, input schema, and inline handler.
    server.tool(
      'fill',
      'Fill a text input or textarea with a value',
      fillSchema.shape,
      async ({ selector, value, clearFirst, timeout, tabId }) => {
        const pageResult = await getPageForOperation(tabId);
        if (!pageResult.success) {
          return handleResult(pageResult);
        }
    
        const page = pageResult.data;
        const timeoutMs = timeout ?? getDefaultTimeout();
    
        try {
          const element = await page.waitForSelector(selector, {
            timeout: timeoutMs,
          });
    
          if (!element) {
            return handleResult(err(selectorNotFound(selector)));
          }
    
          if (clearFirst ?? true) {
            // Triple-click to select all, then delete
            await element.click({ clickCount: 3 });
            await page.keyboard.press('Backspace');
          }
    
          await element.type(value);
    
          return handleResult(ok({ filled: true, selector, value }));
        } catch (error) {
          if (error instanceof Error && error.message.includes('waiting for selector')) {
            return handleResult(err(selectorNotFound(selector)));
          }
          return handleResult(err(normalizeError(error)));
        }
      }
    );
  • Zod schema defining the input parameters for the 'fill' tool.
    export const fillSchema = z.object({
      selector: selectorSchema,
      value: z.string().describe('Text value to fill'),
      clearFirst: z.boolean().optional().default(true).describe('Clear the field before filling'),
      timeout: timeoutSchema,
      tabId: tabIdSchema,
    });
  • src/server.ts:24-24 (registration)
    High-level registration call that includes the 'fill' tool among interaction tools.
    registerInteractionTools(server);
Behavior2/5

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

With no annotations, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like whether it waits for the element to be visible, handles errors if the selector fails, or interacts with page state. This leaves significant gaps for a tool that modifies web page content.

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 front-loads the core action. Every word earns its place with no redundancy or fluff, making it easy to parse quickly while conveying the essential function.

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 tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain return values, error conditions, or interaction with page state, leaving the agent with incomplete context for safe and effective use in a browser automation scenario.

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 parameters are well-documented in the schema itself. The description adds no additional meaning beyond implying 'value' is for text input, which is already clear from schema descriptions. Baseline 3 is appropriate as the schema handles the heavy lifting.

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 target ('text input or textarea'), making the purpose immediately understandable. It doesn't differentiate from siblings like 'select' or 'keyboard' that might also input text, but it's specific enough to convey the core function without being tautological.

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 like 'keyboard' for typing or 'select' for dropdowns. The description only states what it does, not when it's appropriate, leaving the agent to infer usage from context without explicit direction.

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/andytango/puppeteer-mcp'

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