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'] } },

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