Skip to main content
Glama

Run sandbox command

sandbox_exec
Destructive

Run shell commands as root inside an existing sandbox after user approval. Use ephemeral sandboxes because cancellation, timeout, or request failure deletes the sandbox and its files.

Instructions

Run a shell command inside an existing sandbox, as root. Requires the user's approval. Cancellation, timeout, or a failed command request destroys the whole sandbox and all its files to stop remote code. A nonzero command exit code preserves it. Use an ephemeral sandbox created for this task. Output is capped at 64 KiB per stream; do not blindly retry a failed command.

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>",
      "command": "<command>",
      "confirm": "<confirm>"
    },
    "name": "sandbox_exec"
  }
}

Input Schema

NameRequiredDescriptionDefault
cwdNo/workspace
envsNoEnvironment variables for this command only
commandYes
confirmYesUser approved the command and loss of sandbox files if cancellation, timeout, or request failure requires cleanup
sandboxIdYesExact sandbox ID from sandbox_create or sandbox_list
timeoutMsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.3
    • addedInput schema / properties / envs
      Added value: +{
      +  "additionalProperties": {
      +    "type": "string"
      +  },
      +  "description": "Environment variables for this command only",
      +  "propertyNames": {
      +    "pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
      +    "type": "string"
      +  },
      +  "type": "object"
      +}
  2. Addedv0.1.2

TDQS

A4.4/5.0
Behavior5/5

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

Goes well beyond the destructiveHint=true annotation by spelling out exactly what is destroyed (the whole sandbox and all its files), which triggers it (cancellation, timeout, failed request) versus which does not (a nonzero exit code), that approval is required, and the 64 KiB per-stream output cap. This is unusually complete disclosure for a destructive tool.

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?

Front-loads what the tool does, then each subsequent sentence carries a distinct load-bearing fact: approval, destruction rules, sandbox selection, output cap, retry caution. No filler or restatement of the title.

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 six-parameter destructive tool with no output schema, the description covers the critical risks and the output cap, which implies stdout/stderr streams. It leaves the return shape (exit code field, truncation indicator) and the cwd/envs parameters unaddressed, which is a modest but real gap.

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 50%, and the description compensates for confirm (approval implies sandbox loss) and timeoutMs (timeout destroys the sandbox), plus the sandboxId scoping via 'existing sandbox'. But cwd and envs — including the nested-object env var pattern constraints — get no mention in either the schema or the description.

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: run a shell command, as root, inside an *existing* sandbox. That scope wording separates it from sandbox_create and the file-oriented siblings (sandbox_read_file, sandbox_write_file) without the agent needing to open 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 Guidelines4/5

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

Gives a clear operating condition — 'Use an ephemeral sandbox created for this task' — and a caution against blind retries after failure. It stops short of explicitly naming which sibling to use for non-shell file operations or when a fork/snapshot is preferable, so alternatives are only implied.

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