Skip to main content
Glama

send_key

Simulate keyboard events in Firefox browser automation. Input specific keys, modifiers, and selectors to control browser interactions programmatically via the MCP server.

Instructions

Send keyboard events

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYes
modifiersNo
repeatNo
selectorNo
tabIdNo

Implementation Reference

  • The primary handler function for the 'send_key' MCP tool. Focuses optional selector, builds keypress with modifiers, repeats presses with delays, and returns confirmation.
    async sendKey(args) {
      this.ensureBrowserRunning();
      const { key, selector, modifiers = [], repeat = 1, tabId } = args;
      const page = this.getPage(tabId);
      
      // If selector is provided, focus the element first
      if (selector) {
        await page.focus(selector);
      }
      
      // Build modifier string for Playwright
      const modifierString = modifiers.length > 0 ? modifiers.join('+') + '+' : '';
      const fullKey = modifierString + key;
      
      // Press the key the specified number of times
      for (let i = 0; i < repeat; i++) {
        await page.keyboard.press(fullKey);
        
        // Small delay between repeated presses to ensure they register
        if (repeat > 1 && i < repeat - 1) {
          await new Promise(resolve => setTimeout(resolve, 50));
        }
      }
      
      return {
        content: [{
          type: 'text',
          text: `Sent key '${fullKey}'${repeat > 1 ? ` ${repeat} times` : ''}${selector ? ` to element '${selector}'` : ''} in tab '${tabId || this.activeTabId}'`
        }]
      };
    }
  • Input schema for 'send_key' tool defining parameters: key (required), selector, modifiers (array), repeat (default 1), tabId.
    inputSchema: {
      type: 'object',
      properties: {
        key: { type: 'string' },
        selector: { type: 'string' },
        modifiers: { type: 'array', items: { type: 'string' } },
        repeat: { type: 'number', default: 1 },
        tabId: { type: 'string' }
      },
      required: ['key']
    }
  • Dispatch registration in CallToolRequestSchema handler switch statement, routing 'send_key' calls to this.sendKey(args).
    case 'send_key':
      return await this.sendKey(args);
  • Tool registration in ListToolsRequestSchema response, including name, description, and full input schema.
    {
      name: 'send_key',
      description: 'Send keyboard events',
      inputSchema: {
        type: 'object',
        properties: {
          key: { type: 'string' },
          selector: { type: 'string' },
          modifiers: { type: 'array', items: { type: 'string' } },
          repeat: { type: 'number', default: 1 },
          tabId: { type: 'string' }
        },
        required: ['key']
      }
    },
Behavior1/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 but offers none. It doesn't indicate whether this is a read or write operation, what permissions might be needed, whether it's destructive (e.g., could trigger unintended actions), what happens on failure, or any rate limits. The description is completely silent on behavioral characteristics beyond the basic action implied by the name.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just three words, which could be appropriate if it were more informative. There's no wasted verbiage or unnecessary elaboration. However, this brevity comes at the cost of being under-specified rather than efficiently informative.

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

Completeness1/5

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

For a tool with 5 parameters, 0% schema description coverage, no annotations, and no output schema, the description is completely inadequate. It doesn't explain what the tool actually does beyond the name, provides no parameter guidance, offers no behavioral context, and gives no indication of return values or error conditions. This leaves the agent with insufficient information to use the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 5 parameters and 0% schema description coverage, the schema provides only type information with no semantic meaning. The description adds zero information about what any parameter does - not explaining what 'key' represents (physical key codes? character strings?), what 'modifiers' are (Ctrl, Shift, etc.), what 'repeat' controls, what 'selector' targets, or what 'tabId' identifies. The description fails completely to compensate for the schema's lack of documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

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

The description 'Send keyboard events' is a tautology that essentially restates the tool name 'send_key' without adding meaningful specificity. While it indicates the general domain (keyboard input), it doesn't specify what kind of events, to what target, or how they differ from sibling tools like 'type_text' or 'click'. The description lacks the verb+resource clarity needed for proper differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides absolutely no guidance on when to use this tool versus alternatives. With sibling tools like 'type_text' (for text input) and 'click' (for mouse interactions), the agent has no indication whether this is for single keys, key combinations, form submissions, or other use cases. There's no mention of prerequisites, target contexts, or exclusions.

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

Related 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/JediLuke/firefox-mcp-server'

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