adb_input_text
Send text input to Android devices via ADB commands for automation testing and device control.
Instructions
Input text on the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to input | |
| deviceId | No | Device ID (optional) |
Implementation Reference
- src/tools/screen.ts:190-239 (handler)Core handler function in ScreenTools class that validates input, checks device connection, escapes text for shell, and executes the ADB 'input text' command.async inputText(options: InputTextOptions) { try { const { text, deviceId } = options; if (!text || text.trim().length === 0) { return { success: false, error: 'Empty text', message: 'Text cannot be empty' }; } const connected = await this.adbClient.isDeviceConnected(deviceId); if (!connected) { return { success: false, error: 'Device not connected', message: 'Cannot input text - device is not connected' }; } // Escape special characters for shell const escapedText = text.replace(/["\\\s]/g, '\\$&'); const command = `shell input text "${escapedText}"`; const result = await this.adbClient.executeCommand(command, deviceId); if (!result.success) { return { success: false, error: result.error, message: 'Failed to input text' }; } return { success: true, data: { text, deviceId: deviceId || this.adbClient.getDefaultDevice() }, message: `Input text: "${text}"` }; } catch (error: any) { return { success: false, error: error.message, message: 'Failed to input text' }; } }
- src/index.ts:164-180 (schema)Tool registration in ListTools handler including name, description, and input schema definition.{ name: 'adb_input_text', description: 'Input text on the device', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Text to input', }, deviceId: { type: 'string', description: 'Device ID (optional)', }, }, required: ['text'], },
- src/index.ts:447-448 (registration)Switch case in CallToolRequestSchema handler that routes 'adb_input_text' calls to ScreenTools.inputText method.case 'adb_input_text': return await this.handleToolCall(this.screenTools.inputText(args as any));
- src/types/index.ts:31-34 (schema)TypeScript interface defining the input parameters for the adb_input_text tool, used in ScreenTools.inputText.export interface InputTextOptions { deviceId?: string; text: string; }