Skip to main content
Glama

import_vm

Import a virtual machine from a .utm file into UTM on macOS. Provide the file path to restore or add a VM.

Instructions

Import a VM from a .utm file.

Args: path: Path to the .utm file to import

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • MCP tool handler for import_vm. Accepts path string, delegates to utm.import_vm(path), and returns the result as a dict.
    @mcp.tool()
    def import_vm(path: str) -> dict:
        """Import a VM from a .utm file.
    
        Args:
            path: Path to the .utm file to import
        """
        vm = utm.import_vm(path)
        return vm.to_dict()
  • Core implementation of import_vm. Validates path, runs AppleScript to import a .utm file via UTM's scripting API, parses the result into a VMInfo dataclass.
    def import_vm(path: str) -> VMInfo:
        """Import a VM from a .utm file. Returns the imported VM info."""
        _validate_path(path)
        script = f'''
        tell application "UTM"
            set src to POSIX file "{_esc(path)}"
            set vm to import new virtual machine from src
            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
            return vmId & "||" & vmName & "||" & vmStatus & "||" & vmBackend
        end tell
        '''
        raw = _run(script, timeout=600)
        parts = raw.split("||")
        if len(parts) < 4:
            raise RuntimeError(f"Unexpected import result: {raw!r}")
        return VMInfo(id=parts[0], name=parts[1], status=parts[2], backend=parts[3])
  • The @mcp.tool() decorator on the import_vm function registers it as an MCP tool named 'import_vm'.
    @mcp.tool()
    def import_vm(path: str) -> dict:
        """Import a VM from a .utm file.
    
        Args:
            path: Path to the .utm file to import
        """
        vm = utm.import_vm(path)
        return vm.to_dict()
  • Helper function _validate_path used by import_vm to ensure the path is absolute and has no path traversal.
    def _validate_path(path: str) -> str:
        if not path.startswith("/"):
            raise ValueError(f"Path must be absolute: {path!r}")
        if ".." in path.split("/"):
            raise ValueError(f"Path traversal not allowed: {path!r}")
        return path
  • VMInfo dataclass returned by import_vm, with a to_dict() method used by the server handler.
    @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}
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description must carry behavioral info. It fails to disclose whether importing overwrites existing VMs, requires specific permissions, or has side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no fluff, front-loaded with the core purpose. Every part is essential.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is too sparse. It omits error conditions, prerequisites (e.g., file must exist), and behavior on conflicts.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal meaning to the 'path' parameter by specifying it must point to a .utm file, which the schema's title 'Path' does not convey. However, schema coverage is 0%, and more details (e.g., file validation) would improve usefulness.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Import a VM') and the resource type ('.utm file'). It distinguishes from siblings like clone_vm and export_vm by specifying the source format.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like clone_vm or export_vm. Does not mention prerequisites or when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/neverprepared/mcp-utm'

If you have feedback or need assistance with the MCP directory API, please join our Discord server