Skip to main content
Glama

type_text

Input text into focused fields on Android devices or emulators, optionally clearing existing content first for automated testing and interaction.

Instructions

Type text into the currently focused input field on the Android device/emulator.

Args: text: The text to type into the input field device_id: Optional device ID to target specific device/emulator clear_first: If True, clears existing text before typing new text

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clear_firstNo
device_idNo
textYes

Implementation Reference

  • The handler function for the MCP tool 'type_text'. It connects to the Android device using uiautomator2, enables fast input IME, and uses device.send_keys() to type the provided text, optionally clearing the field first. The @mcp.tool() decorator registers it as an MCP tool.
    @mcp.tool() async def type_text(text: str, device_id: str = None, clear_first: bool = False) -> dict: """Type text into the currently focused input field on the Android device/emulator. Args: text: The text to type into the input field device_id: Optional device ID to target specific device/emulator clear_first: If True, clears existing text before typing new text """ try: if not text: return { "success": False, "error": "Text parameter cannot be empty", "text": text } # Get device connection for uiautomator2 device = get_device_connection(device_id) # Enable fast input IME for reliable text input device.set_fastinput_ime(enable=True) # Use uiautomator2's send_keys method which is much more reliable device.send_keys(text=text, clear=clear_first) return { "success": True, "message": f"Successfully typed text into input field", "text": text, "cleared_first": clear_first, "action_type": "type_text", "device_id": device_id or "default" } except subprocess.CalledProcessError as e: return { "success": False, "error": f"Failed to type text: {e}", "stderr": e.stderr if e.stderr else "", "text": text, "action_type": "type_text" } except FileNotFoundError: return { "success": False, "error": "ADB not found. Please ensure Android SDK is installed and adb is in PATH.", "text": text, "action_type": "type_text" } except Exception as e: return { "success": False, "error": f"Unexpected error: {e}", "text": text, "action_type": "type_text" }
  • puppeteer.py:822-822 (registration)
    The @mcp.tool() decorator registers the type_text function as an MCP tool.
    @mcp.tool()

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/pedro-rivas/android-puppeteer-mcp'

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