Skip to main content
Glama

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
NameRequiredDescriptionDefault
textYesText to input
deviceIdNoDevice ID (optional)

Implementation Reference

  • 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' }; } }
  • 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));
  • TypeScript interface defining the input parameters for the adb_input_text tool, used in ScreenTools.inputText.
    export interface InputTextOptions { deviceId?: string; text: string; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/richard0913/adb-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server