Skip to main content
Glama
VikashLoomba

MCP-Server-Playwright

browser_fill

Automatically populate web form fields using CSS selectors to input specified values during browser automation.

Instructions

Fill out an input field

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for input field
valueYesValue to fill

Implementation Reference

  • Handler implementation for the 'browser_fill' tool. Fills the input field specified by CSS selector with the given value using pressSequentially, includes error handling and retry logic for strict mode violations.
    case ToolName.BrowserFill:
      try {
        await page.locator(args.selector).pressSequentially(args.value, { delay: 100 });
        return {
          content: [{
            type: "text",
              text: `Filled ${args.selector} with: ${args.value}`,
            }],
          isError: false,
        };
      } catch (error) {
        if((error as Error).message.includes("strict mode violation")) {
            console.log("Strict mode violation, retrying on first element...");
            try {
                await page.locator(args.selector).first().pressSequentially(args.value, { delay: 100 });
                return {
                    content: [{
                        type: "text",
                        text: `Filled ${args.selector} with: ${args.value}`,
                    }],
                    isError: false,
                };
            } catch (error) {
                return {
                    content: [{
                        type: "text",
                        text: `Failed (twice) to fill ${args.selector}: ${(error as Error).message}`,
                    }],
                    isError: true,
                };
            }
        }
        return {
          content: [{
            type: "text",
              text: `Failed to fill ${args.selector}: ${(error as Error).message}`,
            }],
          isError: true,
        };
      }
  • Input schema definition for the 'browser_fill' tool, specifying selector and value as required string properties.
    {
      name: ToolName.BrowserFill,
      description: "Fill out an input field",
      inputSchema: {
        type: "object",
        properties: {
          selector: { type: "string", description: "CSS selector for input field" },
          value: { type: "string", description: "Value to fill" },
        },
        required: ["selector", "value"],
      },
    },
  • index.ts:36-152 (registration)
    The TOOLS array where the 'browser_fill' tool is registered with its schema, used in ListToolsRequest handler.
    const TOOLS: Tool[] = [
      {
        name: ToolName.BrowserNavigate,
        description: "Navigate to a URL",
        inputSchema: {
          type: "object",
          properties: {
            url: { type: "string" },
          },
          required: ["url"],
        },
      },
      {
        name: ToolName.BrowserScreenshot,
        description: "Take a screenshot of the current page or a specific element",
        inputSchema: {
          type: "object",
          properties: {
            name: { type: "string", description: "Name for the screenshot" },
            selector: { type: "string", description: "CSS selector for element to screenshot" },
            fullPage: { type: "boolean", description: "Take a full page screenshot (default: false)", default: false },
          },
          required: ["name"],
        },
      },
      {
        name: ToolName.BrowserClick,
        description: "Click an element on the page using CSS selector",
        inputSchema: {
          type: "object",
          properties: {
            selector: { type: "string", description: "CSS selector for element to click" },
          },
          required: ["selector"],
        },
      },
      {
        name: ToolName.BrowserClickText,
        description: "Click an element on the page by its text content",
        inputSchema: {
          type: "object",
          properties: {
            text: { type: "string", description: "Text content of the element to click" },
          },
          required: ["text"],
        },
      },
      {
        name: ToolName.BrowserFill,
        description: "Fill out an input field",
        inputSchema: {
          type: "object",
          properties: {
            selector: { type: "string", description: "CSS selector for input field" },
            value: { type: "string", description: "Value to fill" },
          },
          required: ["selector", "value"],
        },
      },
      {
        name: ToolName.BrowserSelect,
        description: "Select an element on the page with Select tag using CSS selector",
        inputSchema: {
          type: "object",
          properties: {
            selector: { type: "string", description: "CSS selector for element to select" },
            value: { type: "string", description: "Value to select" },
          },
          required: ["selector", "value"],
        },
      },
      {
        name: ToolName.BrowserSelectText,
        description: "Select an element on the page with Select tag by its text content",
        inputSchema: {
          type: "object",
          properties: {
            text: { type: "string", description: "Text content of the element to select" },
            value: { type: "string", description: "Value to select" },
          },
          required: ["text", "value"],
        },
      },
      {
        name: ToolName.BrowserHover,
        description: "Hover an element on the page using CSS selector",
        inputSchema: {
          type: "object",
          properties: {
            selector: { type: "string", description: "CSS selector for element to hover" },
          },
          required: ["selector"],
        },
      },
      {
        name: ToolName.BrowserHoverText,
        description: "Hover an element on the page by its text content",
        inputSchema: {
          type: "object",
          properties: {
            text: { type: "string", description: "Text content of the element to hover" },
          },
          required: ["text"],
        },
      },
      {
        name: ToolName.BrowserEvaluate,
        description: "Execute JavaScript in the browser console",
        inputSchema: {
          type: "object",
          properties: {
            script: { type: "string", description: "JavaScript code to execute" },
          },
          required: ["script"],
        },
      },
    ];
  • Enum definition mapping BrowserFill to the tool name string 'browser_fill'.
    enum ToolName {
      BrowserNavigate = "browser_navigate",
      BrowserScreenshot = "browser_screenshot",
      BrowserClick = "browser_click",
      BrowserClickText = "browser_click_text",
      BrowserFill = "browser_fill",
      BrowserSelect = "browser_select",
      BrowserSelectText = "browser_select_text",
      BrowserHover = "browser_hover",
      BrowserHoverText = "browser_hover_text",
      BrowserEvaluate = "browser_evaluate"
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. 'Fill out an input field' implies a mutation/write operation but doesn't disclose behavioral traits such as whether it requires the field to be visible/editable, if it triggers events, error handling, or side effects. It lacks details on permissions, rate limits, or what happens post-fill.

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 with zero waste. It's front-loaded and appropriately sized for the tool's purpose, earning its place without unnecessary elaboration.

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 no annotations, no output schema, and a mutation tool with 2 parameters, the description is incomplete. It doesn't cover return values, error cases, or behavioral context needed for safe invocation. The schema handles parameters, but the description lacks essential operational details.

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 clear descriptions for 'selector' (CSS selector) and 'value' (value to fill). The description adds no meaning beyond the schema, as it doesn't explain parameter interactions or usage nuances. Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Fill out an input field' states a clear verb ('fill out') and resource ('input field'), but it's vague about scope and doesn't distinguish from siblings like browser_select (which might also interact with inputs). It specifies the action but lacks detail on what 'fill out' entails compared to similar tools.

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. It doesn't mention prerequisites (e.g., needing a page loaded), exclusions, or comparisons to siblings like browser_select_text. The description implies usage for input fields but offers no context for decision-making.

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/VikashLoomba/MCP-Server-Playwright'

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