Back to Microsandbox

README

README.md

0.4.411.3 KB
Original Source
<div align="center"> <a href="./#gh-dark-mode-only" target="_blank" align="center">
</a>
</div> <div align="center"> <a href="./#gh-light-mode-only" target="_blank">
</a>
</div> <div align="center"><b>——&nbsp;&nbsp;&nbsp;every agent deserves its own computer&nbsp;&nbsp;&nbsp;——</b></div> <div align='center'> <a href="https://github.com/superradcompany/microsandbox/releases"></a> <a href="https://discord.gg/T95Y3XnEAK"></a> <a href="LICENSE"></a> </div>

Microsandbox spins up lightweight VMs in milliseconds from our SDKs. Runs locally on your machine. No server to set up. No lingering daemon. It is all embedded and rootless!

  • Hardware Isolation: Hardware-level isolation with microVM technology.
  • Instant Startup: Average boot times under 100 milliseconds.
  • Embeddable: Spawn VMs right within your code. No setup server. No long-running daemon.
  • Secrets That Can't Leak: Unexploitable secret keys that never enter the VM.
  • OCI Compatible: Runs standard container images from Docker Hub, GHCR, or any OCI registry.
  • Long-Running: Sandboxes can run in detached mode. Great for long-lived sessions.
  • Agent-Ready: Your agents can create their own sandboxes with our Agent Skills and MCP server.

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  Getting Started

  Install the SDK

sh
cargo add microsandbox    # 🦀 Rust
sh
uv add microsandbox       # 🐍 Python
sh
npm i microsandbox        # 🟦 TypeScript

  Install the CLI (Optional)

Boot a microVM in one command.

sh
npx microsandbox run debian

Or install the msb command globally:

sh
curl -fsSL https://install.microsandbox.dev | sh
sh
msb run debian

Requirements: Linux with KVM enabled, or macOS with Apple Silicon.

Warning: Microsandbox is still beta software. Expect breaking changes, missing features, and rough edges.

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  SDK

The SDK lets you create and control sandboxes directly from your application. Sandbox::builder("...").create() boots a microVM as a child process. No infrastructure required.

  Run Code in a Sandbox

rs
use microsandbox::Sandbox;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let sandbox = Sandbox::builder("my-sandbox")
        .image("python")
        .cpus(1)
        .memory(512)
        .create()
        .await?;

    let output = sandbox
        .exec("python", ["-c", "print('Hello from a microVM!')"])
        .await?;

    println!("{}", output.stdout()?);

    sandbox.stop_and_wait().await?;

    Ok(())
}
<details> <summary><b>&nbsp;Python Example →</b></summary>
python
import asyncio
from microsandbox import Sandbox

async def main():
    sandbox = await Sandbox.create(
        "my-sandbox",
        image="python",
        cpus=1,
        memory=512,
    )

    output = await sandbox.exec("python", ["-c", "print('Hello from a microVM!')"])

    print(output.stdout_text)

    await sandbox.stop_and_wait()

asyncio.run(main())
</details> <details> <summary><b>&nbsp;TypeScript Example →</b></summary>
typescript
import { Sandbox } from "microsandbox";

await using sandbox = await Sandbox.builder("my-sandbox")
  .image("python")
  .cpus(1)
  .memory(512)
  .create();

const output = await sandbox.exec("python", ["-c", "print('Hello from a microVM!')"]);

console.log(output.stdout());
</details>

The first call to create() pulls the image if it isn't cached locally, so it may take longer depending on your connection. Subsequent runs reuse the cache.

<a href="https://docs.microsandbox.dev/sdk/overview"></a>

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  CLI

The msb CLI provides a complete interface for managing sandboxes, images, and volumes.

  Run a Command

sh
msb run python -- python3 -c "print('Hello from a microVM!')"

  Named Sandboxes

sh
# Create and start a named sandbox
msb create --name my-app python
sh
# Execute commands
msb exec my-app -- python -c "import this"
msb exec my-app -- curl https://example.com
sh
# Lifecycle
msb stop my-app
msb start my-app
msb rm my-app

  Image Management

sh
msb pull python           # Pull an image
msb image ls              # List cached images
msb image rm python       # Remove an image

  Install & Uninstall Sandboxes

sh
msb install ubuntu               # Install ubuntu sandbox as 'ubuntu' command
ubuntu                           # Opens Ubuntu in a microVM
msb uninstall ubuntu             # Uninstall the ubuntu sandbox

  Status & Inspection

sh
msb ls                         # List all sandboxes
msb ps my-app                  # Show sandbox status
msb inspect my-app             # Detailed sandbox info
msb metrics my-app             # Live CPU/memory/network stats

[!TIP]

Run msb --tree to see all available commands and their options.

<a href="https://docs.microsandbox.dev/cli/overview"></a>

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  AI Agents

Give your AI agents the ability to create and manage their own sandboxes.

  Agent Skills

Teach any AI coding agent how to use microsandbox by installing the Agent Skills. Works with Claude Code, Cursor, Codex, Gemini CLI, GitHub Copilot, and more.

sh
npx skills add superradcompany/skills

  MCP Server

Connect any MCP-compatible agent to microsandbox with the MCP server. Provides structured tool calls for sandbox lifecycle, command execution, filesystem access, volumes, and monitoring.

sh
# Claude Code
claude mcp add --transport stdio microsandbox -- npx -y microsandbox-mcp

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  Documentation

For guides, API references, and examples, visit the microsandbox documentation.

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  Contributing

Interested in contributing to microsandbox? Check out our CONTRIBUTING.md for guidelines and DEVELOPMENT.md for build, test, and release instructions.

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  License

This project is licensed under the Apache License 2.0.

<a href="./#gh-dark-mode-only" target="_blank"></a><a href="./#gh-light-mode-only" target="_blank"></a>  Acknowledgements

Special thanks to all our contributors, testers, and community members who help make microsandbox better every day! We'd like to thank the following projects and communities that made microsandbox possible: libkrun and smoltcp

<div align='center'> <a href="https://www.ycombinator.com/"></a> </div>