Skip to main content
Glama

fs_apply_patch

Destructive

Apply structured text patches to project files with conflict detection via expected checksums and atomic writes, requiring a lease for access.

Instructions

Apply a structured text patch under the project root. Requires lease_id. For existing files, expected_sha256 from fs_read is mandatory (CONFLICT if the file changed). Pass edits=[{old_string,new_string},...] or new_content for a full replace. create=true allows new files (empty expected_sha256). Atomic temp+rename in the same directory. Write to production checkouts requires the matching writable_env gate declared in projects.yaml. Use stable environment-specific project identifiers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
editsNo
createNo
projectNodemo
lease_idYes
new_contentNo
expected_sha256No

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

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

Beyond the destructive annotation, the description discloses key behaviors: conflict detection, atomic temp+rename, production write restrictions, and the distinction between edits and full content replacement. This provides agents with safety-critical knowledge about failure modes and requirements.

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 packs critical information into a few sentences, front-loading the main action and following with prerequisites, modes, and safety details. No redundant content is present.

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?

Given the complexity of a patch tool with two modes, conflict handling, and environment restrictions, the description covers the key operational aspects. The existence of an output schema addresses return values, so the description does not need to explain them.

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?

Schema coverage is 0%, so the description carries the burden of explaining parameters; it defines edits, new_content, create, expected_sha256, and project identifiers. It leaves path somewhat implicit (under project root) and does not explain lease_id format, but overall adds substantial semantic value beyond 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?

The description clearly states the tool applies a structured text patch under the project root, distinguishing it from sibling file-write tools by emphasizing structured edits and the ability to do full replace via new_content. The verb 'apply' and specific resource make the action unambiguous.

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?

It explains when to use the tool: requires a lease_id, and for existing files, an expected_sha256 from fs_read to detect conflicts. However, it does not explicitly compare to alternatives like fs_write_file, so while context is clear, exclusion guidance is implicit. The mention of create=true and production writable_env gates gives situational guidance.

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/davidlosasgonzalez/codeagent-mcp'

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