Skip to main content
Glama

edit

Destructive

Modify Python file text via exact string replacements or full rewrites, with type-checked previews and writes blocked when new errors exceed the limit.

Instructions

Edit text in a Python file, type-checked: edit(file_path="src/app.py", old_string="x = 1", new_string="x = 2").

Use this for changes that are not a whole definition (a few lines, an import, a module-level statement) or for rewriting a whole file (new_text). To replace, add or delete a function/method/class by name use edit_symbol.

Give either old_string -> new_string (old_string must match exactly once unless replace_all=true; the reply gives the matching lines and the replacement count) or the complete new_text (also creates a new file), never both. Each text is at most 1,000,000 characters. The text must be valid Python; new lines take the file's line endings (CRLF stays CRLF). Writes when the new errors in the file and in the files that import it stay within max_new_errors (default 0, null = no limit); otherwise nothing is written and the result lists the errors plus an id for apply_edit. apply=false always previews. undo_edit reverts.

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": {
      "file_path": "<file_path>"
    },
    "name": "edit"
  }
}

Input Schema

NameRequiredDescriptionDefault
applyNo
new_textNo
file_pathYes
new_stringNo
old_stringNo
replace_allNo
max_new_errorsNo
include_dependentsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.4

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, but the description adds substantially more: a type-check gate via `max_new_errors`, the guarantee that nothing is written when the gate fails, preview semantics for `apply=false`, and line-ending preservation. These are non-obvious behaviors (a silent type-check veto on writes) that an agent could not derive from the annotations.

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?

The example is front-loaded and the structure moves cleanly from signature to when-to-use to parameter rules to write-safety. It is dense but nearly every clause carries information; the final paragraph runs long and stacks several independent rules into one block, which slightly hurts scannability.

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 multi-mode write tool with no output schema and no schema descriptions, the definition covers the decision inputs, the safety gate, the failure response shape ('the result lists the errors plus an id for apply_edit'), and the recovery path. An agent has enough to call it correctly on the first attempt.

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

Parameters4/5

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

With 0% schema description coverage, the description must carry the parameters and it largely does: mutual exclusivity of `old_string`/`new_string` versus `new_text`, the exactly-once match rule, `replace_all=true` as the escape hatch, `max_new_errors` default 0 with null meaning no limit, and `apply=false` as preview. Gaps remain for `include_dependents` (only obliquely implied by 'files that import it') and the default of `apply`, which are not spelled out.

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 text in a Python file') and immediately backs it with a concrete call example. It explicitly carves out its scope against the sibling `edit_symbol` ('to replace, add or delete a function/method/class by name'), so an agent can discriminate 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 Guidelines5/5

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

Gives an explicit when-to-use rule ('changes that are not a whole definition... or for rewriting a whole file') and names the alternative `edit_symbol` for symbol-level work. It also routes failure recovery to `apply_edit` (via the returned id) and reverts to `undo_edit`, so the follow-on paths are stated rather than inferred.

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