Skip to main content
Glama

Search and Replace

search_and_replace
Destructive

Perform bulk search-and-replace across files using glob patterns. Replace all occurrences with literal text or regex (RE2 with capture groups). Preview changes via dry run that returns a unified diff before committing modifications.

Instructions

Bulk search-and-replace across files matching a glob. Replaces ALL occurrences per file (unlike edit: first only). Always dryRun:true first — returns a unified diff. Literal matching by default; isRegex:true enables RE2 with capture groups ($1, $2).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoBase directory (default: root). Absolute path required if multiple roots.
filePatternNoGlob to filter files. Default: **/***/*
searchPatternYesText to search for. Literal by default; RE2 regex when `isRegex=true`.
replacementYesReplacement text
isRegexNoTreat searchPattern as RE2 regex. Supports capture groups ($1, $2) in replacement.
caseSensitiveNoCase-sensitive matching. Default: true.
dryRunNoPreview matches without writing. Check changedFiles and matches in the response before committing.
includeHiddenNoInclude hidden files/directories (starting with .). Default: false.
includeIgnoredNoInclude .gitignore-ignored files (node_modules, dist). Default: false.
returnDiffNoReturn unified diff of changes even if dryRun is false. Default: false.
maxFilesNoMax files to process before stopping

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
matchesNoTotal matches found
filesChangedNoFiles modified
processedFilesNoFiles processed
failedFilesNoFiles skipped due to errors
failuresNoSample of per-file errors
changedFilesNoSample of changed files
changedFilesTruncatedNoChanged file list truncated
diffNoUnified diff of changes when `dryRun` or `returnDiff` is enabled
diffTruncatedNoDiff was truncated to fit size limit
stoppedReasonNoWhy processing stopped early
Behavior4/5

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

Annotations already indicate destructive hint. Description adds details: replaces ALL occurrences (vs single), returns unified diff on dry run, literal vs regex matching with capture groups. No contradiction.

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 concise sentences with front-loaded purpose, no fluff, each part adds value: bulk action, all occurrences, dry run advice, regex mode.

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?

Given 11 parameters, annotations, output schema, and sibling tools, the description covers core behavior, safety (dry run), and key options (regex). Missing details like case sensitivity are in schema.

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 covers 100% of parameters with descriptions. Description adds context about overall behavior but doesn't significantly enhance parameter understanding beyond what the schema provides.

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?

Description clearly states tool does bulk search-and-replace across files matching a glob, and distinguishes from sibling 'edit' which replaces only the first occurrence. It also specifies behavior like all occurrences and regex support.

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?

Explicitly recommends using dryRun first and contrasts with 'edit' for single occurrences. No explicit when-not-to-use, but the context is clear.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/j0hanz/filesystem-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server