Skip to main content
Glama
This server has been deprecated

Rebranded to ComposeLint AI. Repository has been moved to TechsOneAi/ComposeLintAI.

replace_pattern

Destructive

Replaces all occurrences of a detected code pattern across project files; use dry-run first to preview affected files and roll back changes when needed.

Instructions

DESTRUCTIVE BATCH OPERATION: Replaces ALL occurrences of a pattern across the project.

What it does: Creates new token + replaces usages. Can be rolled back via rollback_pattern(pattern_id).
When to use: When replacing a recurring conditional or hardcoded pattern across all files.
When NOT to use: USE dry_run=True FIRST to preview affected files. pattern_id must come from detect_conditional_variants.
Side effects: DESTRUCTIVE: Modifies multiple .kt files simultaneously. Records changes in journal.
Parameters:
  - pattern_id: Unique pattern identifier from detect_conditional_variants.
  - dry_run: If True (recommended first), previews changes without writing to disk.
Returns:
  JSON string with replacements made, modified files, and created token name.

Input Schema

NameRequiredDescriptionDefault
dry_runNo
pattern_idYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added
  2. Removed
  3. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, but the description goes further: it discloses that multiple .kt files are modified simultaneously, that a new token is created, that changes are recorded in the journal, and that rollback is available through rollback_pattern(pattern_id). That is meaningful behavior beyond the annotation flags and beyond a bare 'destructive' signal.

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?

Front-loaded with the destructive warning and organized under labelled sections, which suits a risky batch operation. There is mild redundancy in flagging DESTRUCTIVE twice (header and Side effects) and 'When NOT to use' is really a 'how to mitigate' instruction rather than an exclusion, but no sentence is wasted.

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 mutation with two parameters, the definition covers mechanism, prerequisites, mitigation, side effects, and recovery. An output schema exists and the description still summarizes the return payload (replacements, modified files, created token name), leaving no material gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the full burden and does so: pattern_id is tied to its required source tool, and dry_run is explained as a preview that writes nothing to disk, with a recommendation to run it first. Both parameters gain meaning they do not have in the bare schema.

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?

States a specific verb and resource with explicit scope: 'Replaces ALL occurrences of a pattern across the project,' plus the mechanism 'Creates new token + replaces usages.' This clearly separates it from siblings such as set_token, set_text, and detect_conditional_variants, which an agent could otherwise confuse with a replacement operation.

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?

Provides explicit 'When to use' (recurring conditional or hardcoded pattern across all files) and 'When NOT to use' guidance that routes the agent to dry_run=True first. It also imposes an upstream dependency, stating pattern_id must come from detect_conditional_variants, and names rollback_pattern as the undo path.

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