Skip to main content
Glama
jomon003

PlayMCP Browser Automation Server

by jomon003

pressKey

Simulate keyboard key presses during browser automation to interact with web elements, submit forms, or navigate pages programmatically.

Instructions

Press a key on the keyboard

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press (e.g., 'Enter', 'Escape', 'ArrowDown', etc.)

Implementation Reference

  • The core implementation of the pressKey tool handler in PlaywrightController, simulating key press using page.keyboard.press(key).
    async pressKey(key: string): Promise<void> {
      try {
        if (!this.isInitialized() || !this.state.page) {
          throw new Error('Browser not initialized');
        }
        this.log('Pressing key', { key });
        await this.state.page.keyboard.press(key);
        this.log('Key press complete');
      } catch (error: any) {
        console.error('Press key error:', error);
        throw new BrowserError('Failed to press key', 'Check if the key name is valid');
      }
    }
  • Tool schema definition for pressKey, specifying the input parameter 'key' as a required string.
    const PRESS_KEY_TOOL: Tool = {
      name: "pressKey",
      description: "Press a key on the keyboard",
      inputSchema: {
        type: "object",
        properties: {
          key: { 
            type: "string",
            description: "Key to press (e.g., 'Enter', 'Escape', 'ArrowDown', etc.)"
          }
        },
        required: ["key"]
      }
    };
  • src/server.ts:539-539 (registration)
    Registers the pressKey tool in the tools dictionary passed to the MCP server's capabilities.
    pressKey: PRESS_KEY_TOOL,
  • src/server.ts:834-845 (registration)
    MCP server request handler for callTool 'pressKey', dispatching to playwrightController.pressKey with input validation.
    case 'pressKey': {
      if (!args.key) {
        return {
          content: [{ type: "text", text: "Key is required" }],
          isError: true
        };
      }
      await playwrightController.pressKey(args.key as string);
      return {
        content: [{ type: "text", text: "Key pressed successfully" }]
      };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't explain how it works (e.g., virtual vs. physical key press, timing, or effects on the system). This leaves gaps in understanding the tool's behavior and potential side effects.

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 that directly states the tool's function without unnecessary words. It's front-loaded and efficient, making it easy for an agent to parse and understand immediately.

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 low complexity (one parameter) and high schema coverage, the description is minimally adequate. However, with no annotations or output schema, it lacks details on behavioral traits (e.g., whether it's safe, blocking, or has side effects), which could be important for an agent to use it correctly in automation contexts.

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 extra meaning beyond what the schema provides, such as examples of valid keys or constraints, so it meets the baseline for high schema coverage.

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 ('a key on the keyboard'), making the purpose immediately understandable. It doesn't distinguish from siblings like 'type' or 'mouseClick', but it's specific enough to avoid vagueness or tautology.

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 like 'type' for text input or 'mouseClick' for mouse interactions. The description lacks context about typical use cases 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/jomon003/PlayMCP'

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