mcqemu/README.md

2.0 KiB

mcqemu

An MCP server that lets LLM agents manage QEMU virtual machines: launch and stop VMs, inspect them over QMP, manage disk images with qemu-img, take live snapshots, and run commands inside guests through qemu-guest-agent.

Requirements

  • Linux with QEMU installed (qemu-system-* and qemu-img on PATH)
  • /dev/kvm access for hardware acceleration (optional — TCG emulation works without it, just slower)
  • Python 3.11+ managed with uv

Install

# From this checkout
uv sync

# Add to Claude Code
claude mcp add mcqemu -- uv run --directory /path/to/mcqemu mcqemu

What it can do

Group Tools
Lifecycle launch_vm, stop_vm, pause_vm, resume_vm, attach_vm, forget_vm
Inspect list_vms, vm_info
Live snapshots vm_snapshot_create / restore / delete / list
Disk images image_create, image_info, image_convert, image_resize, image_snapshot_*
Guest agent guest_ping, guest_info, guest_exec, guest_file_read, guest_file_write

VMs are daemonized QEMU processes with QMP control sockets, so they survive MCP server restarts. The registry lives in ~/.local/share/mcqemu/, sockets in $XDG_RUNTIME_DIR/mcqemu/.

Guest tools (guest_*) need qemu-guest-agent installed inside the guest OS; the host-side virtio-serial channel is wired on every launch, so installing the agent in the guest is the only step.

Quick start

image_create(path="~/vms/test.qcow2", size="10G")
launch_vm(name="test", disks=["~/vms/test.qcow2"], iso="~/isos/alpine.iso",
          port_forwards=["2222:22"])
# ... install the OS via the serial console log ...
stop_vm(name="test")
launch_vm(name="test", disks=["~/vms/test.qcow2"])
guest_exec(name="test", command="uname", args=["-a"])

Development

uv run pytest                  # unit tests (QMP and subprocess mocked)
uv run pytest -m integration   # boots a real tiny VM (needs QEMU installed)
uv run ruff check .