directRunCode is the entire lifecycle in one call, which suits an ad-hoc calculation; anything with intermediate state goes through createSandbox and carries the sandbox_id from then on. Files cross the boundary explicitly in both directions, and a created sandbox pauses itself, with max_alive_time as the ceiling you set on how long it can come back.
A hosted Linux sandbox service with nine tools: create sandboxes, run code and commands inside them, move files in and out, and destroy them.
- directRunCode creating a sandbox, executing the code and destroying the sandbox in one call, optionally exporting what it produced — several files come back as a zip
- createSandbox returning the sandbox_id every later call carries, taking a name, environment variables, metadata and a max_alive_time
- runCode and runCommand executing inside a named sandbox with their own environment and timeout, returning text output only
- writeSandboxFiles importing files from public URLs or base64, creating missing directories and overwriting anything already there
- downloadSandboxFiles exporting a file or directory to downloadable URLs, in batches, covering common document, image, audio, video, archive, web and source formats when a directory is exported
- listSandboxFiles checking a path before a download, and listSandboxes showing what is currently alive under your key
- killSandbox destroying a sandbox by ID
A 302.AI key in 302AI_API_KEY — sandboxes are listed against that key, so it is also what scopes them. Anything that produces files needs the export tools as well: the run tools return text and nothing else.
One command plus a key — npx -y @302ai/sandbox-mcp, then supply credentials
