input_text
Simulate text input on Android devices using ADB commands. Automate UI interactions by injecting text directly into active fields for testing and debugging purposes.
Instructions
Input text into the current field
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | Text to input |
Implementation Reference
- src/tools/handlers.ts:186-205 (handler)The core handler function for the 'input_text' tool. Escapes the input text, executes ADB commands to input the text and press ENTER, captures the updated UI hierarchy, and returns a formatted response with the action confirmation and UI dump.input_text: async (args: any) => { const { text } = args as { text: string }; const escapedText = text.replace(/"/g, '\\"'); await executeCommand(`adb shell input text "${escapedText}"`); await executeCommand(`adb shell input keyevent 66`); const uiContent = await captureUIContent(false); return { content: [ { type: 'text', text: `Text input: ${text}`, }, ...uiContent, ], }; },
- src/tools/definitions.ts:103-116 (schema)The JSON schema definition for the 'input_text' tool, defining the required 'text' string parameter.{ name: 'input_text', description: 'Input text into the current field', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'Text to input', }, }, required: ['text'], }, },
- src/index.ts:26-30 (registration)Registration of tool list handler, which provides the schema definitions for all tools including 'input_text'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions, }; });
- src/index.ts:32-46 (registration)Registration of tool call handler, which dynamically dispatches to the 'input_text' handler based on tool name from the imported toolHandlers object.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const handler = toolHandlers[name as keyof typeof toolHandlers]; if (!handler) { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`); } return await handler(args); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError(ErrorCode.InternalError, `Tool execution failed: ${errorMessage}`); } });