Skip to main content
Glama

Write a whole file

write_file
DestructiveIdempotent

Create or overwrite a complete file in an Overleaf project's local clone, adding missing parent directories; optionally guard overwrites with an expected revision.

Instructions

Write a whole file: create it, with any missing parent directories, or overwrite it entirely. Use it to add a new file; for an existing one prefer replace_text or edit_section, which cannot drop text you did not mean to rewrite. content is written exactly as given, as UTF-8, with no trailing newline added. expectedRevision makes the call a guarded overwrite, refused if the file changed since that read or no longer exists, so leave it out when creating a file. path must be relative and stay inside the project; absolute paths, .. escapes and the .git directory are refused. Pulls from Overleaf first, then writes only the local clone; push_changes publishes it. Returns whether the file was created or overwritten.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath relative to the project root, e.g. sections/related-work.tex. Must stay inside the project.
contentYesThe complete new contents of the file, not a fragment to append.
projectNoWhich project to use: its Overleaf address, its 24-character id, or a registered project name. Omit to use the default project.
expectedRevisionNoOptional guard: the 64-character revision hash returned by read_file with mode=full or mode=smart for this same file. When given, the edit is refused if the file changed since that read — for example because pulling from Overleaf brought in a collaborator's version. Pass it whenever the edit depends on content you read earlier.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.8

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already declare destructiveHint/openWorldHint/idempotentHint, but the description adds substantial non-obvious behavior: UTF-8 with no trailing newline added, exact-as-given content, path guards (absolute, .. escapes, .git refused), the Overleaf-pull-then-local-write ordering, and that the guarded overwrite is refused if the file changed or vanished. This is the kind of context an agent cannot get from 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?

A single dense paragraph, front-loaded with the operation and its two modes, then routing, then behavioral caveats. Every sentence carries information; nothing is padding or restated boilerplate.

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

Completeness5/5

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

No output schema exists, and the description compensates by stating the return value ('whether the file was created or overwritten'). Combined with the write semantics, path restrictions, and sync ordering, an agent has everything needed to call this correctly.

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 100%, so the schema already documents all four parameters, and the description largely mirrors it for path and content. It does add meaning beyond the schema for expectedRevision — tying it to the Overleaf pull and stating when to omit it — which is genuinely useful call-selection guidance.

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+resource (write a whole file) plus the two modes it covers: create with missing parents, or full overwrite. It explicitly names the sibling operations to prefer for existing files (replace_text, edit_section), so an agent can distinguish it without opening any schema.

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 when-to-use ('add a new file') and when-not ('for an existing one prefer replace_text or edit_section, which cannot drop text you did not mean to rewrite'), plus the condition for including expectedRevision ('leave it out when creating a file') and a follow-up routing hint to push_changes.

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