Skip to main content
Glama
lewisvoncken

Playwright MCP

by lewisvoncken

browser_press_key

Destructive

Simulate keyboard key presses in browser automation to interact with web elements, trigger actions, or navigate pages using Playwright MCP's structured accessibility approach.

Instructions

Press a key on the keyboard

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesName of the key to press or a character to generate, such as `ArrowLeft` or `a`

Implementation Reference

  • The asynchronous handler function that executes the tool logic by pressing the specified key on the current browser tab's page using Playwright's keyboard.press method. It returns code snippet, action, and configuration for snapshot and network wait.
    handle: async (context, params) => {
      const tab = context.currentTabOrDie();
    
      const code = [
        `// Press ${params.key}`,
        `await page.keyboard.press('${params.key}');`,
      ];
    
      const action = () => tab.page.keyboard.press(params.key);
    
      return {
        code,
        action,
        captureSnapshot,
        waitForNetwork: true
      };
    },
  • Tool schema defining the name 'browser_press_key', title, description, Zod input schema for the 'key' parameter, and type as 'destructive'.
    schema: {
      name: 'browser_press_key',
      title: 'Press a key',
      description: 'Press a key on the keyboard',
      inputSchema: z.object({
        key: z.string().describe('Name of the key to press or a character to generate, such as `ArrowLeft` or `a`'),
      }),
      type: 'destructive',
    },
  • src/tools.ts:36-52 (registration)
    Registration of the keyboard tools (including browser_press_key) into the snapshotTools array with captureSnapshot enabled (true).
    export const snapshotTools: Tool<any>[] = [
      ...common(true),
      ...console,
      ...dialogs(true),
      ...files(true),
      ...install,
      ...keyboard(true),
      ...navigate(true),
      ...network,
      ...pdf,
      ...screenshot,
      ...snapshot,
      ...tabs(true),
      ...testing,
      ...video,
      ...wait(true),
    ];
  • src/tools.ts:54-69 (registration)
    Registration of the keyboard tools (including browser_press_key) into the visionTools array with captureSnapshot disabled (false).
    export const visionTools: Tool<any>[] = [
      ...common(false),
      ...console,
      ...dialogs(false),
      ...files(false),
      ...install,
      ...keyboard(false),
      ...navigate(false),
      ...network,
      ...pdf,
      ...tabs(false),
      ...testing,
      ...video,
      ...vision,
      ...wait(false),
    ];
Behavior4/5

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

Annotations indicate destructiveHint=true and readOnlyHint=false, which the description doesn't contradict. The description adds value by specifying the action is on a keyboard, but it doesn't elaborate on behavioral traits like whether this simulates a physical key press, if it triggers browser events, or any side effects. With annotations covering safety, this is adequate but not rich in context.

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, clear sentence with no wasted words, making it easy to parse and understand quickly. It's front-loaded with the core action, which is ideal for tool selection.

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 (simple action with one parameter) and rich annotations (destructiveHint=true, openWorldHint=true), the description is minimally adequate. However, with no output schema and siblings like 'browser_type', it could benefit from more context about differences or return values to be fully complete.

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?

The input schema has 100% description coverage, with the 'key' parameter well-documented in the schema itself. The description doesn't add any semantic details beyond what's in the schema, such as examples of key names or special cases. 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.

Purpose4/5

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

The description clearly states the action ('press') and target ('key on the keyboard'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'browser_type' or 'browser_click', which also involve keyboard/mouse interactions, leaving some ambiguity about when to choose this specific tool over alternatives.

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_type' or 'browser_click'. It lacks context about typical use cases (e.g., pressing special keys like Enter or Arrow keys) or prerequisites, leaving the agent to infer usage from the tool name 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/lewisvoncken/playwright-mcp'

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