Skip to main content
Each recipe shows the same task across all four ways to drive Nullspace. Pick the tab for your client; the rest of the docs use the same pattern.
MCP exposes every CLI command as a tool (nullspace sandbox createnullspace.sandbox.create), so a local coding agent runs these recipes by asking in natural language. See Local MCP to connect Codex, Claude Code, Cursor, or VS Code.

Create a sandbox

from nullspace import Sandbox

sandbox = Sandbox.create(template="base", timeout=300)
print(sandbox.id)

Run a command

result = sandbox.commands.run("echo hello && python3 --version", shell=True)
print(result.exit_code, result.stdout)

Read and write files

sandbox.files.write("/workspace/hello.txt", "hi\n")
print(sandbox.files.read("/workspace/hello.txt"))

Expose a preview URL

sandbox.commands.run(
    "cd /workspace && python3 -m http.server 8080 --bind 0.0.0.0",
    shell=True, background=True,
)
print(sandbox.get_url(8080))

Fork a running sandbox

child = sandbox.fork()
print(child.id)

Pause and resume

snapshot = sandbox.hibernate()          # pause, persist full state
sandbox = Sandbox.resume(snapshot.id)   # wake where it stopped

List and clean up

for s in Sandbox.list():
    print(s.id, s.status)
sandbox.kill()

Go deeper

Build a template

Capture dependencies once and start future sandboxes from a reusable template.

Mount a volume

Persist data independently of any one sandbox and mount it into many runs.

Run code interpreter

Stateful notebook-style cells, package installs, and rich results.

Run an agent

MCP, an in-sandbox coding-agent template, or a framework integration.