send_keys
Simulate keyboard input by sending text or special keys to Scenic applications. Use modifiers like ctrl, shift, alt, or meta for complex interactions. Ideal for testing and automation via Scenic MCP server.
Instructions
Send keyboard input to the connected Scenic application
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | Special key name (e.g., enter, escape, tab, backspace, delete, up, down, left, right, home, end, page_up, page_down, f1-f12) | |
| modifiers | No | Modifier keys to hold while pressing the key | |
| text | No | Text to type (each character will be sent as individual key presses) |
Implementation Reference
- src/tools.ts:300-370 (handler)The handler function that executes the 'send_keys' tool. It validates connection to Scenic app, checks input parameters, constructs a command with action 'send_keys', sends it to the Elixir backend via connection, parses response, and returns success/error messages.async function handleSendKeys(args: any) { try { const isRunning = await conn.checkTCPServer(); if (!isRunning) { return { content: [ { type: 'text', text: 'Cannot send keys: No Scenic application connected.\n\nUse connect_scenic first or start your Scenic application. The MCP server will automatically detect when the app becomes available.', }, ], isError: false, }; } const { text, key, modifiers } = args; if (!text && !key) { return { content: [ { type: 'text', text: 'Error: Must provide either "text" or "key" parameter', }, ], isError: true, }; } const command = { action: 'send_keys', text, key, modifiers: modifiers || [], }; const response = await conn.sendToElixir(command); const data = JSON.parse(response); if (data.error) { return { content: [ { type: 'text', text: `Error sending keys: ${data.error}`, }, ], isError: true, }; } return { content: [ { type: 'text', text: `Keys sent successfully!\n${JSON.stringify(data, null, 2)}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error sending keys: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/tools.ts:46-70 (schema)Tool schema definition including name, description, and inputSchema specifying parameters for text, key, and modifiers with types and descriptions.{ name: 'send_keys', description: 'KEYBOARD INPUT: Send text input or special keystrokes to the Scenic application. Use for typing text, navigation shortcuts, testing keyboard interactions. Supports text, special keys (enter, escape, tab), and modifier combinations (ctrl+c, cmd+s).', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Text to type (each character will be sent as individual key presses)', }, key: { type: 'string', description: 'Special key name (e.g., enter, escape, tab, backspace, delete, up, down, left, right, home, end, page_up, page_down, f1-f12)', }, modifiers: { type: 'array', items: { type: 'string', enum: ['ctrl', 'shift', 'alt', 'cmd', 'meta'], }, description: 'Modifier keys to hold while pressing the key', }, }, }, },
- src/tools.ts:194-195 (registration)Registration in the tool handler router (handleToolCall switch statement) that dispatches 'send_keys' calls to the handleSendKeys function.case 'send_keys': return await handleSendKeys(args);