Skip to main content
Glama

Replace text in sandbox files

replace_in_files

Replace every occurrence of a plain-text pattern with a new value across specified sandbox files, or use an empty value to delete matches.

Instructions

Replace text in sandbox files. Replaces every occurrence of pattern with newValue in each file. Needs file.write.

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": {
      "sandboxId": "<sandboxId>",
      "paths": "<paths>",
      "pattern": "<pattern>",
      "newValue": "<newValue>"
    },
    "name": "replace_in_files"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathsYesFiles up to 5 MiB each.
patternYesPlain text. Every occurrence is replaced, byte for byte; the rest of the file is not changed.
newValueYesRequired. Use "" to delete the matches.
sandboxIdYesPublic Sandbox id returned by create/list/get sandbox calls.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.0

TDQS

C2.8/5.0
Behavior1/5

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

The description says it replaces every occurrence in each file, which overwrites existing content, while the annotations declare `destructiveHint=false`. In MCP terms that hint implies only additive updates, so replacing existing text conflicts with it; the schema further notes that an empty `newValue` deletes matches.

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 description is short and front-loaded, with the scope and permission requirement stated efficiently. The first sentence mostly restates the title, but the second sentence adds useful specificity about every occurrence being replaced.

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

Completeness3/5

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

For a four-required-parameter mutation tool with no output schema, the description covers purpose, replacement scope, and required permission. However, it does not explain return values, partial-failure behavior across multiple files, or reversibility, which are important for a batch file-editing operation.

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 input schema already documents the parameters thoroughly, including file size limits, byte-for-byte replacement, deletion via empty `newValue`, and sandbox ID format. The description adds no parameter-level meaning beyond that 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 uses a specific verb and resource: replacing text in sandbox files, with every occurrence of `pattern` replaced by `newValue`. This distinguishes it from search-oriented siblings like `find_in_files`, but it does not explicitly name or contrast those alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

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

The description gives no guidance on when to use this tool versus alternatives such as `find_in_files` or `search_files`, nor does it state when not to use it. It mentions the `file.write` permission requirement, which is useful operational context, but not usage routing.

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