list_vms
List all registered UTM virtual machines and view their current status to manage virtual environments on macOS.
Instructions
List all registered UTM virtual machines with their status.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/mcp_utm/server.py:17-18 (registration)The MCP tool 'list_vms' is registered as a FastMCP tool via the @mcp.tool() decorator.
@mcp.tool() def list_vms() -> list[dict]: - src/mcp_utm/server.py:18-20 (handler)The MCP tool handler function that lists all registered UTM VMs by calling the AppleScript helper.
def list_vms() -> list[dict]: """List all registered UTM virtual machines with their status.""" return [vm.to_dict() for vm in utm.list_vms()] - src/mcp_utm/applescript.py:139-163 (helper)The AppleScript helper function that executes the osascript command to list all UTM virtual machines and parses the output into VMInfo objects.
def list_vms() -> list[VMInfo]: """List all registered UTM virtual machines.""" script = ''' tell application "UTM" set output to "" repeat with vm in virtual machines set vmId to id of vm set vmName to name of vm set vmStatus to status of vm as text set vmBackend to backend of vm as text set output to output & vmId & "||" & vmName & "||" & vmStatus & "||" & vmBackend & linefeed end repeat return output end tell ''' raw = _run(script) vms = [] for line in raw.strip().split("\n"): line = line.strip() if not line: continue parts = line.split("||") if len(parts) >= 4: vms.append(VMInfo(id=parts[0], name=parts[1], status=parts[2], backend=parts[3])) return vms - src/mcp_utm/applescript.py:96-104 (schema)The VMInfo dataclass representing the schema of a listed VM (id, name, status, backend) with a to_dict() method.
@dataclass class VMInfo: id: str name: str status: str backend: str def to_dict(self) -> dict: return {"id": self.id, "name": self.name, "status": self.status, "backend": self.backend}