clear_text_field
Remove text from Android device input fields by sending delete key commands. This tool helps clear text boxes during UI testing and development workflows.
Instructions
Clear text in current field by sending delete keys
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "clear_text_field"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| length | No | ||
| device_serial | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/adb_mcp_server/server.py:506-513 (handler)The clear_text_field tool handler: moves cursor to end of field and sends multiple delete keyevents to clear up to the specified number of characters. Registered via @mcp.tool() decorator.
@mcp.tool() def clear_text_field(length: int = 50, device_serial: str | None = None) -> str: """Clear text in current field by sending delete keys""" # Move to end and delete backwards run_adb(["shell", "input", "keyevent", "KEYCODE_MOVE_END"], device_serial) for _ in range(length): run_adb(["shell", "input", "keyevent", "KEYCODE_DEL"], device_serial) return f"Cleared up to {length} characters"