attach_drive
Attach an ISO or disk image file to a specific drive of a stopped UTM virtual machine to enable booting from external media or accessing additional storage.
Instructions
Attach an ISO or disk image to a removable drive.
Args: name: VM name (must be stopped) drive_id: Drive ID (from list_vm_drives) source_path: Path to ISO or disk image file
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| drive_id | Yes | ||
| source_path | Yes |
Implementation Reference
- src/mcp_utm/server.py:209-218 (handler)MCP tool handler that exposes attach_drive as a tool, calls applescript.attach_drive and returns a dict result.
def attach_drive(name: str, drive_id: str, source_path: str) -> dict: """Attach an ISO or disk image to a removable drive. Args: name: VM name (must be stopped) drive_id: Drive ID (from list_vm_drives) source_path: Path to ISO or disk image file """ utm.attach_drive(name, drive_id, source_path) return {"name": name, "drive_id": drive_id, "source": source_path} - src/mcp_utm/server.py:208-209 (registration)Tool registered via @mcp.tool() decorator on FastMCP instance.
@mcp.tool() def attach_drive(name: str, drive_id: str, source_path: str) -> dict: - src/mcp_utm/applescript.py:553-573 (helper)AppleScript implementation that attaches an ISO/disk image to a removable drive by updating the UTM VM configuration via AppleScript.
def attach_drive(name: str, drive_id: str, source_path: str) -> bool: """Attach an ISO or disk image to a removable drive on a stopped VM.""" _validate_vm_name(name) _validate_path(source_path) script = f''' tell application "UTM" set vm to virtual machine named "{_esc(name)}" set conf to configuration of vm set drvs to drives of conf repeat with i from 1 to count of drvs set d to item i of drvs if id of d is "{_esc(drive_id)}" then set source of d to POSIX file "{_esc(source_path)}" exit repeat end if end repeat update configuration of vm with conf end tell ''' _run(script) return True - src/mcp_utm/server.py:210-216 (schema)Function signature and docstring define the schema: name (str), drive_id (str), source_path (str) -> dict.
"""Attach an ISO or disk image to a removable drive. Args: name: VM name (must be stopped) drive_id: Drive ID (from list_vm_drives) source_path: Path to ISO or disk image file """