list_vms
List all UTM virtual machines on macOS and display their current status.
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/applescript.py:139-163 (handler)Actual implementation of list_vms — executes AppleScript to iterate UTM virtual machines, parsing output into VMInfo objects (id, name, status, backend). This is the core logic that queries UTM via osascript.
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)VMInfo dataclass — defines the data model returned by list_vms (id, name, status, backend fields with 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} - src/mcp_utm/server.py:17-20 (handler)MCP tool handler for list_vms — decorated with @mcp.tool(), delegates to applescript.list_vms() and converts results to dicts.
@mcp.tool() 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/server.py:17-20 (registration)Registration via @mcp.tool() decorator — registers 'list_vms' as an MCP tool on the FastMCP server instance.
@mcp.tool() def list_vms() -> list[dict]: """List all registered UTM virtual machines with their status.""" return [vm.to_dict() for vm in utm.list_vms()]