Skip to main content
Glama

write_file

Destructive

Create or overwrite text files within the filesystem base, automatically creating parent directories and validating PHP syntax before saving so broken content is rejected.

Instructions

Create or overwrite a text file (confined to the filesystem base). Parent directories are created as needed. For an existing .php file, prefer edit_file with a targeted old_string/new_string over retyping the whole file here — a full rewrite risks a transcription slip (e.g. an escaped bracket) that a partial edit can't introduce. Any .php content is syntax-checked before it touches disk; a broken write is rejected with the parse error instead of being saved, so this can't brick a live, always-loaded plugin file.

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
pathYes
contentYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.1.2

TDQS

A4.3/5.0
Behavior5/5

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

Goes well beyond the single destructiveHint=true annotation: parent directories are auto-created, writes are confined to the base, .php content is syntax-checked before hitting disk, and broken writes are rejected with the parse error rather than saved. That last point tells the agent exactly how failure manifests and why a bad write can't brick a live file.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Each sentence adds distinct information and the core scope statement is front-loaded. The .php guidance sentence is long with a parenthetical aside, but the detail is doing real work rather than padding.

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 two-parameter destructive write with no annotations beyond destructiveHint and no output schema, the definition covers scope, side effects (directory creation), safety checks, and failure mode. Only the return value and path-format expectations are left unstated, which is a minor 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 0%, so the description must carry the load. It clarifies that path is resolved against the filesystem base (an important semantic), but says nothing about acceptable path formats, absolute vs relative paths, or content encoding/overwrite-truncation behavior.

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?

Opens with a specific verb pair and resource ("Create or overwrite a text file") plus a scoping constraint ("confined to the filesystem base"). It explicitly distinguishes itself from edit_file, so an agent can separate the two without opening either schema.

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?

Gives a concrete when-not rule: for an existing .php file, prefer edit_file with targeted old_string/new_string, and explains the risk that motivates it. It does not address the sibling write_sandbox_file, so the alternative-routing is strong but not exhaustive.

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