# headless browser linux & webmcp custom ui

- Status: `experiment`
- Track: [browser-delivered vms & container fabrics](https://aifoc.us/labs/browser-delivered-vms/)
- Layer: 10. Browser-Delivered VMs & Container Fabrics
- Updated: 2 December 2026
- Live demo: https://unkernel-headless-webmcp-ui.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/unkernel-headless-webmcp-ui

## Inspired by

- [on-device ai needs a trust model](https://aifoc.us/on-device/)
- [my chrome extensions are just prompts](https://aifoc.us/my-chrome-extensions-are-just-prompts/)

## Why this matters

Compiling a real Linux 7.x kernel to WebAssembly via [Unkernel](https://unkernel.dev/) and [WebAssembly JSPI](https://github.com/WebAssembly/js-promise-integration) lets a static web page execute standard POSIX binaries locally—yet most demos stop at an `xterm.js` terminal window. Terminals force both people and language models to parse unstructured text, ANSI sequences, and fragile column spacing. This lab tests running Linux 7.x headlessly inside a Dedicated Worker behind purpose-built web cards and typed [WebMCP](https://github.com/webmachinelearning/webmcp) tools.

## What this opens up

Static browser apps that run real Linux utilities (`awk`, `grep`, loopback HTTP servers, and kernel memory checkpoints) over an in-memory 9p workspace (`/work`) with zero server compute, zero external guest network sockets, and deterministic JSON tool surfaces for browser agents.

## How the tests work

1. Wait for auto-boot (or click **Boot / Reboot Linux 7.x VM**) to load `unkernel.wasm` inside `public/vm-worker.js` (`memoryMiB: 112`, `jit: true`, external `net` omitted) and mount a reactive 9p `MemoryFs` at `/work`.
2. Edit `sales-q4.csv`, `notes.md`, `config.json`, or `site/index.html` in the **Reactive 9p File Explorer** and watch `mem.onChange()` events update the workspace while real BusyBox `awk` and `grep` cards recalculate locally.
3. Click **Start & Fetch Loopback Site** to run a BusyBox loopback HTTP server on guest port `8080` serving `/work/site` and fetch `http://localhost:8080/` over vsock (`vm.fetch()`) with zero external sockets.
4. Click **Run Side-by-Side Comparison** to measure exact wire bytes, parse stability, and real `vm.exec()` latency between structured WebMCP JSON and raw shell table stdout, then run **Checkpoint -> Mutate -> Restore** to verify `vm.snapshot()` kernel RAM rollback.
5. Invoke any of the five registered WebMCP tools directly or connect an optional client-side LLM via [Port Authority AI Router](https://port-authority.dev/ai-router/) (`https://llmchannel.dev/router.js`), Chrome Built-in `LanguageModel`, or local Ollama.


## Hypothesis

- **Claim:** Running a full Linux 7.x kernel headlessly inside a Dedicated Worker behind a reactive 9p `MemoryFs` and typed WebMCP JSON tools removes terminal scraping fragility while keeping real POSIX execution latency in the tens of milliseconds with zero external network exposure.
- **Confirms it:** BusyBox `awk`, `grep`, vsock loopback `vm.fetch("http://localhost:8080/")`, `mem.onChange()` live file sync, and `vm.snapshot()` / `createKernel({ restore })` all execute cleanly inside the browser worker while returning schema-validated JSON with zero banner or column-parsing noise.
- **Bounds or disproves it:** Dedicated Worker boot time, 12.2 MiB `unkernel.wasm` delivery, or JSPI browser support limitations prevent the headless UI from responding faster and more reliably than a terminal wrapper or server-backed API.


## Under the hood

[Headless Browser Linux & WebMCP Custom UI](https://unkernel-headless-webmcp-ui.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/unkernel-headless-webmcp-ui)) boots `unkernel@0.3.0-261202-b033dc7` inside a module Dedicated Worker (`public/vm-worker.js`) importing `/vendor/unkernel/0.3.0-261202-b033dc7/web.mjs` with `memoryMiB: 112`, `jit: true`, and no external network device (`net` omitted). The 12.2 MiB `unkernel.wasm` binary is copied at build time by `scripts/copy-unkernel.mjs` into `public/vendor/` (gitignored) and served directly by Cloudflare Static Assets with `Cache-Control: public, max-age=31536000, immutable`.

Instead of presenting a terminal emulator, the worker mounts an in-memory 9p `MemoryFs` at `/work` seeded with `sales-q4.csv`, `notes.md`, `site/index.html`, and `config.json`, subscribes to `mem.onChange()` to push live guest write notifications to the main thread, and exposes structured RPC methods backed by real BusyBox utilities (`vm.exec("awk", ...)`, `vm.exec("grep", ...)`, loopback HTTP fetched via `vm.fetch("http://localhost:8080/")`, and `vm.snapshot()` / `createKernel({ restore })`). The main thread (`public/app.js`) registers five typed tools (`list_workspace_files`, `analyze_csv_with_awk`, `search_project`, `preview_guest_http`, and `checkpoint_and_restore`) via `navigator.modelContext?.registerTool` with an automatic local fallback registry, lets users inspect real Linux `uname -a` output in an optional collapsible console peek, and compares WebMCP JSON payloads directly against human-formatted shell stdout on the same query.


## Key terms & further reading

- [Unkernel (Linux 7.x in WebAssembly)](https://unkernel.dev/) — A Linux 7.x kernel compiled to WebAssembly with an embedded BusyBox initramfs, vsock transport, 9p host file mounts, and live memory snapshots.
- [WebAssembly JSPI (JavaScript Promise Integration)](https://github.com/WebAssembly/js-promise-integration) — Standard WebAssembly extension (`WebAssembly.Suspending`) that allows compiled kernel code to suspend on async host operations and resume cleanly.
- [WebMCP (navigator.modelContext)](https://github.com/webmachinelearning/webmcp) — Browser specification for registering typed JSON-schema tools (`registerTool`) on a web page so agents invoke structured capabilities instead of scraping UI or terminal text.
- [9p MemoryFs & Dedicated Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) — Runs the Linux VM off the main UI thread while mounting a host JavaScript file tree at `/work` with live `onChange()` callbacks whenever the guest modifies files.
- [Port Authority AI Router](https://port-authority.dev/ai-router/) — Optional client-side `MessagePort` router (`https://llmchannel.dev/router.js`) allowing users to connect their own LLM provider to drive WebMCP tools with zero server-held keys.

## Open questions to iterate on

- How does `unkernel.wasm` cold-start latency scale when paired with persistent OPFS block overlays across repeat page visits?
- Which subset of POSIX utilities should remain hidden behind typed WebMCP tools versus exposed directly when an agent hits an unanticipated edge case?

## Iteration log

- **2026-12-02:** Initial deployment on `unkernel@0.3.0-261202-b033dc7` (Linux 7.3.4+): headless Dedicated Worker runtime, reactive `/work` 9p `MemoryFs` explorer, BusyBox `awk` CSV analytics, BusyBox `grep` project search, vsock loopback HTTP preview via `vm.fetch()`, 5-tool WebMCP surface with optional Port Authority / Chrome Built-in AI / Ollama runner, structured-vs-raw comparator, and `vm.snapshot()` checkpoint/restore.

## Primitives tested

- `Unkernel (Linux 7.x WASM)`
- `WebAssembly JSPI`
- `Dedicated Worker`
- `9p MemoryFs`
- `Vsock Loopback vm.fetch()`
- `WebMCP (navigator.modelContext)`
- `Kernel Snapshot & Restore`

## Connected labs in other tracks

- [webmcp intent registry lab](https://aifoc.us/labs/agent-bridges-and-discovery/webmcp-intent-registry-lab/) — Measures dynamic tool retrieval versus full `tools/list` token budgets across WebMCP sites.
- [browser ephemeral vm](https://aifoc.us/labs/browser-containment/browser-ephemeral-vm/) — Tests browser-side execution isolation and ephemeral teardown patterns.

---
Canonical: https://aifoc.us/labs/browser-delivered-vms/unkernel-headless-webmcp-ui/
