Skip to main content
Glama

Write a file in a sandbox

write_file
Idempotent

Writes content to a file on a sandbox disk, waiting for the sandbox to become ready before saving and confirming success only after the file is stored.

Instructions

Write a file in a sandbox. Files up to 5 MiB after decoding. For a larger file, use POST /sandboxes/{sandboxId}/files/upload-url. On a sandbox that is still starting, the call waits until it is ready (up to 60 s, like a command): a sandbox's files are in place only once it is ready, so a write any earlier would not stay. A 200 always means the file is on the sandbox's disk.

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": {
      "sandboxId": "<sandboxId>",
      "path": "<path>",
      "content": "<content>"
    },
    "name": "write_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesAbsolute path, or path relative to the sandbox work directory (/home/user). The canonicalized path must resolve under /home/user or /tmp; anything else is rejected with a 400 invalid_path error.
contentYes
encodingNoutf8
sandboxIdYesPublic Sandbox id returned by create/list/get sandbox calls.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.0

TDQS

A4.1/5.0
Behavior4/5

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

With annotations already declaring readOnlyHint=false, idempotentHint=true, and destructiveHint=false, the description adds real value: the 5 MiB post-decoding limit, the up-to-60 s wait on a starting sandbox, and the guarantee that a 200 means the file is on disk. It stops short of stating what happens when the target path already exists (overwrite/truncate), which is the most important undisclosed behavior for a write tool marked idempotent.

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?

The size limit and the alternative endpoint are front-loaded, which is the right priority. The sandbox-readiness explanation repeats itself slightly ('the call waits until it is ready ... a write any earlier would not stay'), costing a few words without adding information.

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 four-parameter mutation tool with no output schema, it covers the limit, the readiness wait, and the meaning of a 200 response, which is enough for an agent to invoke it correctly. It omits overwrite semantics for an existing path, the one behavior an agent would still have to guess at.

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 50%: path and sandboxId are documented in the schema, while content and encoding are bare. The phrase 'after decoding' hints that content may be base64 and ties to the encoding enum, but the description never explains the content/encoding relationship or whether content is raw bytes. It adds marginal meaning over the schema rather than compensating for the coverage 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?

The opening sentence gives a specific verb plus resource (write a file) and scopes it to a sandbox, which separates it from read_file, delete_file, and the sandbox-lifecycle siblings. It also immediately names the large-file escape hatch (upload-url), so an agent knows the boundary of this tool's applicability.

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?

It gives clear conditional routing: use this tool for files up to 5 MiB, use POST /sandboxes/{sandboxId}/files/upload-url beyond that. It also warns that calling while the sandbox is starting blocks up to 60 s. The only gap is that it does not contrast with in-place mutation siblings such as replace_in_files, but the guidance for size and readiness is explicit.

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