Skip to main content
Glama

edit_file

Replace exact text in an existing file to apply small, well-defined edits. If the match is stale or ambiguous, nothing is written—re-read the file and retry.

Instructions

Edit an existing file directly via exact-match replacement (free — no Codex usage). The search text must match the file's current content exactly, once (or set replace_all) — a stale or ambiguous match refuses with nothing written, so re-read the file and retry. Use for small, well-defined edits ChatGPT can make itself; delegate large multi-file work to implement.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the file, relative to the project or absolute inside it.
searchYesExact text to find (must match the current file content).
projectNoProject path the user named in chat (armed via init). Pass it explicitly on every call. If no project has been named, ask the user; never guess.
replaceYesReplacement text.
replace_allNoReplace all occurrences (default false: exactly one must match).
session_tokenNoSession token returned by init (or create_project). Required for every project tool call in this chat. A new chat must be re-armed.
Behavior4/5

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

With no annotations provided, the description carries the transparency burden. It discloses key behaviors: exact-match requirement, refusal without writing on stale/ambiguous matches ('refuses with nothing written'), and the need to re-read the file. It also adds the notable context that this operation is free and does not consume Codex usage.

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?

The description is three sentences long and front-loaded with the core action and mechanism. Every sentence adds value: match semantics, failure behavior, and usage boundaries. There is no filler or redundant repetition of schema properties.

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?

Given six parameters and full schema coverage, the description provides sufficient operational context: exact-match behavior, failure mode with no partial write, retry guidance, and scope boundaries. It does not describe return values, but no output schema exists and the behavior on failure is already disclosed.

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 description coverage is 100%, so the schema already documents all six parameters. The description adds helpful context about exact-match semantics and replace_all's 'exactly one must match' rule, but it does not add per-parameter syntax or format details beyond what the schema already provides.

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's purpose: 'Edit an existing file directly via exact-match replacement.' It goes beyond a bare verb by specifying the mechanism (exact-match) and the resource (existing file), and it differentiates from siblings by scoping it to small, well-defined edits and delegating large multi-file work to implement.

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?

The description gives explicit guidance: 'Use for small, well-defined edits ChatGPT can make itself; delegate large multi-file work to implement.' It also instructs the agent to re-read and retry after a stale or ambiguous match, providing clear operational context.

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/psrisuphan/cheap-labor'

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