Skip to main content
Glama

Edit part of a file

edit_file
Destructive

Replaces old_text with new_text in a file. old_text must match exactly once (include a little surrounding text to make it unique), unless replace_all is true. old_text cannot be empty: to add text, give the passage it goes next to as old_text and that passage with the addition as new_text. The change appears live in Manulyx for anyone with the file open. If tracking of your edits is on for this project (the default, or the owner requires tracking), it is recorded as a tracked change under the person's name and yours that can be accepted or rejected; otherwise it is applied directly and kept in History.

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": {
      "project_id": "<project_id>",
      "path": "<path>",
      "old_text": "<old_text>",
      "new_text": "<new_text>"
    },
    "name": "edit_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYes
new_textYesThe replacement (may be empty to delete the passage).
old_textYesExact text to replace, as it is in the file now.
project_idYesThe project's id, from list_projects.
replace_allNoReplace every occurrence instead of requiring exactly one.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.2/5.0
Behavior5/5

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

Annotations only flag this as destructive and non-idempotent; the description goes well beyond them by disclosing that the change is visible live to anyone with the file open, and that the edit may land as a tracked change under two names that can be accepted or rejected, or be applied directly and kept in History. Those are real consequences an agent cannot get from the structured fields.

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-loads the core replace semantics, then constraint, then edge case, then runtime behavior, so an agent can stop reading early. The final tracking sentence is long and contains several clauses, but every clause carries information about edit consequences.

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

Completeness4/5

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

For a destructive five-parameter mutation with no output schema, the description covers the uniqueness failure mode, the empty-text edge case, concurrency visibility, and tracking semantics. It does not state what the tool returns on success or describe the error when old_text matches multiple times.

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?

Schema coverage is 80%, so most parameters are already documented, but the description adds the critical semantic constraint that old_text must match exactly once and cannot be empty, plus the exact-match-uniqueness workaround. replace_all's meaning is only restated from the schema.

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?

States a specific verb and resource ('Replaces old_text with new_text in a file') and scopes it to a partial edit rather than a whole-file write, which implicitly separates it from write_file. It never names a sibling explicitly, so differentiation comes from inference rather than statement.

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 concrete operational guidance: old_text must match exactly once, include surrounding text for uniqueness, and the non-empty rule with an exact recipe for adding text instead. It also explains when replace_all applies. It does not say when to prefer write_file or delete_file instead of editing, so exclusions are missing.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources