Skip to main content
Glama

Write a file

write_file
Destructive

Writes a text file in create, atomic overwrite, or append mode and can create parent folders. Refuses protected system, config, and restricted-path files to keep edits within allowed areas.

Instructions

Write a text file: mode create (default; refuses an existing file), overwrite (atomic, keeps permissions) or append. Refuses the files the fence protects (shell rc files, LaunchAgents, .git hooks and config, editor tasks, MCP and Claude Code config, protected folders, anything outside the home folder and temp).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>",
      "content": "<content>"
    },
    "name": "write_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
whyNoone line in plain words: what this does and why (logged). With outside_sandbox: what the user asked for that the sandbox blocked
modeNocreate (default) refuses an existing file; overwrite replaces it; append adds to its end
pathYesthe file: absolute, ~/..., or relative to the home folder
contentYesthe text to write (up to 2 MB)
make_dirsNocreate missing parent folders (default false)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.7.3
    • addedInput schema / properties / content / description
      Added value: +"the text to write (up to 2 MB)"
    • addedInput schema / properties / make_dirs / description
      Added value: +"create missing parent folders (default false)"
    • addedInput schema / properties / mode / description
      Added value: +"create (default) refuses an existing file; overwrite replaces it; append adds to its end"
    • addedInput schema / properties / path / description
      Added value: +"the file: absolute, ~/..., or relative to the home folder"
  2. First observedv0.7.1

TDQS

A4.3/5.0
Behavior5/5

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

Beyond destructiveHint=true, it discloses that create mode refuses an existing file, that overwrite is atomic and preserves permissions, and it enumerates the fence categories that will be refused (shell rc files, LaunchAgents, .git hooks/config, editor tasks, MCP/Claude config, protected folders, anything outside home or temp). That is exactly the kind of failure-mode detail an agent needs before calling a destructive write.

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, both dense: the mode triage comes first, then the refusal fence. No filler, no restatement of the title, and the most decision-relevant information (mode defaults, refusal conditions) is front-loaded.

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 destructive five-parameter write tool with no output schema, the description covers modes, path scoping, and refusal conditions well. The one gap is that it never says what a successful call returns or whether the result is verifiable, which matters given there is no output schema to fall back on.

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 100%, so the baseline is 3; the description still adds meaning the schema lacks, notably that overwrite is atomic and keeps permissions, where the schema only says "replaces it". It also implicitly constrains path to home/temp locations, reinforcing the schema's path description.

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 opens with a concrete verb+resource ("Write a text file") and immediately enumerates the three write modes, so the agent knows exactly what class of operation this is. It never names a sibling such as edit_file or read_file to delimit the boundary, so differentiation is left to inference from the verb.

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 gives clear when-to-use guidance at the mode level: create for new files, overwrite for replacement, append for adding to the end, including the default. What is absent is routing guidance against alternatives (e.g., use edit_file for partial edits) and any mention of when a write should be declined beyond the protected-path list.

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