Skip to main content
Glama

adb_file_replace

Replace text in files on an Android device without writing sed syntax. Supports literal find-and-replace, global or line-specific edits, optional backups, and match counts.

Instructions

Find and replace text in a file on the device. Uses sed internally with proper escaping — exposes a safe interface without requiring sed syntax knowledge. Supports global replacement, line-targeted edits, and optional backup creation. Reports match count.

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": {
      "path": "<path>",
      "find": "<find>",
      "replace": "<replace>"
    },
    "name": "adb_file_replace"
  }
}

Input Schema

NameRequiredDescriptionDefault
findYesText to find (literal string, not regex)
pathYesFile path on device
rootNoUse root shell for protected paths
backupNoCreate a .bak backup before modifying
deviceNoDevice serial
globalNoReplace all occurrences (default: true). Set false for first-only.
replaceYesReplacement text
lineNumberNoRestrict replacement to a specific line number

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. Changed1 schema field changedv1.1.3
    • removedInput schema / additionalProperties
      Removed value: -false
  3. First observedv1.1.1

TDQS

B3.4/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full burden. It does disclose real behavior: sed-based in-place editing with escaping, global vs first-only, line targeting, an optional .bak backup, and a returned match count. It stays silent on what happens on zero matches, whether a missing file errors, permission failures, and whether edits are atomic, which are material for a mutation tool.

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

Conciseness4/5

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

Three short sentences, front-loaded with the action and followed by capabilities. The sed-internals clause is useful for trust but borders on implementation trivia; nothing else is wasted.

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 an 8-parameter mutation tool with no annotations and no output schema, the description covers the core mechanics and the match-count return, but omits failure modes and permission behavior. It is adequate, not complete.

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 coverage is 100%, so the baseline is 3. The description adds modest value by mapping its three feature phrases onto the global, lineNumber and backup parameters, but it adds nothing for root or device beyond what the schema already states.

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

Purpose4/5

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

"Find and replace text in a file on the device" gives a specific verb and resource, and the sed note implicitly separates it from raw adb_shell usage and from adb_file_write (whole-file writes). It never names a sibling tool explicitly, so an agent still has to infer the boundary against adb_shell or adb_grep on its own.

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

Usage Guidelines3/5

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

Usage is only implied: you call it when you want to edit file contents in place. There is no statement of when to prefer it over adb_shell sed, adb_push of a rewritten file, or adb_grep plus adb_file_write, and no mention of prerequisites such as write permissions or the file existing.

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