Microsandbox
🧱 secure, local and programmable sandboxes for AI agents
Last verified:
What is Microsandbox?
Microsandbox is a self-hosted platform for secure execution of untrusted user or AI-generated code using hardware-level microVM isolation. It combines the strong security of traditional virtual machines with the speed and ease-of-use of Docker containers, enabling boot times under 200ms instead of 10+ seconds. The platform is built for AI agents, developers, and anyone who needs to execute code safely without compromising on speed or security.
Key features include VM-level isolation using libkrun (the same technology as Firecracker used by AWS Lambda), PythonSandbox and NodeSandbox types with pre-configured environments, SDKs for Python/JavaScript/Rust, MCP (Model Context Protocol) native support for seamless integration with Claude and other AI tools, state persistence between executions, package installation via pip/npm, file system access, shell command execution, and JSON-RPC API for programmatic control. The server runs locally by default on http://127.0.0.1:5555.
Microsandbox is ideal for building AI code execution platforms where assistants can safely run generated code, secure data analysis services for research institutions, interactive coding learning environments for education, CI/CD pipelines for isolated testing, web browsing agents, and instant app hosting for AI-generated demos. It supports macOS (Apple Silicon M1/M2/M3/M4 only) and Linux with KVM virtualization, with Windows support coming soon.
Microsandbox pricing
Pricing model: Freemium
Microsandbox is open source under Apache 2.0 license and self-hosted, meaning you run it on your own infrastructure with no subscription fees. The Python/JavaScript/Rust SDKs are free to install via pip/npm/cargo. The server runs locally on your machine with no cloud costs. You only pay for your own hardware resources (CPU, memory, storage) used by the microVMs. The project has raised $63M in Series B funding but the software itself is free.
Microsandbox pros
- Hardware-level VM isolation with microVMs for strong security
- Lightning-fast startup under 200ms vs 10+ seconds for traditional VMs
- Self-hosted with full control over your infrastructure
- MCP native support works with Claude and AI tools out of the box
- SDKs available for Python, JavaScript, and Rust
- PythonSandbox with full Python 3.x, pip, and data science libraries
- NodeSandbox with Node.js runtime, npm, and built-in modules
- Persistent state between executions within the same session
- OCI compatible works with standard container images
- File system access and shell command execution in sandboxes
- JSON-RPC 2.0 API for programmatic sandbox management
- Comprehensive error handling with has_error() and error() methods
- Metrics endpoint for CPU, memory, and disk usage monitoring
- Apache 2.0 license open source
- 3.9k GitHub stars with active community development
Microsandbox cons
- macOS requires Apple Silicon (M1/M2/M3/M4) Intel Macs not supported
- Windows support not yet available coming soon
- Linux requires KVM virtualization enabled
- First run takes longer to download base images
- No GUI passthrough support yet VNC only
- Networking is not where creator wants it yet inflexible
- No rate limiting currently implemented in API
- File streaming feature planned but not yet implemented
Frequently asked questions about Microsandbox
What is microsandbox and how does it work?
Microsandbox is a self-hosted platform for secure execution of untrusted code using microVMs powered by libkrun (the same Firecracker technology AWS uses for Lambda). It creates isolated hardware-virtualized environments that boot in under 200ms, combining VM-level security with container-like speed. You install the msb CLI, start the server, and use SDKs to create PythonSandbox or NodeSandbox environments where code runs completely isolated from your host system.
What programming languages are supported?
Microsandbox currently supports Python (PythonSandbox with full Python 3.x, pip, pandas, numpy, TensorFlow) and JavaScript/Node.js (NodeSandbox with Node.js runtime, npm, and built-in modules like fs, os, path). SDKs are available for Python, JavaScript, and Rust. The project has a contributors guide for adding support for new languages and language-specific sandboxes.
How do I install and get started?
Install using the script: curl -sSL https://get.microsandbox.dev | sh. Then start the server: msb server start --dev. Install the SDK for your language (pip install microsandbox, npm install microsandbox, or cargo add microsandbox). Create your first sandbox with PythonSandbox.create(name='demo') and execute code with sb.run('print(Hello)'). The server runs on http://127.0.0.1:5555 by default.
What operating systems are supported?
macOS requires Apple Silicon (M1/M2/M3/M4) - Intel-based Macs are not currently supported due to virtualization requirements. Linux requires KVM virtualization enabled (check with lsmod | grep kvm). Windows support is coming soon but not yet available. The server can run on any machine with these virtualization capabilities.
How does state persistence work?
Both PythonSandbox and NodeSandbox maintain state between executions within the same session. Variables and imports persist - if you run x = 42 then y = x * 2, the second execution knows about x. File changes and installations inside project sandboxes are automatically persisted to the ./menv directory, so stopping and restarting keeps your work. Temporary sandboxes discard all changes when exited.
Can I run AI-generated code safely?
Yes, that is the primary use case. Microsandbox is built for AI agents to safely execute generated code without compromising infrastructure. The MCP native server connects directly to Claude and other MCP-enabled AI tools. Your AI can run, test, and debug code in real-time in isolated microVMs. This is perfect for coding assistants, automated development workflows, and educational platforms where AI validates its own output.
How do I install packages in the sandbox?
In PythonSandbox, use await sb.run('pip install requests') to install packages from PyPI, then import and use them. In NodeSandbox, npm packages are installed similarly. The sandbox has full access to pip and npm package managers. You can install data science libraries like pandas, numpy, TensorFlow for Python, or any npm package for Node.js. Packages persist within the sandbox session.
What API does microsandbox use?
The main API uses JSON-RPC 2.0 over HTTP POST to /api/v1/rpc with Bearer token authentication. Available methods include sandbox.start, sandbox.stop, sandbox.repl.run (execute code), sandbox.command.run (execute shell commands), and sandbox.metrics.get (get CPU/memory/disk usage). The server also implements MCP (Model Context Protocol) with tools like sandbox_start, sandbox_stop, sandbox_run_code for AI integration.
How is microsandbox different from Docker containers?
Microsandbox uses hardware-level VM isolation instead of shared kernel containers, providing stronger security against sophisticated attacks that can break out of containers. It is like Docker for VMs - same ease of use but with true VM isolation. Traditional VMs take 10+ seconds to boot while microsandbox boots in under 200ms. It uses libkrun/Firecracker technology same as AWS Lambda and E2B.
What are common use cases for microsandbox?
Building AI code execution platforms where assistants safely run generated code, secure data analysis services for research institutions handling user datasets, interactive coding learning environments for bootcamps and online courses, CI/CD pipelines for isolated microservice testing, web browsing agents that scrape sites safely, instant app hosting for AI-generated demos and prototypes, and running untrusted code from GitHub repos or npm packages without risking your system.