Skip to main content
Glama
andytango
by andytango

keyboard

Press keys or key combinations in a browser to automate typing, navigation, and form interactions during web automation tasks.

Instructions

Press a key or key combination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesKey to press (e.g., "Enter", "Tab", "a")
modifiersNoModifier keys to hold
tabIdNoTab ID to operate on (uses active tab if not specified)

Implementation Reference

  • Handler implementation for the 'keyboard' tool: registers the tool and provides the execution logic using Puppeteer's keyboard API to press modifiers and the key.
    server.tool(
      'keyboard',
      'Press a key or key combination',
      keyboardSchema.shape,
      async ({ key, modifiers, tabId }) => {
        const pageResult = await getPageForOperation(tabId);
        if (!pageResult.success) {
          return handleResult(pageResult);
        }
    
        const page = pageResult.data;
        const mods = (modifiers ?? []) as KeyModifier[];
    
        try {
          // Press modifier keys
          for (const mod of mods) {
            await page.keyboard.down(mod);
          }
    
          // Press the main key
          await page.keyboard.press(key as KeyInput);
    
          // Release modifier keys
          for (const mod of mods.reverse()) {
            await page.keyboard.up(mod);
          }
    
          return handleResult(ok({
            pressed: true,
            key,
            modifiers: mods,
          }));
        } catch (error) {
          return handleResult(err(normalizeError(error)));
        }
      }
    );
  • Zod schema defining the input parameters for the 'keyboard' tool: key, optional modifiers, and optional tabId.
    export const keyboardSchema = z.object({
      key: z.string().min(1).describe('Key to press (e.g., "Enter", "Tab", "a")'),
      modifiers: z.array(z.enum(['Alt', 'Control', 'Meta', 'Shift'])).optional().default([]).describe('Modifier keys to hold'),
      tabId: tabIdSchema,
    });
  • src/server.ts:29-29 (registration)
    Calls registerInputTools which includes the registration of the 'keyboard' tool.
    registerInputTools(server);
  • Type definition for keyboard modifier keys used in the keyboard tool.
     * Keyboard modifier keys
     */
    export type KeyModifier = 'Alt' | 'Control' | 'Meta' | 'Shift';
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. It states what the tool does ('Press') but doesn't describe important behavioral aspects: whether this simulates physical key presses, how it interacts with browser focus, what happens if the target isn't keyboard-focusable, or any side effects. The description is minimal and lacks operational 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 extremely concise - a single, clear sentence that communicates the core functionality without any wasted words. It's front-loaded with the essential action and doesn't include unnecessary elaboration or examples.

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 tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what 'pressing' means in this context (simulation vs. actual input), what happens after key press, error conditions, or typical use cases. The description leaves too many operational 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?

Schema description coverage is 100%, so the schema fully documents all three parameters. The description adds no parameter-specific information beyond what's in the schema. The baseline score of 3 reflects adequate parameter documentation through the schema alone, with no additional value from the description.

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 or key combination'), making the purpose immediately understandable. It distinguishes from siblings like 'click' or 'mouse' by focusing on keyboard input rather than mouse actions. However, it doesn't explicitly differentiate from all possible keyboard-related tools that might exist.

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. It doesn't mention when keyboard input is preferred over other input methods (like 'fill' for text entry or 'click' for button activation), nor does it specify prerequisites or context for effective use.

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/andytango/puppeteer-mcp'

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