Skip to main content
Glama

write_file

Destructive

Create or replace a file; mode append adds to the end. .docx paths take Markdown; .xlsx/.xls/.xlsm take a JSON 2D array or an object of named sheets. The parent folder must exist (mode overwrite creates it). Rewrites are atomic. To change part of an existing file use edit_block; for PDFs use write_pdf. encoding base64 writes the decoded bytes as they are, for photos and other binary files (any extension); send a large one in parts with mode append, each part a multiple of 4 base64 characters, up to 20 MB. On Windows a rewrite may not keep the file's own permission entries or alternate data streams (such as the mark of a downloaded 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
modeNorewrite
pathYes
contentYes
deviceIdNoComputer name or id
encodingNoutf8
workSessionIdNoFrom create_work_session

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • removedInput schema / properties / content / maxLength
      Removed value: -2000000
    • changedInput schema / properties / deviceId / description
      Previous value: -"Computer name or id; optional with one computer or a default"New value: +"Computer name or id"
  2. Changed2 schema fields changed
    • changedInput schema / properties / deviceId / description
      Previous value: -"Computer name or id from list_devices. Optional with one computer online or a default set."New value: +"Computer name or id; optional with one computer or a default"
    • changedInput schema / properties / workSessionId / description
      Previous value: -"Work session from create_work_session. Pass the same ID on every call in this conversation; omit for legacy unscoped work."New value: +"From create_work_session"
  3. Changed1 schema field changed
    • addedInput schema / properties / encoding
      Added value: +{
      +  "default": "utf8",
      +  "enum": [
      +    "utf8",
      +    "base64"
      +  ],
      +  "type": "string"
      +}
  4. Changed1 schema field changed
    • addedInput schema / properties / workSessionId
      Added value: +{
      +  "description": "Work session from create_work_session. Pass the same ID on every call in this conversation; omit for legacy unscoped work.",
      +  "format": "uuid",
      +  "type": "string"
      +}
  5. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the annotations (destructiveHint=true, readOnlyHint=false) it discloses that rewrites are atomic, that the parent folder must exist except in overwrite mode, that append parts must be multiples of 4 base64 characters up to 20 MB, and the Windows caveat about lost permission entries and alternate data streams. These are exactly the side effects an agent needs before overwriting data.

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?

Core behavior is front-loaded in the first sentence, followed by format rules, then prerequisites/atomicity, then alternatives, then the binary/encoding details and edge cases. Dense but every sentence carries distinct operational information with no repetition.

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 six-parameter write tool with no output schema, it covers prerequisites, atomicity, size limits, binary handling, and platform caveats. It does not say what is returned or how failures are surfaced, but nothing needed to invoke it correctly appears to be missing.

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 description coverage is only 33%, so the description has to carry the load and mostly does: it explains mode's three values and their side effects, encoding's base64 behavior, and what content means per file extension. Path and the interaction of deviceId/workSessionId with target selection are left to the schema, which is a modest remaining gap.

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 and resource ('Create or replace a file') and immediately defines the mode variants, including that append adds to the end. It also names the siblings it is not for (edit_block for partial changes, write_pdf for PDFs), so an agent can pick it out of the file-manipulation set without opening schemas.

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?

Gives explicit routing rules: use edit_block to change part of an existing file, use write_pdf for PDFs, use encoding base64 with append for large binaries. The per-extension content rules (.docx Markdown, .xlsx JSON 2D array or named-sheet object) further constrain when this tool is the right one.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources