Skip to main content
Glama

Edit file text

fs_replace
DestructiveIdempotent

Use this when the user asks to change part of a file in an approved project: replaces exact text with new text. Changes files on the computer. Needs the sessionId from execution_session_open and a new operationId; each call is metered as one execution. A short result is returned inline within about two seconds; otherwise keep the returned IDs for operation_status and operation_output and do not resend the call.

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": {
      "sessionId": "<sessionId>",
      "operationId": "<operationId>",
      "path": "<path>",
      "oldText": "<oldText>",
      "newText": "<newText>"
    },
    "name": "fs_replace"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesFile path relative to the selected project root (or the workspace root without a project target).
newTextYesReplacement text
oldTextYesExact text to replace
sessionIdYesexecutionSessionId returned by execution_session_open
deadlineAtNoOptional UTC admission deadline at most 60 seconds ahead (queue start timeout, NOT process execution lifetime)
replaceAllNoReplace every occurrence instead of exactly one (default false)
operationIdYesA new random UUID v4 for this call; reuse it only to retry this same call
minSimilarityNo0.8-1. When oldText is not found exactly, replace the one near match at least this similar (1 = identical) and report it as fuzzy; without it a near match is only reported, never written (optional)
expectedSha256NoSHA-256 of the current file; the edit is refused if the file changed (optional)
idempotencyKeyNoOptional retry key, 8-128 chars of [A-Za-z0-9._:-]; defaults to operationId
efficiencyProfileNoOptional, unverified label of the client's model, recorded as display metadata in the device owner's local activity statistics. Omit when unknown. Never send credentials or conversation content.
expectedReplacementsNoExact number of places to change; the edit is refused unless oldText occurs exactly this many times (optional)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / properties / expectedReplacements
      Added value: +{
      +  "description": "Exact number of places to change; the edit is refused unless oldText occurs exactly this many times (optional)",
      +  "maximum": 10000,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • addedInput schema / properties / minSimilarity
      Added value: +{
      +  "description": "0.8-1. When oldText is not found exactly, replace the one near match at least this similar (1 = identical) and report it as fuzzy; without it a near match is only reported, never written (optional)",
      +  "maximum": 1,
      +  "minimum": 0.8,
      +  "type": "number"
      +}
  2. Changed3 schema fields changed
    • changedInput schema / properties / deadlineAt / pattern
      Previous value: -"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"New value: +"Z$"
    • removedInput schema / properties / operationId / pattern
      Removed value: -"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    • removedInput schema / properties / sessionId / pattern
      Removed value: -"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
  3. First observed

TDQS

A3.9/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true, idempotentHint=true and openWorldHint=false, so safety and idempotency are covered. The description adds genuinely new behavior: each call is metered as one execution, a short result returns inline in about two seconds, and longer work escalates to operation_status/operation_output. It does not mention reversibility/no-undo, though 'changes files on the computer' is largely restated by the destructive annotation.

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?

One dense paragraph, front-loaded with the activation condition, then prerequisites, then return/retry behavior. Every sentence carries information; the only near-redundant clause is 'Changes files on the computer', which the destructive annotation already conveys.

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 12-parameter, destructive, nested-object tool with no output schema, the description covers the workflow an agent needs: when to call, required session/operation IDs, latency expectation, and the async fallback. The safety parameters (expectedSha256, expectedReplacements, minSimilarity) are fully documented in the schema, so their absence from prose is acceptable, though an irreversibility note would help for a destructive edit.

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 the schema already explains path, oldText, minSimilarity, expectedSha256 and the rest. The description only adds provenance for sessionId and the 'new random UUID, reuse only to retry' rule for operationId, which is marginal value on top of an already documented 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 exact text with new text' in 'part of a file in an approved project', which implicitly separates it from whole-file write tools like fs_write. It stops short of naming a sibling explicitly, so an agent must infer the partial-vs-whole distinction rather than have it stated.

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?

'Use this when the user asks to change part of a file in an approved project' gives a clear triggering condition, and the prerequisites (sessionId from execution_session_open, a new operationId per call) plus the 'do not resend' retry rule add operational guidance. No exclusions or named alternatives are given, so the when-not case is left implicit.

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.