Skip to main content
Glama

Replace in files

replace_in_files
Destructive

Use this when the same text or regular-expression replacement should be searched and applied across multiple files under a path, such as a rename or version bump. For one known block use edit_block; for one complete known file use write_file.

Input Schema

NameRequiredDescriptionDefault
pathYesAbsolute path of a file or directory to search.
regexNoTreat pattern as a regular expression. Default false (plain text).
deviceYesReMCP device id returned by list_devices. Required for every device operation.
dry_runNoOnly report the files that would change. Default false.
patternYesText or regular expression to find.
maxFilesNoStop after this many changed files. Default 100, maximum 500.
filePatternNoOptional glob limiting which file names are changed, such as "*.ts".
replacementYesReplacement text. In regex mode, $1 and friends refer to capture groups.

Output Schema

NameRequiredDescriptionDefault
dataNoOptional structured result data for follow-up reasoning and tool calls.
textYesConcise human-readable result of the tool call.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added
  2. Removed
  3. First observed

TDQS

A4.5/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, so the destructive nature is covered. The description adds useful behavioral context by clarifying that the operation applies across multiple files and supports both plain text and regular expressions, which goes beyond what the annotations alone convey.

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?

Two sentences, both purposeful, with the primary use case front-loaded and exclusions clearly stated. No filler or redundant restatement of the tool name or schema.

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-file operation with a rich input schema, an output schema, and safety annotations, the description covers the core decision the agent needs: when to pick this tool over its siblings. Nothing essential for correct invocation is missing.

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 fully documents all 8 parameters including regex, dry_run, and maxFiles. The description provides high-level context but no additional parameter-level semantics beyond what the schema already supplies, so a baseline 3 is appropriate.

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?

The description clearly states a specific operation: search and apply a text or regex replacement across multiple files under a path, with concrete examples like rename or version bump. It also distinguishes itself from siblings by naming edit_block and write_file as alternatives.

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?

The description opens with 'Use this when...' and gives explicit conditions for use: same replacement across multiple files. It also states when not to use it: one known block should use edit_block, and one complete known file should use write_file.

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