Skip to main content
Glama

Write File

write_file

Write text content to a file, choosing atomic replace or append mode to safely update project files.

Instructions

Write content to a file with atomic commit or append mode.

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
pathYesRelative or absolute path to the file.
appendNoIf True, appends to the file instead of overwriting.
atomicNoIf True, writes to a temp file and replaces atomically.
contentYesThe text content to write.

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.1.0
    • addedInput schema / properties / append
      Added value: +{
      +  "default": false,
      +  "description": "If True, appends to the file instead of overwriting.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / atomic
      Added value: +{
      +  "default": true,
      +  "description": "If True, writes to a temp file and replaces atomically.",
      +  "type": "boolean"
      +}
  2. First observedv2.0.0

TDQS

B3.1/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full behavioral burden. It mentions atomic commit and append mode, but does not warn that the default is destructive overwrite, nor does it describe permissions, encoding, or failure behavior for a mutation tool.

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?

A single front-loaded sentence with no wasted words. It identifies the action, resource, and two key modes immediately.

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

Completeness3/5

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

The tool is simple and has a complete schema plus an output schema, which lowers the description's burden. However, for an unannotated mutation tool, the missing overwrite-risk warning and sibling differentiation leave a meaningful gap.

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 four parameters clearly. The description mentions append and atomic modes but adds no syntax, defaults, or constraints beyond what the schema provides, so baseline 3 is appropriate.

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 states a specific verb and resource ("Write content to a file") and names the two write modes. It does not, however, distinguish this tool from close siblings like edit_file or batch_replace, which an agent must choose between.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this instead of edit_file, batch_replace, or read_file, and no mention of prerequisites or when not to use it. The only implied usage is that it writes whole content rather than editing.

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