unkernel-mcp
by xbtoshi
README.md
# unkernel-box
Instant, air-gapped **Linux-in-WebAssembly** sandbox wrapper around [`unkernel`](https://unkernel.dev/) (`pithings/unkernel`).
Ships as a **CLI (`unkernel-box`)**, a zero-dependency **MCP server (`unkernel-mcp`)**, and a tiny **ESM library** — booting a real Linux 7.x `aarch64` kernel in **~50 ms** with a RAM-only root filesystem.
## Security Defaults
- **Double isolation:** Guest Linux ELF binaries execute inside `kwemu` (software ARM64 CPU) inside a Linux kernel compiled to WebAssembly.
- **Air-gapped by default:** Zero network access unless `--net` or `--allow` is passed.
- **LAN / localhost SSRF guard:** Even with `--net`, connections to `127.0.0.0/8`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `169.254.0.0/16`, `100.64.0.0/10`, and `.local` are blocked and logged unless `--allow-lan` is explicitly set.
- **Ephemeral RAM root + audited `/sandbox`:** Every file injected via `--file` is copied into guest RAM (`MemoryFs`), all mutations are recorded, and everything disappears on exit.
## Requirements
- **Node.js >= 24** (WebAssembly JSPI support)
## Install
```bash
# Install globally from npm
npm install -g unkernel-box
# Or run directly without installing
npx unkernel-box run "uname -a"
```
## CLI Usage (`unkernel-box`)
```bash
# Instant air-gapped busybox Linux shell (<100ms, zero download)
unkernel-box shell
# Pre-cache Alpine or Debian once into ~/.cache/unkernel, then boot
unkernel-box fetch alpine
unkernel-box shell --alpine
# Copy an untrusted script/binary into guest RAM (/sandbox/<name>), run air-gapped, wipe on exit
unkernel-box run --file ~/Downloads/suspect.sh "sh /sandbox/suspect.sh"
# Mount a host directory strictly read-only at /work
unkernel-box run --alpine --ro . "ls -la /work"
# Allow outbound TCP ONLY to specific domains (blocks & logs everything else)
unkernel-box run --alpine --allow registry.npmjs.org "wget -qO- https://registry.npmjs.org"
# Structured JSON output (includes boot_ms, exec_ms, fs_changes, net_events)
unkernel-box run --json "uname -a && touch /sandbox/test.txt"
```
## MCP Server (`unkernel-mcp`)
Add to OpenCode (`~/.config/opencode/opencode.json`), Claude Desktop, or any stdio MCP client (zero-install via `npx`, or use `["unkernel-mcp"]` if installed globally):
```json
{
"mcp": {
"unkernel": {
"type": "local",
"command": ["npx", "-y", "-p", "unkernel-box", "unkernel-mcp"],
"timeout": 180000,
"enabled": true
}
}
}
```
Exposed tools:
- **`unkernel_exec`** — Ephemeral one-shot command run with optional inline `files`, `host_files`, `ro_mount`, `net`, and `allow_domains`.
- **`unkernel_session_start`** / **`unkernel_session_exec`** / **`unkernel_session_stop`** — Persistent in-memory VM sessions (RAM-only, wiped on stop).
## JS/TS Library Usage
```js
import { bootSandbox } from "unkernel-box";
const sb = await bootSandbox({
distro: "base", // or "alpine" | "debian"
files: { "hello.sh": "echo hi from $(uname -r)\n" },
});
const res = await sb.execCommand("sh /sandbox/hello.sh");
console.log(res.stdout, sb.fsEvents);
await sb.stop();
```
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues