Skip to main content
Glama

clone_vm

Clone a UTM virtual machine template with a unique random MAC address to prevent network conflicts. Specify the template name and new VM name.

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' — decorated with @mcp.tool(), delegates to utm.clone_vm() and returns the cloned VM config as a dict.
    @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 implementation of clone_vm — validates names, generates optional random MAC, builds AppleScript for UTM duplicate + optional MAC update, runs it via osascript, 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)
  • generate_mac() — helper that creates a locally-administered unicast MAC address used when randomize_mac=True.
    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)
  • VMConfig dataclass — return type for clone_vm; contains name, memory, cpu_cores, mac_address, network_mode with to_dict() serialization.
    @dataclass
    class VMConfig:
        name: str
        memory: int  # MiB
        cpu_cores: int
        mac_address: str
        network_mode: str
    
        def to_dict(self) -> dict:
            return {
                "name": self.name,
                "memory": self.memory,
                "cpu_cores": self.cpu_cores,
                "mac_address": self.mac_address,
                "network_mode": self.network_mode,
            }
  • MCP server registration — line 12 imports applescript as utm, line 14 creates FastMCP('utm') which the @mcp.tool() decorator on clone_vm registers against.
    """MCP server exposing UTM virtual machine management via AppleScript.
    
    Tools for listing, cloning, configuring, and controlling UTM VMs.
    Provides proper MAC address randomization for Apple VF clones via
    the AppleScript ``update configuration`` API.
    """
    
    from __future__ import annotations
    
    from mcp.server.fastmcp import FastMCP
    
    from . import applescript as utm
    
    mcp = FastMCP("utm")
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It mentions randomizing MAC addresses but does not explain side effects on the original template, whether the operation requires specific permissions, what happens to existing VM properties, or what the tool returns. This is a significant gap for a mutation tool.

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 extremely concise: one sentence stating the purpose followed by a brief list of parameter explanations. No redundant information, and the key action is front-loaded.

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

Completeness3/5

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

Given the moderate complexity (3 parameters, no output schema), the description covers the essential usage and parameter semantics well. However, it lacks information about return values, success/failure conditions, and operational prerequisites (e.g., VM state). These omissions prevent full completeness.

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

Parameters5/5

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

The description provides clear, helpful explanations for all three parameters, including default behavior for randomize_mac. Since schema description coverage is 0%, the description fully compensates by documenting each parameter's meaning and purpose, going beyond the bare schema.

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 tool clones a UTM template VM and includes a unique random MAC address. It specifies the action (clone), resource (UTM template VM), and a key distinguishing feature, differentiating it from sibling tools like delete_vm or start_vm.

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 does not provide explicit guidance on when to use this tool versus alternatives, nor does it mention prerequisites or exclusions. It implies usage for cloning templates but lacks context such as whether the template must exist or if the VM must be stopped. This is adequate but not exemplary.

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