Skip to main content
Glama

Write or overwrite file

write_file
DestructiveIdempotent

Write or overwrite a file in the server's workspace. With project_id, path is resolved inside that project's folder; without it, path is relative to the server workspace root. Use encoding:"base64" to write binary content (e.g. a generated .xlsx); plain text mode assumes UTF-8 and will corrupt binary bytes. One call carries up to 512 KB of content; write anything larger in pieces, or fetch it on the server with exec. Writing a file does not serve it: a project's URL is answered by a running app, so after writing the files call start_app (a changed server needs start_app again to pick the change up).

Input Schema

NameRequiredDescriptionDefault
pathYesFile path, e.g. "public/index.html". Relative to the project folder when project_id is given, otherwise to the server workspace root.
contentYesThe file's full contents. Base64 encoded when encoding is base64.
encodingNoOptional, default "utf8". Set "base64" when content is base64-encoded binary data.
server_idYesThe server's id, as returned by create_server or list_servers.
project_idNoOptional. Resolve path inside this project's workspace folder instead of the server workspace root.

Output Schema

NameRequiredDescriptionDefault
pathYesThe path, as given.
writtenYestrue once the file is written.
encodingNoHow content was decoded.
project_idNoThe project the path was resolved in. null for the server workspace root.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Adds substantial context beyond annotations: the overwrite risk, the 512 KB per-call limit, encoding corruption warnings, and the non-obvious fact that writing does not serve a project until start_app runs. These behavioral traits are exactly what annotations cannot convey.

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?

Well front-loaded, with the core action first and constraints/follow-up after. It is fairly dense with several distinct clauses, but each sentence carries actionable information, so little is wasted.

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?

For a mutation tool with an output schema, the description covers the safety profile, size limits, encoding, path resolution and the start_app follow-up. Nothing an agent needs to call it correctly is 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 coverage is 100% so the schema already documents parameters, but the description adds value by explaining the binary-corruption rationale for base64 and path resolution relative to project vs workspace root. It reinforces and slightly exceeds the schema's own descriptions.

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 and resource ('Write or overwrite a file') and scopes it to the server's workspace, distinguishing it from read_file, delete_file and list_files. An agent can tell exactly what it does and its overwrite semantics without opening the 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?

Explicitly tells when to use base64 vs utf8, when to split large content (512 KB cap, or fetch via exec), and critically routes the agent to start_app after writing files. It names alternatives and the conditions that select them.

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.