Skip to main content
Glama

browser_fill

Fill any form input field on a webpage by specifying its CSS selector and the text to enter, enabling automated browser interactions.

Instructions

Fill a form input with text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for input field
valueYesText to enter in the field

Implementation Reference

  • The handler function `handleBrowserFill` that executes the browser_fill tool logic. It waits for the selector element, fills the input with the provided value using Playwright's page.fill(), and returns success/error response.
    async function handleBrowserFill(page: Page, args: any): Promise<{ toolResult: CallToolResult }> {
      try {
        await page.waitForSelector(args.selector);
        await page.fill(args.selector, args.value);
        return {
          toolResult: {
            content: [{
              type: "text",
              text: `Filled ${args.selector} with: ${args.value}`,
            }],
            isError: false,
          },
        };
      } catch (error) {
        return {
          toolResult: {
            content: [{
              type: "text",
              text: `Fill operation failed on ${args.selector}: ${(error as Error).message}`,
            }],
            isError: true,
          },
        };
      }
    }
  • The schema definition for browser_fill tool. Defines the name, description, and inputSchema with required properties 'selector' (CSS selector for input field) and 'value' (text to enter).
    {
      name: "browser_fill",
      description: "Fill a form input with text",
      inputSchema: {
        type: "object",
        properties: {
          selector: { type: "string", description: "CSS selector for input field" },
          value: { type: "string", description: "Text to enter in the field" }
        },
        required: ["selector", "value"]
      }
    },
  • src/tools.ts:3-12 (registration)
    The BROWSER_TOOLS array listing 'browser_fill' as one of the available browser tools.
    export const BROWSER_TOOLS = [
      "browser_navigate",
      "browser_screenshot",
      "browser_click",
      "browser_fill",
      "browser_select",
      "browser_hover",
      "browser_evaluate",
      "browser_set_viewport"
    ];
  • The switch case in executeToolCall that dispatches 'browser_fill' to handleBrowserFill handler.
    case "browser_fill":
      return await handleBrowserFill(activePage!, args);
  • The startServer function that calls registerTools and setupHandlers to register all tools including browser_fill on the MCP server.
    async function startServer() {
      parseArgs();
      const server = new Server(
        {
          name: "mcp-browser-agent",
          version: "0.1.0",
        },
        {
          capabilities: {
            resources: {},
            tools: {},
          },
        }
      );
    
      const tools = registerTools();
      setupHandlers(server, tools);
      const transport = new StdioServerTransport();
      await server.connect(transport);
    }
Behavior2/5

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

With no annotations, the description should disclose behavioral details, but it only says 'fill' without specifying whether it overwrites existing text, waits for elements, or handles disabled fields. This leaves significant behavioral ambiguity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence, front-loading the action. However, it could be slightly expanded with useful context while remaining brief.

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?

Given the simplicity of the tool (2 params, no output schema), the description is adequate but lacks details on behavior like clearing the field or submission. Sibling tools exist for other form actions, but no comparative guidance is provided.

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?

Input schema covers 100% of parameters with descriptions (selector and value), so baseline is 3. The description adds no additional semantic information beyond the schema.

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

Purpose5/5

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

The description 'Fill a form input with text' clearly states the action (fill) and the target (form input), distinguishing it from sibling tools like browser_click or browser_select which perform different actions.

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 such as browser_evaluate for setting values or browser_click for activation. There is no mention of prerequisites like element visibility or state.

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/imprvhub/mcp-browser-agent'

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