scroll_to_text
Scroll on Android device screens to locate specific text content, supporting automated UI testing and development workflows.
Instructions
Scroll until text is found on screen
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"text": "<text>"
},
"name": "scroll_to_text"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| max_scrolls | No | ||
| device_serial | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/adb_mcp_server/server.py:482-496 (handler)The handler function for the 'scroll_to_text' tool. It repeatedly checks the UI hierarchy for elements containing the target text using find_element_by_text, scrolls down if not found, and returns the location when found or after max_scrolls attempts.
@mcp.tool() def scroll_to_text( text: str, max_scrolls: int = 10, device_serial: str | None = None ) -> str: """Scroll until text is found on screen""" for i in range(max_scrolls): elements = find_element_by_text(text, partial_match=True, device_serial=device_serial) if elements: return f"Found '{text}' after {i} scrolls at {elements[0].get('center', 'unknown')}" scroll_down(device_serial) time.sleep(0.5) return f"Text '{text}' not found after {max_scrolls} scrolls"