Skip to main content
Glama

replace_in_file

Replace all occurrences of a specified text with new content directly inside a file, enabling in-place editing without manual search.

Instructions

Replace all occurrences of old with new in a file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
newYesReplacement text.
oldYesText to find.
pathYesFile to edit.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior2/5

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

No annotations are provided, so the description carries full responsibility for behavioral disclosure. It does not state whether the replacement is atomic, case-sensitive, line-based, or whether it handles special characters. Key traits like side effects (modifying disk), failure modes (file not found, permission denied, no matches), and idempotency are entirely omitted.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely short (one sentence, 8 words) – it sacrifices completeness for brevity. It is front-loaded with the verb 'Replace', which is good, but the sentence fails to earn its place because it omits critical context that would only add a few more words (e.g., 'exact', 'in existing file').

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

Completeness2/5

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

Given that there are 19 sibling file-manipulation tools and an output schema exists, the description should clarify what the tool returns (success indicator? list of replacements?), how it interacts with other tools (e.g., conflict with write_file), and edge-case behavior. It is severely incomplete for a file-modification tool that can have destructive effects.

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

Parameters2/5

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

The schema already describes each parameter with basic names and types (path, old, new as strings). The description adds no semantic nuance beyond repeating the parameter roles. It fails to clarify scope: for example, does 'old' match partial substrings or whole words? Does 'new' support escaped characters or newlines? With 100% schema coverage, the baseline is 3, but the description underperforms by not enriching interpretation.

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 clearly states the action ('replace all occurrences'), the target ('file'), and the operation's scope ('all occurrences of old with new'). It distinguishes from siblings like write_file, which would overwrite the entire file, and append_file, which adds text. However, it doesn't explicitly clarify that this is a text-based search-and-replace (not regex) and lacks a caution about potential partial matches or text within larger words.

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?

No guidance is provided on when to use this tool versus its many siblings. For example, the description does not explain that replace_in_file is for simple exact-text substitutions, while search_text might be used to preview matches first, or that write_file is preferable for full rewrites. There is no mention of prerequisites (e.g., file must exist) or when to avoid it (e.g., binary files).

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/jvcaesar/gremlin-mcp'

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