type_text
Types a string into the currently-focused window by emitting keystrokes. Use the delay parameter to control typing speed.
Instructions
Type a string into the currently-focused window (emits keystrokes). Use key_press for special/modifier combos.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| delay | No | Milliseconds between keystrokes. Default 12. |
Implementation Reference
- server.js:279-287 (handler)The typeText function that executes the 'type_text' tool logic. It validates the 'text' argument is a string, sets a delay (default 12ms), then shells out to xdotool type --delay <ms> -- <text> to emit keystrokes into the currently-focused window.
async function typeText(args) { const missing = requireBin('xdotool'); if (missing) return errorResult(missing); if (typeof args.text !== 'string') return errorResult('text is required (string)'); const delay = Math.max(0, Math.floor(args.delay ?? 12)); const r = await run(BIN.xdotool, ['type', '--delay', String(delay), '--', args.text]); if (r.code !== 0) return errorResult(`type_text failed: ${r.stderr || r.stdout}`); return textResult({ length: args.text.length, delay_ms: delay }); } - server.js:489-500 (schema)The tool registration object for 'type_text' in the TOOLS array, including its name, description, annotations (destructiveHint: true), and inputSchema (text: string required, delay: number optional).
{ name: 'type_text', description: 'Type a string into the currently-focused window (emits keystrokes). Use key_press for special/modifier combos.', annotations: { title: 'Type text', destructiveHint: true }, inputSchema: { type: 'object', properties: { text: { type: 'string' }, delay: { type: 'number', description: 'Milliseconds between keystrokes. Default 12.' }, }, required: ['text'], }, - server.js:563-563 (registration)The HANDLERS map that registers the 'type_text' tool name to its handler function typeText.
type_text: typeText, - server.js:57-62 (helper)The requireBin helper used by typeText to check if xdotool is installed before attempting to use it.
function requireBin(name) { if (!BIN[name]) { return `Required system tool "${name}" is not installed. Install with: sudo apt install ${name === 'gnomeShot' ? 'gnome-screenshot' : name === 'xclip' ? 'xclip' : name === 'xdotool' ? 'xdotool' : 'wmctrl'}`; } return null; }