Skip to main content
Glama

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

Implementation Reference

  • 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' }; } }
  • 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));
  • TypeScript interface for input parameters used in the handler, matching the JSON schema.
    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