Skip to main content
Glama

vmac

Project VMs for headless macOS/iOS work. vmac reads a Dockerfile-style Vmacfile and builds a tart macOS VM from it. Each instruction is a cached layer (a copy-on-write tart clone), so a rebuild starts at the first changed step. It ships as a CLI and as an MCP server.

Install

npm i -g https://github.com/mnott/vmac/releases/latest/download/vmac.tgz

Update with pai update. Nothing is published to npmjs.com. Requires macOS, Node >= 18 and tart.

Related MCP server: AppleScript Automation MCP

Vmacfile reference

FROM vmac-base                  # an OCI image or a local VM; must be first, exactly once
CPU 6
MEMORY 16G                      # 16G or 8192M
RUN brew install swiftlint      # runs in the guest via `tart exec ... zsh -lc`
ENV DEVICE="iPhone 17"          # appended to ~/.zshenv in the guest
SHARE src /tmp/vmac/p/src ro    # host dir shared at /Volumes/My Shared Files/src
SHARE results /tmp/vmac/p/results rw
COPY tools/setup.sh /usr/local/bin/   # host file or directory into the guest; trailing / keeps the name
TASK test sh build.sh test {args}     # run with `vmac run test`
TASK shot screencapture -x {out}/screen.png

SECRET GH_TOKEN                 # env var injected at exec time from the host (name only, never a value)
RUN --key release:mnott/PAI npm i -g https://github.com/mnott/PAI/releases/latest/download/pai.tgz
  • RUN --key release:owner/repo resolves the latest release tag first (gh release view, falling back to the GitHub API; the build fails if it cannot) and hashes release:owner/repo@<tag> into the layer in addition to the instruction text: a new release rebuilds that layer and every later one, the same tag stays cached.

  • RUNTIME iOS [27.2] makes the build install that simulator runtime in the guest (xcodebuild -downloadPlatform) as a cached layer. Without the line, an Xcode project that targets iOS is detected and gets it automatically; vmac run re-checks (one simctl call) before every task.

  • vmac doctor prints the one fixing command under each warning (clickr permissions per running VM, bridge registration, stale vmac-base).

  • SECRET NAME declares an env var taken from the host environment, or from ~/.vmac/secrets.env (KEY=VALUE lines, mode 600 required). It is passed to every RUN and TASK on tart exec -i stdin and never written to the guest disk, a layer, the metadata or a hash; a SECRET line changes no hash. Build and run fail if a declared secret is missing. SECRET names and COPY sources that look like credential stores (~/.claude, ~/.ssh, ~/.aws, ~/.config/gh, Keychains, .netrc, id_rsa*, id_ed25519*, *.pem, *.p12) are refused.

  • # starts a comment line; a trailing \ continues a line.

  • {args} is replaced by the shell-quoted arguments of vmac run; {out} by the guest results directory (/Volumes/My Shared Files/results if a share results exists, else /tmp/vmac-out).

  • A layer is cached by a hash of its instruction, everything before it and (for COPY) the file contents. Layer VMs are named vmac-L-<hash>; the final VM is vmac-<project>. SHARE and TASK are metadata only.

Shares convention

Source and tools are mounted read-only. There is exactly one rw share (the io/results share): in/ is written by the host, out/ by the guest. vmac up, run and run --fresh refuse more than one rw share and name the offending ones.

Commands

vmac build [dir|base] [--project NAME]   build vmac-<project> (default project: dir name)
vmac list                                list vmac-* VMs with state
vmac run [--fresh] [--src DIR] <project> <task> [args...]
                                         sync checkout, run a project TASK, collect results
vmac run <task> [args...]                run a TASK from ./Vmacfile
vmac shot <vm> [name]                    screenshot VM screen + booted simulator
vmac exec <vm> -- <cmd...>               run a command in a VM
vmac up <vm> / vmac down <vm>            start headless / stop
vmac run --fresh <task> [args...]        run in a throwaway clone vmac-eph-<id>, deleted afterwards
vmac gc | reap                           delete stale vmac-eph-* VMs and unreferenced layers
vmac doctor                              one ok/warn line per check
vmac prune                               delete layer VMs no project references
vmac mcp                                 MCP stdio server

Running a project

vmac run <project> <task> takes the task, shares and secrets from the project's metadata. If the project has a SHARE src <path> ro, the checkout (--src DIR, default cwd) is first rsynced on the host into <src share>/<id>/ (id = first 8 hex of sha1 of the absolute dir; rsync -rlt --delete, excluding .git, node_modules, .build, DerivedData, *.xcresult and every pattern in an optional .vmacignore). The VM is never restarted; a running VM keeps its fixed shares.

Task placeholders: {args} quoted arguments, {out} guest path of the per-run folder results/<YYYYMMDD-HHMMSS> (when a results share exists), {src} guest path /Volumes/My Shared Files/src/<id>. The guest command also gets VMAC_SRC and VMAC_OUT. SHARE host paths may start with ~ or $HOME. After the task a best-effort simulator screenshot goes to simulator.png; result lines (Test Case ... passed|failed, TEST SUCCEEDED|FAILED, error:, ** BUILD ...) from *.log files and the file list are printed, with the host results path.

vmac build base builds vmac-base (node, PAI, AIBroker, Clickr, permission check) from the Vmacfile shipped in the package. State lives in ~/.vmac (override with VMAC_HOME).

Device Hub

So an operator watching the guest over Screen Sharing sees a simulator test live, vmac opens Device Hub (Xcode's simulator viewer) in the guest and selects the booted device with a small Swift Accessibility (AX) script run in the guest: no Automation prompt, no setup. Every guest step has a timeout. It is best effort: a failure prints one note and never fails up or run.

  • Runs after vmac up <vm> (when xcrun exists in the guest) and before a project task that mentions simctl, build.sh test or xcodebuild, or whose project has ENV VMAC_SIMULATOR=1 in its Vmacfile.

  • ENV VMAC_DEVICE=<name> in the Vmacfile picks the device; otherwise the first booted simulator is used.

  • vmac show <vm> [device] re-runs the selection by hand and prints whether it worked.

MCP bridge

vmac bridge <vm> <name> runs an allowlisted MCP server inside a guest VM and passes MCP stdio (newline-delimited JSON-RPC) through unchanged, via tart exec -i. The VM is started on demand (never restarted if running; shares come from its build metadata).

vmac mcp add pai-sim clickr -- /opt/homebrew/bin/node /opt/homebrew/lib/node_modules/@tekmidian/clickr/dist/index.js
vmac mcp list
vmac mcp register pai-sim clickr [--apply]   # prints (or runs) the registration
vmac mcp rm pai-sim clickr

register prints claude mcp add vmac-pai-sim-clickr -s user -- vmac bridge pai-sim clickr; --apply runs it through the claude binary. Plain vmac mcp still starts the vmac MCP server.

Allowlist: entries live in $VMAC_HOME/config.json (~/.vmac by default), keyed <vm>/<name>. A pair that is not listed never runs: every request gets a JSON-RPC error (-32000) naming the missing entry and the bridge exits 1. If the VM cannot start, or the guest server exits early, each pending request gets one -32000 error and the bridge exits 1; it never hangs. Lifecycle logs go to stderr only.

Trust: guest output is data. The bridge forwards it byte-for-byte and only reads response ids to track pending requests. The child tart process receives only PATH, HOME and TART_HOME from the host, so no credentials cross.

MCP tools

vmac mcp starts the vmac MCP server (stdio). Register it once:

claude mcp add vmac -s user -- vmac mcp

Tool

Input

Notes

vmac_list

none

vmac-* VMs with state

vmac_up

vm

starts headless, shares from build metadata; vm is vmac-* or a bare project name

vmac_down

vm

stops the VM

vmac_exec

vm, command, timeoutSec? (default 120, max 900), stdin?

returns {exit, stdout, stderr, timedOut}; each stream capped at 64 KB ([truncated N bytes]); on timeout the command is killed, exit 124

vmac_run

project, task, args?, fresh?, srcDir?

like vmac run; returns {exit, runName, outDir, lines, files, log}; srcDir must be an absolute existing directory

vmac_shot

vm, name?

text with paths plus PNG image content for screen.png and simulator.png (files over 4 MB are skipped)

vmac_doctor

none

`{ok, checks: ["ok

vmac_exec only accepts vmac-* VMs (never pai-sim or other VMs) and never starts a VM: if it is not running the call fails with VM x is not running (vmac_up first). Commands are not filtered; the guest is the sandbox. Bad input makes the tool return an error result with a message like vmac_x: 'name' must be a string.

Constraints

  • tart's licence is not OSI open source. Check its terms before use: free for individuals, organisations above a certain size need a licence.

  • Apple's macOS licence allows at most two macOS VMs running at once per Mac.

  • Cirrus images ship the account admin/admin. That is only acceptable for VMs reachable from the host alone. vmac never types it; everything goes through tart exec.

  • No VM restarts behind a running job: each VM has one fixed set of shares.

Licenses

vmac itself is MIT. It bundles neither tart nor any VM image; you install and license those yourself.

  • tart (Cirrus Labs) is not OSI open source; GitHub reports its license as NOASSERTION. Free use is limited: organisations above a size threshold need a paid licence. The exact threshold is UNVERIFIED here; read the current terms at https://github.com/cirruslabs/tart/blob/main/LICENSE and https://tart.run/licensing/ before using vmac in a company.

  • Apple: macOS may only be virtualised on Apple hardware, and at most two macOS VMs may run at once per Mac. vmac refuses to start a third (vmac doctor shows x/2).

  • Cirrus Labs images ship the account admin/admin; check the licence of the image you use (the Xcode images embed Apple's Xcode terms). Only use them for VMs reachable from the host alone.

License

MIT

Watching the VM

Whenever vmac starts a VM (vmac up, vmac run, vmac run --fresh, before the task), it opens a Screen Sharing window to it on the host (open vnc://<vm ip>), once per boot. If a Screen Sharing client is already connected to that address, nothing is opened. vmac down and the end of a --fresh run close only the window vmac opened for that VM.

  • On by default. Opt out per call with --no-watch, for a whole shell with VMAC_WATCH=0 (overnight runs), or permanently with "watch": false in $VMAC_HOME/config.json.

  • vmac never types or passes a password and the URL carries no user:pass. Screen Sharing asks you for the image login the first time; tick "Remember this password in my keychain" and macOS fills it in from then on.

  • Closing uses a System Events click on the window's close button, so it needs the Accessibility permission for the terminal; without it the window simply stays open.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers