Skip to main content
Glama

workspace_edit_file

Destructive

Replace a specified text occurrence in a workspace file, or all occurrences with replace_all, while preserving surrounding text and line endings.

Instructions

Replace one exact text occurrence, or all with replace_all=true.

old_text must be nonempty. Missing or ambiguous matches leave the file unchanged. Text and line endings outside replacements are preserved.

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>",
      "old_text": "<old_text>",
      "new_text": "<new_text>"
    },
    "name": "workspace_edit_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYes
new_textYes
old_textYes
replace_allNo

Output Schema

NameRequiredDescriptionDefault
pathYes
resourcesNo
replacementsYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.5.1
    • addedInput schema / additionalProperties
      Added value: +false
  2. Addedv0.2.2

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true and readOnlyHint=false, but the description adds genuinely useful behavior: atomic failure semantics (missing or ambiguous matches leave the file unchanged) and preservation of surrounding text and line endings. It does not cover encoding/BOM handling or whether the file must already exist, which keeps it below 5.

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?

Three short sentences, front-loaded with the core action and the one-vs-all switch, followed by the constraints. No filler, no restatement of the tool name.

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?

An output schema exists, so return values need not be described, and the description covers the main correctness risks (no match, ambiguous match, line-ending preservation). It is only short of complete on preconditions such as whether the path must exist and whether edits are confined to the workspace.

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 0% and the schema only supplies bare titles, so the description has to carry the load. It usefully constrains old_text (must be nonempty) and explains replace_all=true, but path and new_text get no semantics at all beyond their names, leaving a real gap against the 0% coverage baseline.

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?

The description opens with a specific verb+resource: replace an exact text occurrence in a file, with an explicit one-vs-all switch. It is clear enough to separate from workspace_write_file by implication (surgical replacement vs. full write), though it never names the sibling or says 'in a workspace file' explicitly.

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 implied rather than stated: the 'exact text occurrence' framing suggests targeted edits, and the ambiguity rule suggests searching first, but it never says when to prefer this over workspace_write_file or to call workspace_text_search to verify a unique match before editing.

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