Skip to main content
Glama

str_replace

Replace a specific substring in a file, verifying uniqueness to avoid errors, for precise small edits.

Instructions

Surgical edit: replace a literal substring in a file. Default occurrence='unique' (errors on >1 match). Tiny payload in/out; preferred over file.replace for any edit smaller than the whole file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileYes
findYes
vaultNo
dry_runNo
replaceYes
occurrenceNo
expected_content_hashNo
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 discloses that occurrence defaults to 'unique' and errors on >1 match, and that the payload is tiny. However, it does not detail potential side effects, error behavior for missing files or unmatched strings, or any permissions or atomicity guarantees.

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 efficient sentences with no waste. The first sentence defines the core action, the second provides critical usage guidance. Every sentence adds value.

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 the complexity (7 parameters, no output schema, no annotations), the description is too brief. It does not explain return values or behaviors for edge cases like file not found or unmatched string. The phrase 'tiny payload in/out' is vague and insufficient.

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 has 0% description coverage across 7 parameters. The description only adds meaning to the 'occurrence' parameter by explaining its default. It does not explain 'dry_run', 'expected_content_hash', 'vault', or the return behavior. This is insufficient for an agent to correctly invoke all parameters.

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 the tool performs a surgical replacement of a literal substring in a file. It distinguishes itself from sibling tool file.replace by noting it is preferred for edits smaller than the whole file, and mentions the default occurrence behavior.

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?

The description advises when to use this tool over file.replace (for any edit smaller than the whole file) and explains the default 'occurrence=unique' behavior that errors on multiple matches. It does not explicitly list when not to use it, but provides sufficient context for an agent to decide.

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/usrivastava92/obsidian-native-mcp'

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