adb_grep
Search file contents on an Android device by text pattern with fixed-string matching by default; supports recursive search, depth control, and result limits. Use adb_find for filenames.
Instructions
Search file contents on the device by text pattern. Uses fixed-string matching by default (no regex injection risk). Supports recursive directory search with depth control and result capping. For filename searches, use adb_find instead.
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": {
"pattern": "<pattern>",
"path": "<path>"
},
"name": "adb_grep"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File or directory path to search | |
| root | No | Use root shell for protected paths | |
| device | No | Device serial | |
| pattern | Yes | Text pattern to search for | |
| maxDepth | No | Maximum directory depth for recursive search (1-50, default 10) | |
| recursive | No | Search directories recursively | |
| ignoreCase | No | Case-insensitive search (default: true) | |
| maxResults | No | Maximum matching lines to return (1-10000, default 500) | |
| fixedString | No | Use fixed-string matching (default: true, safer). Set false for regex. | |
| result_handle | No | Optional. If provided, store this tool's result under `result://<tool>/<name>` for retrieval after compaction. Name must be 1-32 chars, [a-zA-Z0-9_-]. Existing handles with the same tool+name are overwritten. Use adb_result_list to see active handles, adb_result_get or the MCP Resource URI to retrieve. | |
| filesWithMatches | No | Show only filenames that contain matches, not the matching lines | |
| result_handle_ttl | No | Optional. TTL in seconds for the result handle (60 to 604800). Default 43200 (12 hours). Ignored if result_handle is not provided. |