Skip to main content
Glama
pvinis
by pvinis

playwright_fill

Fill input fields on web pages using a CSS selector and specified value. Integrates with the Playwright MCP Server for browser automation tasks.

Instructions

fill out an input field

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
selectorYesCSS selector for input field
valueYesValue to fill

Implementation Reference

  • FillTool class: the core handler that executes page.waitForSelector and page.fill for the playwright_fill tool
    export class FillTool extends BrowserToolBase {
      /**
       * Execute the fill tool
       */
      async execute(args: any, context: ToolContext): Promise<ToolResponse> {
        return this.safeExecute(context, async (page) => {
          await page.waitForSelector(args.selector);
          await page.fill(args.selector, args.value);
          return createSuccessResponse(`Filled ${args.selector} with: ${args.value}`);
        });
      }
    }
  • Tool schema definition including name, description, and input schema for validation
      name: "playwright_fill",
      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"],
      },
    },
  • Dispatch/registration in main tool handler switch statement calling FillTool.execute
    case "playwright_fill":
      return await fillTool.execute(args, context);
  • Initialization of the FillTool instance
    if (!fillTool) fillTool = new FillTool(server);
  • Code generation helper for translating playwright_fill actions to Playwright test code
        case 'playwright_fill':
          return this.generateFillStep(parameters);
        case 'playwright_click':
          return this.generateClickStep(parameters);
        case 'playwright_screenshot':
          return this.generateScreenshotStep(parameters);
        case 'playwright_expect_response':
          return this.generateExpectResponseStep(parameters);
        case 'playwright_assert_response':
          return this.generateAssertResponseStep(parameters);
        case 'playwright_hover':
          return this.generateHoverStep(parameters);
        case 'playwright_select':
          return this.generateSelectStep(parameters);
        case 'playwright_custom_user_agent':
          return this.generateCustomUserAgentStep(parameters);
        default:
          console.warn(`Unsupported tool: ${toolName}`);
          return null;
      }
    }
    
    private generateNavigateStep(parameters: Record<string, unknown>): string {
      const { url, waitUntil } = parameters;
      const options = waitUntil ? `, { waitUntil: '${waitUntil}' }` : '';
      return `
      // Navigate to URL
      await page.goto('${url}'${options});`;
    }
    
    private generateFillStep(parameters: Record<string, unknown>): string {
      const { selector, value } = parameters;
      return `
      // Fill input field
      await page.fill('${selector}', '${value}');`;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states 'fill out an input field' which implies a write operation, but doesn't disclose behavioral traits like whether it waits for the field to be visible, handles validation, triggers events, or has side effects. For a mutation tool with zero annotation coverage, this is a significant gap 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 phrase: 'fill out an input field'. It's front-loaded with the core action and target, with zero wasted words. Every part of the sentence directly contributes to understanding the tool's purpose.

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 complexity of a browser automation tool with no annotations and no output schema, the description is incomplete. It doesn't explain return values, error conditions, or interaction details. For a mutation tool in a Playwright context, more context on behavior and outcomes is needed to be fully helpful.

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 documentation for 'selector' (CSS selector) and 'value' (value to fill). The description doesn't add any meaning beyond this, such as examples or constraints. With high schema coverage, the baseline is 3, as the description doesn't compensate but also doesn't detract from the schema's information.

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' clearly states the action (fill) and target (input field), but it's vague about scope and doesn't differentiate from siblings like playwright_type or playwright_press_key that might handle similar input interactions. It specifies the resource but lacks precision about what 'fill' entails compared to other input methods.

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. With siblings like playwright_press_key (for keyboard input) and playwright_type (which might simulate typing), the description doesn't indicate if this is for direct value setting, form completion, or specific input types. There's no mention of prerequisites, context, or exclusions.

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

Related 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/pvinis/mcp-playwright-stealth'

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