get_vm
Retrieve the current status and configuration details of a virtual machine by providing its name.
Instructions
Get status and configuration of a VM by name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/mcp_utm/server.py:23-28 (handler)The MCP tool handler for 'get_vm'. Calls utm.get_vm_status() and utm.get_vm_config() and returns a combined dict with status and configuration.
@mcp.tool() def get_vm(name: str) -> dict: """Get status and configuration of a VM by name.""" status = utm.get_vm_status(name) config = utm.get_vm_config(name) return {"status": status, **config.to_dict()} - src/mcp_utm/applescript.py:166-176 (helper)Helper function get_vm_status() in applescript layer. Runs an AppleScript to get the VM's status by name.
def get_vm_status(name: str) -> str: """Get the status of a VM by name.""" _validate_vm_name(name) script = f''' tell application "UTM" set vm to virtual machine named "{_esc(name)}" return status of vm as text end tell ''' return _run(script) - src/mcp_utm/applescript.py:178-208 (helper)Helper function get_vm_config() in applescript layer. Runs an AppleScript to read the full VM configuration (name, memory, CPU, MAC, network mode) and returns a VMConfig dataclass.
def get_vm_config(name: str) -> VMConfig: """Read configuration of a VM.""" _validate_vm_name(name) script = f''' tell application "UTM" set vm to virtual machine named "{_esc(name)}" set conf to configuration of vm set vmName to name of conf set vmMem to memory of conf set vmCores to cpu cores of conf set nics to network interfaces of conf if (count of nics) > 0 then set nic to item 1 of nics set macAddr to address of nic set netMode to mode of nic as text else set macAddr to "" set netMode to "" end if return vmName & "||" & vmMem & "||" & vmCores & "||" & macAddr & "||" & netMode end tell ''' raw = _run(script) parts = raw.split("||") return VMConfig( name=parts[0] if len(parts) > 0 else "", memory=_parse_int(parts[1]) if len(parts) > 1 else 0, cpu_cores=_parse_int(parts[2]) if len(parts) > 2 else 0, mac_address=parts[3] if len(parts) > 3 else "", network_mode=parts[4] if len(parts) > 4 else "", ) - src/mcp_utm/server.py:23-28 (registration)Registration of 'get_vm' as an MCP tool via the @mcp.tool() decorator on the get_vm function.
@mcp.tool() def get_vm(name: str) -> dict: """Get status and configuration of a VM by name.""" status = utm.get_vm_status(name) config = utm.get_vm_config(name) return {"status": status, **config.to_dict()} - src/mcp_utm/server.py:23-28 (schema)Schema/interface of the 'get_vm' tool: accepts a string 'name' parameter and returns a dict with 'status' (string) plus all VMConfig fields (name, memory, cpu_cores, mac_address, network_mode).
@mcp.tool() def get_vm(name: str) -> dict: """Get status and configuration of a VM by name.""" status = utm.get_vm_status(name) config = utm.get_vm_config(name) return {"status": status, **config.to_dict()}