Skip to main content
Glama

patch_apk_project

Destructive

Edit smali, AndroidManifest.xml, or resource XML files in an apktool-decoded project by replacing exact text, with ambiguity checks and hash-tracked changes for in-place patching.

Instructions

Edit a text file inside an apktool-decoded project - a smali file, AndroidManifest.xml or a resource XML - by replacing exact text. It fails unless the text is found, and unless it matches exactly once (set all to replace every match); binary files, files over 5 MB and paths that leave the project are refused. Each patch is saved as a record of what changed, with before/after hashes, so the modification is tracked. Returns { projectDir, patchedFile, replacements, sha256Before, sha256After, outputPath }. It edits the project in place: rebuild with build_apk and sign with sign_apk afterwards. Only use it on apps you own or are authorized to modify.

Input Schema

NameRequiredDescriptionDefault
allNoReplace every match. By default the text must match exactly once, so an ambiguous edit fails instead of changing the wrong place.
fileYesPath of the file to edit, relative to the project, e.g. "smali/com/acme/Login.smali" or "AndroidManifest.xml".
findYesThe exact text to replace. Plain text, not a pattern; must not be empty.
replaceYesThe text to put in its place. May be empty to delete the matched text.
workspaceNoWorkspace name (not id). Created if it doesn't exist, and this call is recorded as a job in its history. Defaults to "default".
projectDirYesAbsolute path to the decoded project directory - the outputDir returned by decode_apk. Must contain apktool.yml.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.25

TDQS

A4.4/5.0
Behavior5/5

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

Goes well beyond the destructiveHint/idempotentHint annotations by disclosing the exact failure semantics (text must be found and match exactly once), the refusal rules (binary, size, path traversal), and that edits are in place with before/after hashes recorded as a patch record. The inline return shape compensates for the absent output schema.

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?

Front-loaded with the action and resource, then constraints, then workflow, then return shape — a sensible priority order for an agent. It is dense but every clause carries operational information; the enumerated return-field list is slightly verbose but justified given there is no output schema.

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

Completeness5/5

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

For a destructive in-place edit tool, the description covers failure conditions, safety boundaries, persistence/tracking, the required follow-up steps, and an authorization caveat. No output schema exists, and the return shape is spelled out inline, so nothing material is missing.

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 is already documented, and the description's "set all to replace every match" largely restates the schema's own wording. It reinforces the unique-match default semantic but adds no new format or syntactic detail beyond what the schema provides, so baseline 3 applies.

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 ("Edit a text file inside an apktool-decoded project") and enumerates the exact file types it handles (smali, AndroidManifest.xml, resource XML). This also distinguishes it from siblings like build_apk, sign_apk and read_file, which occupy adjacent steps in the same workflow.

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 clear when-to-use context plus downstream sequencing ("rebuild with build_apk and sign with sign_apk afterwards") and explicit refusals (binary files, >5 MB, paths leaving the project), which implicitly define when not to use it. It does not name a sibling alternative for reading or inspecting files (e.g., read_file) before patching, so routing guidance is strong but not exhaustive.

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