Skip to main content
Glama

browser_key_press

Simulate keyboard key presses during web automation to interact with forms, navigate pages, or trigger browser actions using Selenium WebDriver.

Instructions

Press a key on the keyboard

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press (e.g., 'Enter', 'Tab', 'a', etc.)

Implementation Reference

  • Registers the 'browser_key_press' MCP tool with server.tool(), including input schema for 'key' parameter and the handler function that retrieves the WebDriver, instantiates ActionService, calls pressKey(key), and returns success/error messages.
    server.tool(
      'browser_key_press',
      'Press a key on the keyboard',
      {
        key: z.string().describe("Key to press (e.g., 'Enter', 'Tab', 'a', etc.)"),
      },
      async ({ key }) => {
        try {
          const driver = stateManager.getDriver();
          const actionService = new ActionService(driver);
          await actionService.pressKey(key);
          return {
            content: [{ type: 'text', text: `Key '${key}' pressed` }],
          };
        } catch (e) {
          return {
            content: [
              {
                type: 'text',
                text: `Error pressing key: ${(e as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • Implements the core key press functionality in ActionService using Selenium WebDriver's ActionSequence: keyDown(key) followed by keyUp(key).
    async pressKey(key: string): Promise<void> {
      const actions = this.driver.actions({ bridge: true });
      await actions.keyDown(key).keyUp(key).perform();
    }
  • Zod schema defining the input parameter 'key' as a string for the browser_key_press tool.
    {
      key: z.string().describe("Key to press (e.g., 'Enter', 'Tab', 'a', etc.)"),
    },
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Press a key on the keyboard' implies an action that simulates keyboard input, but doesn't specify whether this occurs in a browser context (implied by sibling tools), what happens if no element is focused, whether modifiers (Ctrl, Shift) are supported, or what the expected outcome is. The description provides minimal behavioral context beyond the basic action.

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 directly states the tool's function without any wasted words. It's appropriately sized for a simple tool with one parameter and gets straight to the point with zero redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a browser automation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't clarify the browser context (though implied by sibling names), doesn't explain what 'pressing a key' means in automation terms, and provides no information about return values or error conditions. The description leaves too many contextual questions unanswered.

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 a clear parameter description for 'key'. The description adds no additional parameter information beyond what the schema already provides. With complete schema coverage, the baseline score of 3 is appropriate since the schema does the heavy lifting for parameter documentation.

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 resource ('a key on the keyboard'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'browser_type' (which might involve typing text rather than single key presses), but the verb+resource combination is specific enough for basic understanding.

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. There's no mention of when key presses are appropriate versus typing text with 'browser_type', no indication of whether this simulates keyboard events in a browser context, and no prerequisites or exclusions stated.

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/pshivapr/selenium-mcp'

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