Skip to main content
Glama

Create or overwrite a file

write_file
Destructive

Writes a complete text file and creates missing folders. Updates existing Overleaf docs in place with a live diff so collaborators keep their cursors; use for full-file replacements, not small edits.

Instructions

Writes the full content of a text file, creating it (and missing folders) if needed. Existing docs are updated in place via a minimal live diff, so collaborators keep their cursors. Prefer edit_file for small changes.

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
pathYesPath of the text file, e.g. "sections/intro.tex"; missing folders are created
contentYesThe complete new content of the file
projectNoProject name, id or Overleaf URL. May be omitted when exactly one project is pinned.
suggestNoRecord changes to an existing doc as tracked changes
overwriteNoSet false to refuse replacing an existing file (default true)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.1.4
    • addedInput schema / properties / content / description
      Added value: +"The complete new content of the file"
    • addedInput schema / properties / path / description
      Added value: +"Path of the text file, e.g. \"sections/intro.tex\"; missing folders are created"
  2. First observedv2.1.1

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already flag destructiveHint=true and openWorldHint=true, so the risk profile is declared. The description adds genuinely new behavior: existing documents are updated via a minimal live diff so collaborators keep their cursors, and missing folders are auto-created. It does not spell out what happens to prior content on a full overwrite, but nothing contradicts the annotations.

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?

Three short sentences, front-loaded with the core write behavior, then creation semantics, then the alternative-tool routing. Every sentence carries distinct information with no redundancy.

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 5-parameter mutation tool with no output schema, the description covers write scope, folder creation, collaborative in-place update, and the edit_file alternative. It omits whether any permission or project-pinning prerequisite applies beyond the schema note, and says nothing about the result of the write.

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 path, content, project, suggest, and overwrite are all already documented. The description reinforces path/creation behavior but adds no meaning for 'suggest' or 'project' beyond what the schema states, so the baseline 3 applies.

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?

States a specific verb (writes) plus resource (full content of a text file), and adds the creation semantics for the file and its parent folders. It explicitly contrasts itself with the sibling edit_file, so an agent can route between 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 clear routing rule: 'Prefer edit_file for small changes,' implying this tool is for whole-file writes. It does not address other plausible siblings such as upload_file or delete_file, and gives no exclusion for when overwriting an existing file is a bad idea.

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