Skip to main content
Glama
Search Code MCP

Search Code MCP

by joutvhu

replace

Refactor code using AST, regex, or text patterns, and preview a unified diff before applying changes to disk.

Instructions

Structural code refactoring and replacement engine. Supports AST rewrite or Regex/Text replacement. By default, runs in dryRun mode producing a unified diff preview to ensure safe operations before writing changes to disk.

Input Schema

NameRequiredDescriptionDefault
pathNoDirectory or file to perform replacement in. Accepts relative or absolute paths (default: '.').
typeNoReplacement engine: 'ast' (default structural rewrite), 'regex', 'text'ast
queryYesTarget search pattern to replace (AST pattern or regex)
dryRunNoIf true (default), outputs unified diff preview without modifying files on disk
fileTypeNoFile type filter
languageNoProgramming language for AST mode (auto-detected if omitted)
noIgnoreNoWhether to search inside gitignored files
filePatternNoGlob pattern to filter files
replacementYesReplacement string or AST rewrite pattern
excludePatternNoGlob pattern to exclude
maxReplacementsNoSafety guardrail: maximum number of matches to replace (default: 50)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.2
    • changedInput schema / properties / path / description
      Previous value: -"Directory or file to perform replacement in (default: '.')"New value: +"Directory or file to perform replacement in. Accepts relative or absolute paths (default: '.')"
  2. First observedv1.0.0

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the full burden. It usefully discloses the dryRun default and diff preview behavior, which is valuable. However, it omits the maxReplacements safety guardrail, permission/auth requirements, whether changes are reversible, and whether dryRun can be overridden.

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 sentences, front-loaded with the core purpose, then modes, then the key safety behavior. Every sentence earns its place with zero waste.

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 complex 11-parameter mutation tool with no annotations and no output schema, the description covers purpose and the dryRun safety default but leaves significant gaps: the maxReplacements guardrail, mode selection guidance, and what happens on non-dryRun execution are not addressed.

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 coverage is 100%, so the schema already documents all 11 parameters including defaults, enums, and meanings. The description adds no parameter-level detail beyond the schema, so 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 states a specific verb+resource ('Structural code refactoring and replacement engine') and identifies the two modes (AST or Regex/Text), clearly distinguishing it from sibling read-only tools like search and count.

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?

The description implies this is a mutation tool with a dryRun preview default, but it does not explicitly state when to use it vs sibling tools (e.g., use search to find patterns first, or count to preview match volume) or when to prefer AST vs regex vs text mode.

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

Deploy Server

Other Tools