teg
Provides tools for building network labs on a libvirt/QEMU/KVM host: creating, starting, stopping and removing QEMU/KVM VMs, and creating, attaching, detaching and listing isolated point-to-point networks.
Allows creating Ubuntu 24.04 cloud-init VMs with SSH key injection, and showing the VM's IP address and SSH connection command.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
teg
teg (test env generator) builds network labs on a libvirt/QEMU/KVM host: Juniper vSRX and vMX, FortiGate and Ubuntu VMs, linked by isolated point-to-point networks. Use it from the command line, or let Claude Code (or any MCP client) drive it through teg's MCP server.
Prerequisites
libvirt with QEMU/KVM, and
genisoimage(for cloud-init VMs)Your user in the
libvirtgroup. teg does everything through libvirt, so it never needs sudo.Python 3.10+, plus
libvirt-devandpkg-config(libvirt-pythonbuilds from source)Base images in a libvirt storage pool (see Base images)
Note: teg does not ship any images. Names such as
default_srx.qcow2anddefault_switch.qcow2are not vendor files: they are ordinary vendor images (e.g.junos-media-vsrx-x86-64-vmdisk-20.4R3.8.qcow2) that you prepare once with a minimal starting config and save under that name. See Base images.
Related MCP server: gns3-mcp
Installation
Install a tagged release (replace vX.Y.Z with a tag from Releases):
uv tool install git+https://github.com/Jitter00/teg@vX.Y.Z
# or: pipx install git+https://github.com/Jitter00/teg@vX.Y.ZEither command puts teg in ~/.local/bin, which is on your PATH.
From a clone, for development:
uv tool install --editable . # `teg` on your PATH; code changes take effect immediately
uv sync # .venv with teg and the dev tools, for `uv run pytest` etc.Use with Claude Code
The repository is also a Claude Code plugin marketplace. With teg installed (above), in Claude Code:
/plugin install teg --marketplace Jitter00/teg(or /plugin marketplace add Jitter00/teg, then /plugin install teg@teg). The plugin brings:
MCP server (
teg mcp): tools to list, create, start, stop and remove VMs and lab networks, and to attach and detach links. Deliberately narrower than the CLI: no file-path parameters,stop_vmneeds explicit names, andremove_vmonly removes VMs teg created.Skill
teg-lab: how to plan a topology, interface order per platform, memory limits.Hooks: removing a VM or network always asks you first, naming what will be deleted; every change is logged to
~/.local/state/teg/audit.log.
Then ask, for example: "Build two vSRX connected by one link, plus an Ubuntu host behind the first."
Other MCP clients can run the server directly with the command teg mcp (stdio).
Security
Access to libvirt is root-equivalent. With
qemu:///system, being in thelibvirtgroup lets you (and anything running as you, includingteg mcp) define VMs that mount any host file or device. Only add users you'd trust with root, and run teg on a lab host, not on a machine holding data you care about.The MCP server is narrower than the CLI, not a sandbox. It has no file-path parameters, only attaches VMs to
defaultandp2p_<n>networks, andremove_vmrefuses VMs without teg's metadata.start_vm,stop_vm,attach_networkanddetach_networkwork on any VM on the host. teg's metadata guards against mistakes, not against someone with libvirt access, who can add it to any VM.Ubuntu VMs give your user passwordless sudo. The cloud-init template locks the password, disables SSH password login and adds only your public key. Use
--user-datafor anything stricter.Guest output is untrusted. Addresses and other values that come from guests are reported as data; the MCP server tells clients not to treat them as instructions.
To report a vulnerability, see SECURITY.md.
Base images
VMs are thin qcow2 overlays on base images kept in a libvirt storage pool (by default the pool
default, usually /var/lib/libvirt/images/):
Device type | Base image | Specs |
|
| Juniper vSRX: 4 GB RAM, 2 vCPUs, virtio NICs |
|
| Juniper vMX (EVPN/VXLAN): 16 GB RAM, 4 vCPUs, virtio NICs |
|
| FortiOS KVM image: 2 GB RAM, 1 vCPU, e1000 NICs |
|
| Ubuntu 24.04 cloud image: 2 GB RAM, 2 vCPUs, 20G disk, cloud-init |
Get the Juniper and FortiOS images from the vendor and the Ubuntu cloud image from
cloud-images.ubuntu.com, and copy them into the pool once (e.g. sudo cp ... /var/lib/libvirt/images/).
teg list_device_types shows which ones teg can find.
The default_* Juniper images are the vendor images plus a little initial config, so every VM
cloned from them is reachable straight away. To make one, boot the vendor image once (for
example junos-media-vsrx-x86-64-vmdisk-20.4R3.8.qcow2 for srx), set a root password, add your
SSH public key, commit, shut it down cleanly, and save the disk in the pool as
default_srx.qcow2 (likewise default_switch.qcow2 from the vMX image). An untouched vendor
image works too, but you then do that first-login setup on the console of every new VM. If you
would rather keep your own file names, map them under [images] in the
configuration.
Configuration
Optional, in ~/.config/teg/config.toml (or the file named by $TEG_CONFIG):
libvirt_uri = "qemu:///system" # $TEG_LIBVIRT_URI overrides it
storage_pool = "default"
[images] # device type -> base image volume in the pool
ubuntu24 = "noble-server-cloudimg-amd64.qcow2"Anything not set keeps the defaults shown above.
Creating VMs
teg create_vm srx1 --device-type srx
teg create_vm vmx1 --device-type switch
teg create_vm fw1 --device-type fortios
teg create_vm host1 --device-type ubuntu24VM names must be valid hostnames: 1-63 letters, digits and hyphens, starting and ending with a
letter or digit. The name becomes the guest's hostname and part of its disk volume's name.
create_vm checks the name, the networks, free memory and the base image before changing
anything, and cleans up after itself if a later step fails.
Ubuntu 24.04 (cloud-init)
No installer runs. teg builds a cloud-init NoCloud seed (<name>-seed.iso in the pool) from
teg/cloud-init/user-data. It creates a user named after you, with passwordless sudo and your SSH
public key (~/.ssh/id_ed25519.pub, falling back to ~/.ssh/id_rsa.pub). Once it has booted:
teg show_vm host1 # shows the IP address and the ssh commandOptions: --ssh-key PATH picks another public key; --user-data PATH uses your own template, in
which ${hostname}, ${username} and ${ssh_key} are replaced.
Networks
Every VM's first interface is on libvirt's default network (NAT, DHCP, management). Links between
VMs are isolated point-to-point networks, p2p_1, p2p_2, ...:
teg create_p2p_network --count 2 # --reuse: hand out unused p2p networks first
teg create_vm srx1 --device-type srx --networks p2p_1 p2p_2
teg create_vm srx2 --device-type srx --networks p2p_1
teg list_lab_networks # which VMs are on which networkInterface order follows the network order: on vSRX, fxp0 is default, then ge-0/0/0,
ge-0/0/1, ...
Changing the links of an existing VM:
teg attach_network srx2 p2p_2 # add as the next interface
teg detach_network srx2 p2p_1
teg update_networks srx1 --networks p2p_2 p2p_1 # set all links at once, in this order
teg remove_p2p_network p2p_2 # refused while a VM still uses itattach_network and detach_network change the VM's definition; a running VM picks the change
up on its next start (--restart restarts it now). update_networks restarts a running VM.
VM lifecycle
teg list_vms
teg start_vm srx1 vmx1
teg stop_vm srx1 # graceful shutdown, forced off after 60 s
teg stop_vm # all running VMs
teg start_vm 'vsrx*' # start, stop and remove accept glob patterns
teg remove_vm srx1 # stop, undefine, delete its disk and seed volumes
teg remove_vm 'vsrx*' # every VM whose name matches the glob patternremove_vm lists the volumes it will delete and asks first (-y skips the prompt). It only deletes
volumes directly in the storage pool that belong to that VM, never base images or another VM's files.
start_vm, stop_vm and remove_vm accept glob patterns (*, ?, [...]) and mix them freely
with plain names. Quote patterns so the shell does not expand them against files in the current
directory. A pattern matches any VM on the libvirt host, not only those teg created; remove_vm
shows the VMs it expanded to in its prompt, so read the list before confirming.
Command reference
teg --version
teg [--json] list_vms
teg [--json] show_vm <name>
teg [--json] list_device_types
teg create_vm <name> [--device-type srx|switch|fortios|ubuntu24] [--networks NET ...] [--ssh-key PATH] [--user-data PATH]
teg start_vm <name|pattern> [name|pattern ...]
teg stop_vm [name|pattern ...]
teg remove_vm <name|pattern> [name|pattern ...] [-y]
teg list_networks <name>
teg update_networks <name> [--networks NET ...]
teg attach_network <name> <network> [--restart]
teg detach_network <name> <network> [--restart]
teg create_p2p_network [--count N] [--reuse]
teg remove_p2p_network <network> [network ...]
teg [--json] list_lab_networks
teg mcp # MCP server on stdio--json prints machine-readable output for any command.
Development
uv run pytest # tests (use libvirt's test driver, no KVM needed)
uv run ruff check . && uv run ruff format . # lint and format
claude plugin validate ./plugin # the Claude Code pluginWork happens in branches and pull requests; the PR title decides the next version. See CONTRIBUTING.md. Planned work: TODO.md and PLAN.md.
License
MIT, see LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Provides capabilities that let LLM agents perform a range of infrastructure management tasks.
Linux VMs for AI agents: create VMs, run commands, edit files and open preview URLs.
Manage Vozora VPS servers, SSH keys, firewalls, DNS and usage from an AI agent.
Real Linux labs your AI agent deploys, routes and runs, with domains, TLS, DBs and an audit log.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI models to securely query and manage virtual machines and virtualized resources via the libvirt API through the Model Context Protocol.1MIT
- AlicenseCqualityCmaintenanceEnables AI agents to control GNS3 network emulation labs. Supports building topologies, managing devices, capturing packets, and automating device CLIs.1002MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to manage virtual machines via natural language, including creating, editing, and VNC control.15 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to control and automate Incus/QEMU virtual machines via SSH, supporting mouse/keyboard, screenshots, commands, and lifecycle management.MIT