Skip to main content
Glama
Angeluis001

Playwright MCP

by Angeluis001

browser_type

Destructive

Type text into web page elements during browser automation, with options to submit text or simulate character-by-character typing for testing interactive features.

Instructions

Type text into editable element

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
elementYesHuman-readable element description used to obtain permission to interact with the element
refYesExact target element reference from the page snapshot
textYesText to type into the element
submitNoWhether to submit entered text (press Enter after)
slowlyNoWhether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.

Implementation Reference

  • The main handler function implementing the logic for the 'browser_type' tool. It resolves the locator from the page snapshot, generates code snippets for execution, prepares action steps for typing or filling text (slowly or fast), optionally submits with Enter, and returns code and action for execution.
    handle: async (context, params) => {
      const snapshot = context.currentTabOrDie().snapshotOrDie();
      const locator = snapshot.refLocator(params);
    
      const code: string[] = [];
      const steps: (() => Promise<void>)[] = [];
    
      if (params.slowly) {
        code.push(`// Press "${params.text}" sequentially into "${params.element}"`);
        code.push(`await page.${await generateLocator(locator)}.pressSequentially(${javascript.quote(params.text)});`);
        steps.push(() => locator.pressSequentially(params.text));
      } else {
        code.push(`// Fill "${params.text}" into "${params.element}"`);
        code.push(`await page.${await generateLocator(locator)}.fill(${javascript.quote(params.text)});`);
        steps.push(() => locator.fill(params.text));
      }
    
      if (params.submit) {
        code.push(`// Submit text`);
        code.push(`await page.${await generateLocator(locator)}.press('Enter');`);
        steps.push(() => locator.press('Enter'));
      }
    
      return {
        code,
        action: () => steps.reduce((acc, step) => acc.then(step), Promise.resolve()),
        captureSnapshot: true,
        waitForNetwork: true,
      };
    },
  • Schema definition for the 'browser_type' tool using Zod, defining input parameters: element and ref (inherited), text (required), submit and slowly (optional).
    const typeSchema = elementSchema.extend({
      text: z.string().describe('Text to type into the element'),
      submit: z.boolean().optional().describe('Whether to submit entered text (press Enter after)'),
      slowly: z.boolean().optional().describe('Whether to type one character at a time. Useful for triggering key handlers in the page. By default entire text is filled in at once.'),
    });
    
    const type = defineTool({
      capability: 'core',
      schema: {
        name: 'browser_type',
        title: 'Type text',
        description: 'Type text into editable element',
        inputSchema: typeSchema,
        type: 'destructive',
      },
  • Registration of the 'browser_type' tool (named 'type' variable) in the module's default export array of tools.
    export default [
      snapshot,
      click,
      drag,
      hover,
      type,
      selectOption,
    ];
  • src/tools.ts:35-50 (registration)
    Higher-level registration including the snapshot tools module (which contains 'browser_type') in the snapshotTools array used likely for tool registration in the MCP server.
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...wait(true),
    ];

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.5/5.0
Behavior4/5

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

Annotations indicate readOnlyHint=false, openWorldHint=true, and destructiveHint=true, covering safety and scope. The description adds context by specifying it types into 'editable element,' which clarifies the target beyond annotations. It doesn't contradict annotations, but lacks details on side effects (e.g., triggering events) or error handling, though annotations provide a good baseline.

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, front-loaded sentence ('Type text into editable element') with zero waste. It efficiently conveys the core purpose without unnecessary elaboration, 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.

Completeness3/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 browser action with 5 parameters), annotations provide good behavioral context (destructive, open-world), and schema coverage is 100%. However, no output schema exists, and the description lacks details on return values or error cases. It's adequate but has gaps in completeness for a mutation tool.

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 parameter descriptions in the schema (e.g., 'element' for permission, 'ref' for target, 'slowly' for character-by-character typing). The description doesn't add meaning beyond the schema, but the schema is comprehensive, so a baseline score of 3 is appropriate as it doesn't compensate or detract.

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 'Type text into editable element' clearly states the action (type) and target (editable element), distinguishing it from siblings like browser_click or browser_press_key. However, it doesn't explicitly differentiate from browser_select_option or browser_file_upload, which also involve input actions, making it clear but not fully sibling-differentiated.

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 doesn't mention prerequisites (e.g., needing a page snapshot from browser_snapshot), exclusions (e.g., non-editable elements), or comparisons to siblings like browser_press_key for key presses or browser_select_option for dropdowns.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.