Skip to main content
Glama

clone_vm

Clone UTM virtual machines from a template with unique MAC addresses to avoid IP conflicts.

Instructions

Clone a UTM template VM with a unique random MAC address.

Args: template: Name of the template VM to clone name: Name for the new VM randomize_mac: Assign a random MAC so clones get unique IPs (default: True)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateYes
nameYes
randomize_macNo

Implementation Reference

  • MCP tool handler for clone_vm — registers the tool with FastMCP and delegates to applescript.clone_vm
    @mcp.tool()
    def clone_vm(
        template: str,
        name: str,
        randomize_mac: bool = True,
    ) -> dict:
        """Clone a UTM template VM with a unique random MAC address.
    
        Args:
            template: Name of the template VM to clone
            name: Name for the new VM
            randomize_mac: Assign a random MAC so clones get unique IPs (default: True)
        """
        config = utm.clone_vm(template, name, randomize_mac=randomize_mac)
        return {"cloned": True, **config.to_dict()}
  • Core AppleScript implementation — duplicates the VM template via osascript, optionally randomizes MAC, and returns the new VM config
    def clone_vm(template_name: str, new_name: str, randomize_mac: bool = True) -> VMConfig:
        """Clone a VM, optionally assigning a random MAC address.
    
        Uses AppleScript ``duplicate`` + ``update configuration`` so UTM's
        in-memory state is updated (unlike raw plist edits).
        """
        _validate_vm_name(template_name)
        _validate_vm_name(new_name)
        new_mac = generate_mac() if randomize_mac else ""
    
        if new_mac:
            script = f'''
            tell application "UTM"
                set tmpl to virtual machine named "{_esc(template_name)}"
                duplicate tmpl with properties {{configuration:{{name:"{_esc(new_name)}"}}}}
                set vm to virtual machine named "{_esc(new_name)}"
                set conf to configuration of vm
                set nic to item 1 of (network interfaces of conf)
                set address of nic to "{_esc(new_mac)}"
                update configuration of vm with conf
            end tell
            '''
        else:
            script = f'''
            tell application "UTM"
                set tmpl to virtual machine named "{_esc(template_name)}"
                duplicate tmpl with properties {{configuration:{{name:"{_esc(new_name)}"}}}}
            end tell
            '''
        _run(script, timeout=600)
    
        return get_vm_config(new_name)
  • Registration via @mcp.tool() decorator — registers clone_vm as an MCP tool on the FastMCP server
    @mcp.tool()
    def clone_vm(
        template: str,
        name: str,
        randomize_mac: bool = True,
    ) -> dict:
        """Clone a UTM template VM with a unique random MAC address.
    
        Args:
            template: Name of the template VM to clone
            name: Name for the new VM
            randomize_mac: Assign a random MAC so clones get unique IPs (default: True)
        """
        config = utm.clone_vm(template, name, randomize_mac=randomize_mac)
        return {"cloned": True, **config.to_dict()}
  • MAC address generator helper — produces random locally-administered unicast MACs for cloned VMs
    def generate_mac() -> str:
        """Generate a random locally-administered unicast MAC address."""
        octets = [random.randint(0, 255) for _ in range(6)]
        octets[0] = (octets[0] & 0xFC) | 0x02  # locally administered, unicast
        return ":".join(f"{b:02x}" for b in octets)
  • Input validation helper — ensures VM names contain only safe characters to prevent AppleScript injection
    def _validate_vm_name(name: str) -> str:
        if not name or not _VM_NAME_RE.match(name):
            raise ValueError(f"Invalid VM name: {name!r} — only word characters, spaces, hyphens, and dots allowed")
        return name
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions MAC randomization but does not discuss side effects (e.g., whether the original template is affected), required permissions, or error conditions. Minimal behavioral disclosure for a mutation operation.

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?

The description is concise: a single-sentence summary followed by an Args section. No superfluous information, and the structure allows quick scanning.

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

Completeness4/5

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

For a tool with 3 parameters and no output schema, the description provides essential purpose and parameter semantics. Minor gaps exist (e.g., missing return value details, error handling) but overall adequate for selection and invocation.

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

Parameters4/5

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

Schema coverage is 0%, but the description adds clear explanations for each parameter: 'template' is the source VM name, 'name' is the new VM name, and 'randomize_mac' explains its purpose and default. This compensates well for the lack of schema descriptions.

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 verb 'Clone', the resource 'UTM template VM', and the key feature 'unique random MAC address'. This distinguishes it from other VM operations like start, stop, or add shares.

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

Usage Guidelines3/5

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

The description implies usage for cloning from a template VM but does not provide explicit guidance on when to use this versus other tools, nor does it state when not to use it or suggest alternatives among the many sibling tools.

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