Skip to main content
Glama
nzjami

Playwright MCP

by nzjami

browser_type

Destructive

Type text into web page elements for browser automation, supporting character-by-character input and form submission.

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 core handler function for the 'browser_type' tool. It locates the target element using the provided ref, then either fills the text instantly or types it sequentially if 'slowly' is true, and optionally presses Enter if 'submit' is true.
    handle: async (tab, params, response) => {
      const locator = await tab.refLocator(params);
    
      await tab.waitForCompletion(async () => {
        if (params.slowly) {
          response.setIncludeSnapshot();
          response.addCode(`// Press "${params.text}" sequentially into "${params.element}"`);
          response.addCode(`await page.${await generateLocator(locator)}.pressSequentially(${javascript.quote(params.text)});`);
          await locator.pressSequentially(params.text);
        } else {
          response.addCode(`// Fill "${params.text}" into "${params.element}"`);
          response.addCode(`await page.${await generateLocator(locator)}.fill(${javascript.quote(params.text)});`);
          await locator.fill(params.text);
        }
    
        if (params.submit) {
          response.setIncludeSnapshot();
          response.addCode(`await page.${await generateLocator(locator)}.press('Enter');`);
          await locator.press('Enter');
        }
      });
    },
  • Defines the input schema for the 'browser_type' tool, extending elementSchema with text, submit, and slowly options.
    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 = defineTabTool({
      capability: 'core',
      schema: {
        name: 'browser_type',
        title: 'Type text',
        description: 'Type text into editable element',
        inputSchema: typeSchema,
        type: 'destructive',
      },
  • Shared base schema for element targeting (element description and snapshot ref), used as foundation for browser_type input schema.
    export const elementSchema = z.object({
      element: z.string().describe('Human-readable element description used to obtain permission to interact with the element'),
      ref: z.string().describe('Exact target element reference from the page snapshot'),
    });
  • src/tools.ts:36-52 (registration)
    Global registration of all MCP tools by aggregating exports from individual tool modules, including 'browser_type' via ...keyboard.
    export const allTools: Tool<any>[] = [
      ...common,
      ...console,
      ...dialogs,
      ...evaluate,
      ...files,
      ...install,
      ...keyboard,
      ...navigate,
      ...network,
      ...mouse,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs,
      ...wait,
    ];
  • Local registration: exports the keyboard tools array including the 'browser_type' tool (named 'type' internally).
    export default [
      pressKey,
      type,
    ];
Behavior3/5

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

Annotations provide readOnlyHint=false, destructiveHint=true, and openWorldHint=true, indicating this is a write operation with potential side effects in an unpredictable environment. The description adds minimal behavioral context beyond annotations - it mentions typing text but doesn't explain what 'editable element' means, how permissions work, or potential consequences. No contradiction with annotations exists, but the description doesn't compensate for the lack of output schema or rich behavioral disclosure.

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 states the core functionality without unnecessary words. It's front-loaded with the essential action and target. Every word earns its place, making it easy for an agent to quickly understand the tool's purpose.

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?

For a destructive tool with 5 parameters and no output schema, the description is minimally adequate. It states what the tool does but doesn't provide enough context about how it works, what constitutes success/failure, or what the agent should expect. The annotations help with safety profiling, but the description doesn't fully compensate for the complexity of browser automation.

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 all parameters well-documented in the schema itself. The description adds no additional parameter semantics beyond what's already in the schema - it doesn't explain the relationship between 'element' and 'ref', when to use 'submit' or 'slowly', or provide examples. With complete schema coverage, the baseline score of 3 is appropriate.

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 ('Type text') and target ('into editable element'), providing a specific verb+resource combination. It distinguishes from siblings like browser_click or browser_press_key by focusing on text input rather than clicking or key pressing. However, it doesn't explicitly differentiate from browser_fill_form, which might have overlapping functionality.

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 like browser_fill_form or browser_press_key. There's no mention of prerequisites, context requirements, or specific scenarios where this tool is preferred over siblings. The agent must infer usage from the tool name and parameters alone.

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/nzjami/mcpPlaywright'

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