Skip to main content
Glama

android_input_text

Input text into focused fields on Android devices using ADB commands. This tool enables automated text entry for testing or automation workflows.

Instructions

Input text into the currently focused field on the Android device via ADB

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesText to input. Spaces will be automatically handled.
deviceSerialNoSpecific device serial number to target (optional)

Implementation Reference

  • src/index.ts:416-433 (registration)
    Registration of the 'android_input_text' tool including name, description, and input schema definition.
    { name: 'android_input_text', description: 'Input text into the currently focused field on the Android device via ADB', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Text to input. Spaces will be automatically handled.', }, deviceSerial: { type: 'string', description: 'Specific device serial number to target (optional)', }, }, required: ['text'], }, },
  • src/index.ts:504-505 (registration)
    Dispatch case in the MCP tool handler switch statement that routes 'android_input_text' calls to the handleInputText function.
    case 'android_input_text': return await handleInputText(this.adb, args as any);
  • Main handler function for the 'android_input_text' tool. Extracts arguments, calls the ADB wrapper's inputText method, and returns a success response.
    export async function handleInputText(adb: ADBWrapper, args: InputTextArgs): Promise<{ content: Array<{ type: string; text: string }> }> { const { text, deviceSerial } = args; try { await adb.inputText(text, deviceSerial); return { content: [ { type: 'text', text: `Text input sent: "${text}"`, }, ], }; } catch (error) { throw new Error(`Failed to input text: ${error instanceof Error ? error.message : String(error)}`); } }
  • TypeScript interface defining the input arguments for the android_input_text handler.
    interface InputTextArgs { text: string; deviceSerial?: string; }
  • Core implementation in ADB wrapper that executes the 'adb shell input text' command with space escaping (%s), performing the actual text input on the Android device.
    async inputText(text: string, deviceSerial?: string): Promise<void> { const device = await this.getTargetDevice(deviceSerial); // Escape spaces and special characters const escapedText = text.replace(/ /g, '%s'); await this.exec(['shell', 'input', 'text', escapedText], device); }

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/jduartedj/android-mcp-server'

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