type_text
Types regular text character by character into the currently focused input field, simulating real user input for usernames, passwords, and form data.
Instructions
Type regular text into the currently focused input field. Use this for typing usernames, passwords, search queries, form data, etc. Each character is typed individually like a real user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Plain text to type (no special keys - use press_key for those) | |
| delay | No | Delay between keystrokes in ms (default: 50). Increase for slower inputs if needed. | |
| tabId | No | Target tab ID (defaults to active tab) | |
| apiKey | No | API key for authentication if enabled |
Implementation Reference
- src/tools/keyboard.ts:32-53 (registration)MCP tool registration named 'type_text'. Defines the tool name, description, input schema (Zod), and handler callback. The handler sends a 'type_text' command via the WebSocket bridge.
server.tool( 'type_text', 'Type regular text into the currently focused input field. Use this for typing usernames, passwords, search queries, form data, etc. Each character is typed individually like a real user.', { text: z.string().describe('Plain text to type (no special keys - use press_key for those)'), delay: z.number().optional().describe('Delay between keystrokes in ms (default: 50). Increase for slower inputs if needed.'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication if enabled'), }, async ({ text, delay, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'type_text', params: { text, delay }, tabId, apiKey, }); if (!result.success) { return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true }; } return { content: [{ type: 'text', text: `Typed "${text.substring(0, 50)}${text.length > 50 ? '...' : ''}"` }] }; } ); - src/tools/keyboard.ts:35-40 (schema)Input schema for 'type_text': requires 'text' (string), optional 'delay' (number, ms), 'tabId' (number), and 'apiKey' (string).
{ text: z.string().describe('Plain text to type (no special keys - use press_key for those)'), delay: z.number().optional().describe('Delay between keystrokes in ms (default: 50). Increase for slower inputs if needed.'), tabId: z.number().optional().describe('Target tab ID (defaults to active tab)'), apiKey: z.string().optional().describe('API key for authentication if enabled'), }, - src/tools/keyboard.ts:41-52 (handler)Handler function for 'type_text'. Receives { text, delay, tabId, apiKey }, sends command via bridge.sendCommand, and returns success message or error.
async ({ text, delay, tabId, apiKey }) => { const result = await bridge.sendCommand({ command: 'type_text', params: { text, delay }, tabId, apiKey, }); if (!result.success) { return { content: [{ type: 'text', text: `Error: ${result.error?.message}` }], isError: true }; } return { content: [{ type: 'text', text: `Typed "${text.substring(0, 50)}${text.length > 50 ? '...' : ''}"` }] }; } - src/websocket-bridge.ts:63-103 (helper)WebSocketBridge.sendCommand - the helper that sends the 'type_text' command over WebSocket to the Chrome extension and waits for a response.
async sendCommand(cmd: BridgeCommand): Promise<BridgeResponse> { if (!this.isConnected()) { return { success: false, error: { code: 'NOT_CONNECTED', message: 'Chrome extension is not connected. Ensure the extension is installed, enabled, and the browser is running.', }, }; } const id = crypto.randomUUID(); const timeout = cmd.timeout ?? DEFAULT_TIMEOUT; return new Promise<BridgeResponse>((resolve, reject) => { const timer = setTimeout(() => { this.pending.delete(id); resolve({ success: false, error: { code: 'TIMEOUT', message: `Command '${cmd.command}' timed out after ${timeout}ms`, }, }); }, timeout); this.pending.set(id, { resolve, reject, timer }); const message = { id, type: 'request', command: cmd.command, params: cmd.params, tabId: cmd.tabId, apiKey: cmd.apiKey, timestamp: Date.now(), }; this.client!.send(JSON.stringify(message)); }); } - src/tools/index.ts:32-32 (registration)Registration call site: registerKeyboardTools is invoked during server setup, which registers the 'type_text' tool on the MCP server.
registerKeyboardTools(server, bridge);