Skip to main content
Glama

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

NameRequiredDescriptionDefault
pathYesFile or directory path to search
rootNoUse root shell for protected paths
deviceNoDevice serial
patternYesText pattern to search for
maxDepthNoMaximum directory depth for recursive search (1-50, default 10)
recursiveNoSearch directories recursively
ignoreCaseNoCase-insensitive search (default: true)
maxResultsNoMaximum matching lines to return (1-10000, default 500)
fixedStringNoUse fixed-string matching (default: true, safer). Set false for regex.
result_handleNoOptional. 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.
filesWithMatchesNoShow only filenames that contain matches, not the matching lines
result_handle_ttlNoOptional. TTL in seconds for the result handle (60 to 604800). Default 43200 (12 hours). Ignored if result_handle is not provided.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.1.6
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  2. Changed3 schema fields changedv1.1.3
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / result_handle
      Added value: +{
      +  "description": "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.",
      +  "maxLength": 32,
      +  "minLength": 1,
      +  "pattern": "^[a-zA-Z0-9_-]+$",
      +  "type": "string"
      +}
    • addedInput schema / properties / result_handle_ttl
      Added value: +{
      +  "description": "Optional. TTL in seconds for the result handle (60 to 604800). Default 43200 (12 hours). Ignored if result_handle is not provided.",
      +  "maximum": 604800,
      +  "minimum": 60,
      +  "type": "integer"
      +}
  3. First observedv1.1.1

TDQS

A3.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must carry the whole behavioral burden. It does disclose meaningful traits: fixed-string matching by default with the stated reason (no regex injection risk), recursive search, depth control, and result capping. It does not describe the shape of returned matches (lines vs file-prefixed), whether it is a read-only operation, or how privileged paths behave, leaving real gaps for a 12-parameter tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four short sentences, front-loaded with purpose, then matching semantics, then capabilities, then the sibling handoff. No restatement of the name or title and no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 12-parameter tool with no annotations and no output schema, the description covers the core search semantics and the main routing decision but says nothing about return content, error cases, or how result_handle interacts with the returned output. Adequate to invoke, not sufficient to predict results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so every parameter including result_handle, fixedString, maxDepth, and maxResults is already documented in the schema. The description's mentions of recursive search, depth control, and result capping merely mirror those fields rather than adding syntax, defaults, or interaction rules. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Search file contents on the device by text pattern') and immediately distinguishes itself from the nearest sibling by naming adb_find for filename searches. An agent can route content-grep vs filename-find without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit alternative and the condition that selects it ('For filename searches, use adb_find instead'), which is the main routing ambiguity among these siblings. It does not discuss when to prefer adb_shell with grep, or when root/device targeting is needed, so it stops short of full when/when-not coverage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools