adb_input_text
Input text directly to an Android device using ADB commands. Specify the text and optional device ID to automate text entry for testing or remote management.
Instructions
Input text on the device
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| deviceId | No | Device ID (optional) | |
| text | Yes | Text to input |
Implementation Reference
- src/tools/screen.ts:190-239 (handler)The core implementation of the 'adb_input_text' tool. Escapes the input text for shell safety and executes the ADB command 'shell input text' via AdbClient.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-181 (schema)Tool schema registration in ListTools handler, defining input schema with required 'text' and optional 'deviceId'.{ 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)Tool call dispatcher in CallToolRequestSchema handler, routing 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 for input parameters used in the handler, matching the JSON schema.export interface InputTextOptions { deviceId?: string; text: string; }