stop_vm
Stop a running virtual machine. Use force to halt VMs that do not shut down gracefully.
Instructions
Stop a running VM.
Args: name: VM name force: Force stop if graceful shutdown fails
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| force | No |
Implementation Reference
- src/mcp_utm/server.py:55-64 (handler)MCP tool handler for stop_vm. Decorated with @mcp.tool(), delegates to utm.stop_vm (the applescript module).
@mcp.tool() def stop_vm(name: str, force: bool = False) -> dict: """Stop a running VM. Args: name: VM name force: Force stop if graceful shutdown fails """ status = utm.stop_vm(name, force=force) return {"name": name, "status": status} - src/mcp_utm/applescript.py:262-273 (helper)Helper function that generates and runs AppleScript to stop a VM via UTM's scripting API. Supports graceful and force stop methods.
def stop_vm(name: str, force: bool = False) -> str: """Stop a VM. Returns status after stop command.""" _validate_vm_name(name) method = "by force" if force else "" script = f''' tell application "UTM" set vm to virtual machine named "{_esc(name)}" stop vm {method} return status of vm as text end tell ''' return _run(script, timeout=60) - src/mcp_utm/server.py:55-56 (registration)Tool registered via the @mcp.tool() decorator on the stop_vm handler function.
@mcp.tool() def stop_vm(name: str, force: bool = False) -> dict: - src/mcp_utm/server.py:55-56 (schema)Input schema: name (str) is required, force (bool, default False) is optional. Return type is dict.
@mcp.tool() def stop_vm(name: str, force: bool = False) -> dict: