CLI
Use the sandbox-sdk CLI to check provider setup with doctor, list providers and sandboxes, run commands, exec into existing sandboxes, and start an MCP server.
@opencoredev/sandbox-sdk ships a sandbox-sdk binary with zero extra dependencies. Use it to verify your local environment, run one-off sandbox commands, attach to running sandboxes, or start a stdio MCP server.
Run without installing
npx @opencoredev/sandbox-sdk doctor
Or install it in your project and run npx sandbox-sdk / bunx sandbox-sdk.
Commands
| Command | Purpose |
|---|---|
sandbox-sdk doctor |
Check Node/Bun version, host tar, Docker reachability, credentials, and optional peer SDKs |
sandbox-sdk providers |
List all built-in providers, peer packages, credential env vars, and readiness |
sandbox-sdk run [options] [--] <cmd...> |
Create a sandbox, run a command, stream output, and clean up |
sandbox-sdk exec [options] <id> [--] <cmd...> |
Connect to an existing sandbox by ID, run a command, and detach without destroying it |
sandbox-sdk list [options] |
List sandboxes created by Sandbox SDK on a provider |
sandbox-sdk mcp [options] |
Serve sandbox tools over MCP stdio (stdout stays protocol-only) |
Check your setup
sandbox-sdk doctor
sandbox-sdk doctor --provider e2b --json
sandbox-sdk providers --configured
doctor checks whether optional peer SDKs are resolvable without importing or executing them, recognizes alternative credential sets (such as Daytona’s DAYTONA_API_KEY or DAYTONA_JWT_TOKEN + DAYTONA_ORGANIZATION_ID), and never prints environment variable values. Pass --help after any command (sandbox-sdk run --help, sandbox-sdk mcp --help) for command-specific options. sandbox-sdk mcp handles SIGINT and SIGTERM cleanly even while stdin remains open, destroying ephemeral sandboxes before exit.
Run a command
Pass --provider <name> or set SANDBOX_PROVIDER:
sandbox-sdk run --provider memory "echo hello from sandbox"
sandbox-sdk run --provider e2b --network none -- node -e "console.log(1 + 1)"
Command quoting
- CLI options must appear before the command; everything after the first command word is passed to the command verbatim (so
sandbox-sdk run --provider memory node -vrunsnode -vwithout needing--). - A single positional argument is passed to the sandbox shell verbatim (
"echo hi && pwd"). - Multiple positional arguments are POSIX-quoted and joined (
-- node -e "console.log('a b')"), so spaces and shell metacharacters are preserved safely.
Passing secrets safely
The CLI refuses raw --secret KEY=VALUE flags because command-line arguments are exposed in process listings and shell history. Pass --secret-env NAME instead to read the secret from your host environment and redact it across stdout, stderr, JSON output, and errors:
GITHUB_TOKEN=ghp_example sandbox-sdk run \
--provider local \
--secret-env GITHUB_TOKEN \
"git ls-remote https://github.com/opencoredev/sandbox-sdk.git"
If NAME is unset or empty, the CLI exits immediately with code 2.
Lifecycle flags
- Without
--keyor--keep,rundestroys the sandbox when the command finishes. - With
--key <name>or--keep,runcallsclose(), leaves the sandbox running, and printsKept sandbox <id>to stderr in plain-text mode (or includessandboxIdin--json).mcp --keyandmcp --idalso printKept sandbox <id>to stderr while keeping stdout strictly JSON-RPC. exec <sandbox-id>always callsclose()and never destroys the target sandbox.memoryandagentosrun in-process, so separate CLI invocations cannot reattach to their sandboxes.
List and exec
sandbox-sdk list --provider e2b --label app=builder
sandbox-sdk exec --provider e2b sbx_12345 "ls -la"
Options by command
Global and discovery
--provider <name>(doctor,run,exec,list,mcp): provider name; falls back toSANDBOX_PROVIDERforrun,exec,list, andmcp(doctorchecks all providers when omitted).--json(doctor,providers,run,exec,list): print redacted machine-readable JSON (runandexecincludetimedOutandabortedbooleans).--configured(providers): show only providers whose credentials are configured.--label KEY=VALUE(list): filter sandboxes by label (repeatable).-v,--version(global): print the package version.-h,--help(global or per command): print top-level or command-specific help.
Execution and runtime options
--key <key>(run,mcp): get-or-create a keyed sandbox and leave it running on exit.--keep(run): callclose()instead ofdestroy()on exit.--network all|none(run,mcp): sandbox network policy (allby default; rejected with--idor when reusing an existing--keysandbox whose policy cannot be verified).--size small|medium|large(run): machine size preset.--cwd <dir>(run,exec): working directory inside the sandbox (/workspaceby default).--env KEY=VALUE(run,exec): environment variable passed to the sandbox or command (repeatable).--timeout-ms <ms>(run,exec,mcp): positive integer timeout in milliseconds (mcp: default timeout for theruntool).--secret-env NAME(run,exec,mcp): read a secret from host envNAMEand redact it across stdout, stderr, JSON, and errors (repeatable; raw--secretis rejected).
MCP server (mcp)
--id <sandbox-id>(mcp): attach to an existing sandbox instead of creating one (mutually exclusive with--key).--root <dir>(mcp): root directory for file tools (/workspaceby default).--allow <t1,t2>(mcp): comma-separated allowlist of MCP tool names.--deny <t1,t2>(mcp): comma-separated denylist of MCP tool names.
Exit codes
| Exit code | Meaning |
|---|---|
0 |
Command succeeded |
2 |
Invalid CLI usage, unknown flag/command, or missing required credentials / --secret-env for run, exec, list, or mcp |
1–255 |
Non-zero sandbox command exit (run/exec), SDK/provider error (1), output backpressure truncation (1), or failed doctor check (1, e.g. old runtime or --provider not ready) |
124 |
Sandbox command timed out |
130 |
Interrupted (SIGINT / SIGTERM) after sandbox cleanup (waits up to 30 s for any in-flight create to finish and destroy, warning on stderr if cleanup is unconfirmed; a second signal exits immediately) |
141 |
Output pipe closed while streaming (run/exec) |
For run and exec, the sandbox command’s own exit code (1–255) is returned directly and can overlap with 2, 124, or 141. Pass --json to inspect result.exitCode, result.timedOut, and result.aborted unambiguously.
Next: MCP integration or Sandbox API.