Skip to main content
Glama

craftos_write_file

Destructive

Write or overwrite a Lua/text file in the workspace, creating missing folders. Use it to prepare scripts and configs for ComputerCraft programs while rejecting paths outside the workspace.

Instructions

Write a Lua/text file in the workspace, replacing any file already there and making missing folders. The workspace is copied to the root of every computer a session starts, so paths match a real deployment. Paths that leave the workspace are refused.

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": "craftos_write_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesWorkspace-relative path with forward slashes, e.g. "startup.lua".
contentYesThe whole file's new text.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.7.1
    • addedInput schema / properties / content / description
      Added value: +"The whole file's new text."
    • addedInput schema / properties / path / description
      Added value: +"Workspace-relative path with forward slashes, e.g. \"startup.lua\"."
  2. First observedv0.7.0

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare destructiveHint=true and openWorldHint=false, so the bar is lower, but the description still adds real value beyond them: it specifies that existing files are replaced wholesale, that missing parent folders are created, and that paths escaping the workspace are refused — a sandbox boundary the annotations do not express. It does not describe the return value or any error signaling, which keeps it from a 5.

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?

Three sentences, each carrying distinct information, with the primary action and its destructive overwrite behavior front-loaded. The middle sentence on workspace copying is slightly indirect context but still earns its place by explaining path semantics.

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 two-parameter mutation tool with no output schema, the description covers overwrite risk, directory creation, path scoping, and the sandbox refusal rule. The only meaningful gap is what the call returns or how failures surface, which matters somewhat given there is no output schema to consult.

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 baseline is 3, but the description adds semantics the schema does not: 'replacing any file already there' tells the agent that content is a whole-file replacement rather than an append, and 'paths that leave the workspace are refused' adds a hard constraint on the path parameter beyond the schema's format note.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb and resource ('Write a Lua/text file in the workspace') and immediately clarifies the two most consequential behaviors: full overwrite of an existing file and auto-creation of missing directories. It is distinguishable from craftos_read_file and craftos_list_files by verb alone, though it never names a sibling explicitly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The middle sentence implies why an agent would use this (the workspace is copied to the root of every computer a session starts, so writes persist into the simulated deployment), which is useful context for choosing this over runtime commands like craftos_script or craftos_run. However, there is no explicit when-to-use/when-not guidance and no named alternative for cases where the agent should not write.

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