Skip to main content
Glama
Angeluis001

Playwright MCP

by Angeluis001

browser_press_key

Destructive

Simulate keyboard key presses during browser automation to interact with web elements, trigger actions, or navigate pages using Playwright's automation capabilities.

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 handler function that executes the browser_press_key tool logic. It presses the specified key on the current browser tab's page using Playwright's keyboard.press method, generates accompanying code snippet, and returns an action object with 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
      };
    },
  • JSON schema definition for the browser_press_key tool, including name, title, description, Zod input schema requiring a 'key' string, and destructive type.
    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',
    },
  • Exports the pressKey tool factory as the default export, registering it to be included in the tools list when imported.
    export default (captureSnapshot: boolean) => [
      pressKey(captureSnapshot),
    ];
Behavior4/5

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

Annotations already indicate destructiveHint=true and readOnlyHint=false, which the description aligns with by implying a state-changing action ('press'). The description adds no additional behavioral context about side effects, timing, or error conditions, but doesn't contradict annotations. With annotations covering the safety profile, this is acceptable.

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?

Extremely concise single sentence with zero wasted words. The description is front-loaded with the core action and gets straight to the point without any unnecessary elaboration or formatting.

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 single-parameter destructive action with good annotations but no output schema, the description is minimally adequate. It states what the tool does but lacks context about browser state requirements, expected outcomes, or error handling that would be helpful for an agent.

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 the parameter 'key' fully documented in the schema. The description adds no additional parameter information beyond what's already in the structured schema, meeting the baseline expectation when schema coverage is complete.

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. It distinguishes from siblings like browser_type (continuous typing) and browser_click (mouse action). However, it doesn't specify this is for browser automation versus general keyboard input.

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 on when to use this tool versus alternatives like browser_type or browser_click. The description provides no context about appropriate use cases, prerequisites, or exclusions, 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/Angeluis001/playwright-mcp'

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