delete_vm
Permanently removes a virtual machine from UTM. This action is irreversible and cannot be undone.
Instructions
Delete a VM permanently. Cannot be undone.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/mcp_utm/server.py:67-71 (handler)MCP tool handler for 'delete_vm' — the decorated function that registers the tool and executes the logic. Calls the AppleScript helper and returns a confirmation dict.
@mcp.tool() def delete_vm(name: str) -> dict: """Delete a VM permanently. Cannot be undone.""" utm.delete_vm(name) return {"name": name, "deleted": True} - src/mcp_utm/applescript.py:276-285 (helper)AppleScript helper that performs the actual VM deletion via osascript — validates the VM name, constructs and runs the 'delete virtual machine' AppleScript, and returns True on success.
def delete_vm(name: str) -> bool: """Delete a VM. Returns True on success.""" _validate_vm_name(name) script = f''' tell application "UTM" delete virtual machine named "{_esc(name)}" end tell ''' _run(script, timeout=60) return True - src/mcp_utm/server.py:67-68 (registration)Registration of the 'delete_vm' tool via the @mcp.tool() decorator on the FastMCP instance, making it available as an MCP tool.
@mcp.tool() def delete_vm(name: str) -> dict: - src/mcp_utm/server.py:67-68 (schema)Input schema for delete_vm: takes a single 'name' parameter (string) and returns a dict. The type hints define the contract for the MCP tool interface.
@mcp.tool() def delete_vm(name: str) -> dict: - tests/test_server.py:17-24 (registration)Test that confirms 'delete_vm' is registered among the expected MCP tool names.
expected = { "list_vms", "get_vm", "clone_vm", "start_vm", "stop_vm", "delete_vm", "suspend_vm", "wait_for_vm", "get_vm_ip", "set_vm_network", "set_vm_resources", "rename_vm", "set_vm_display", "list_vm_shares", "add_vm_share", "remove_vm_share", "set_vm_shares", "list_vm_drives", "attach_drive", "export_vm", "import_vm", "get_serial_port", } assert expected == names