Skip to main content
Glama
CodeSandbox MCP Server

CodeSandbox MCP Server

by techlibs

writeFile

Writes or creates a file in a CodeSandbox sandbox via a stateless per-call connection using sandboxId and sessionId, with encoding, create, and overwrite options.

Instructions

Write a file in the sandbox filesystem. Stateless: connects per call using sandboxId+sessionId.

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>",
      "sessionId": "<sessionId>",
      "path": "<path>",
      "content": "<content>"
    },
    "name": "writeFile"
  }
}

Input Schema

NameRequiredDescriptionDefault
envNoOptional environment variables if the session is created.
pathYesAbsolute path to the file in the sandbox.
createNoWhether to create the file if it does not exist. Defaults to true.
contentYesContent to write (encoded as per 'encoding').
encodingNoEncoding of 'content'. Defaults to 'utf8'.
overwriteNoWhether to overwrite an existing file. Defaults to true.
sandboxIdYesTarget sandbox ID to operate on.
sessionIdYesSession identifier to connect with. If missing in the sandbox, it will be created.
permissionNoOptional permission if session needs to be created. Must be 'write' to modify files if server is not read-only.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.1

TDQS

B3.3/5.0
Behavior3/5

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

Annotations declare readOnlyHint=false and destructiveHint=false, so safety is partially covered, and the description adds that connections are per-call and stateless using sandboxId+sessionId. However, for a mutation tool it omits whether writes are reversible, what happens when create/overwrite are false, or how failures surface. Note the destructiveHint=false claim sits awkwardly with a file-overwriting operation, though the description itself does not contradict it.

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?

Two short sentences, front-loaded with the action and followed by the one non-obvious operational detail. No filler or repetition of schema content.

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

Completeness3/5

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

The schema is rich and fully described, so parameter-level completeness is handled structurally. For a nine-parameter mutation tool with no output schema and only two annotations, the description is thin on failure modes and the interaction between create/overwrite/permission defaults, leaving meaningful gaps.

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 coverage is 100%, so all nine parameters including create, overwrite, encoding, and permission are already documented in the schema, establishing the baseline of 3. The description adds only the sandboxId+sessionId pairing behavior, which is genuinely beyond the schema but small relative to nine parameters.

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?

The description states a specific verb and resource ("Write a file in the sandbox filesystem"), which clearly distinguishes it from sibling readFile and readdir. It lacks any explicit naming of alternatives, but the write/read split is evident from the verb.

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

Usage Guidelines2/5

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

There is no when-to-use guidance, no prerequisites, and no guidance on choosing this over readFile or rename. The only usage-adjacent statement is the stateless connection note, which tells the agent nothing about when to select this tool.

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