Skip to main content
Glama
schmosbyy
by schmosbyy

file_edit

Replace an exact string in a file with another string using JSON parameters, bypassing shell escaping issues.

Instructions

Replace a unique string in a file with another string. old_str must match the raw file content exactly and appear exactly once. Use this instead of shell-based sed/python for all file edits — content goes through JSON parameters, never a shell, so there are no escaping issues.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the file to edit. Tilde (~) is expanded to the proot home directory.
new_strNoThe replacement string. Use empty string to delete old_str.
old_strYesThe exact string to find. Must appear exactly once in the file.

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. First observedv0.2.0

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden and discloses key behavioral constraints: old_str must match raw file content exactly, must appear exactly once, and new_str can be empty for deletion. It does not mention error behavior if the uniqueness constraint is violated or whether the file is created if absent, but the core mutation behavior is transparent.

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 sentences, no filler, with the primary operation stated first and the usage guidance second. Every sentence contributes either an operational constraint or a routing decision, making it highly scannable for an agent.

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

Completeness4/5

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

For a simple edit tool with fully documented parameters, the description covers the essential constraints and rationale. It does not describe the return value or error handling, and it does not explicitly contrast with file_write, but these are minor gaps given the schema completeness and the clarity of the primary use case.

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

Parameters4/5

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

The schema already documents all three parameters with 100% coverage, so the baseline is 3. The description adds useful nuance by emphasizing that old_str is matched against the raw file content rather than a rendered/escaped version, and that JSON parameter passing avoids shell escaping pitfalls. This meaningfully supplements the 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?

The description states a specific verb ('Replace'), a specific resource ('a file'), and the precise operation (unique string replacement). It clearly distinguishes file_edit from siblings like file_read and file_write, and from shell-based editing, so an agent can identify when this tool is relevant.

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?

It explicitly instructs the agent to use this tool instead of shell-based sed/python for file edits and explains why: content goes through JSON parameters with no escaping issues. This gives a clear when-to-use directive and names the alternatives it replaces.

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

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/schmosbyy/openclaw-mcp-termux'

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