Skip to main content
Glama

get_vm_ip

Find the IP address of a running UTM virtual machine by polling the ARP table with its MAC address. Supports Apple VF (macOS) VMs on 192.168.64.0/24 subnet and bridged QEMU VMs. Specify VM name and optional timeout.

Instructions

Discover the IP address of a running VM via ARP.

Polls the ARP table for the VM's MAC address. Works for Apple VF (macOS) VMs on the 192.168.64.0/24 subnet and bridged QEMU VMs.

Args: name: VM name timeout: Seconds to wait for ARP discovery (default: 60)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
timeoutNo

Implementation Reference

  • MCP tool handler that registers 'get_vm_ip' as a tool and delegates to the AppleScript utility function.
    @mcp.tool()
    def get_vm_ip(name: str, timeout: int = 60) -> dict:
        """Discover the IP address of a running VM via ARP.
    
        Polls the ARP table for the VM's MAC address. Works for Apple VF
        (macOS) VMs on the 192.168.64.0/24 subnet and bridged QEMU VMs.
    
        Args:
            name: VM name
            timeout: Seconds to wait for ARP discovery (default: 60)
        """
        ip, mac = utm.get_vm_ip(name, timeout=timeout)
        return {"name": name, "ip": ip, "mac_address": mac}
  • Helper function that reads the VM's MAC address from UTM config, then polls the ARP table to discover the IP address. Handles zero-stripped MAC formats and raises TimeoutError if not found within the timeout.
    def get_vm_ip(name: str, timeout: int = 60) -> tuple[str, str]:
        """Discover VM IP via ARP table by reading its MAC from UTM config.
    
        Returns (ip_address, mac_address) tuple.
        """
        _validate_vm_name(name)
        timeout = _validate_timeout(timeout)
        config = get_vm_config(name)
        mac = config.mac_address.lower()
        if not mac:
            raise RuntimeError(f"No MAC address found for VM '{name}'")
    
        # ARP output may strip leading zeros from MAC octets (e.g. 0e → e).
        mac_stripped = ":".join(p.lstrip("0") or "0" for p in mac.split(":"))
    
        deadline = time.monotonic() + timeout
        while time.monotonic() < deadline:
            result = subprocess.run(["arp", "-a"], capture_output=True, text=True)
            for line in result.stdout.split("\n"):
                line_lower = line.lower()
                if mac in line_lower or mac_stripped in line_lower:
                    start = line.find("(")
                    end = line.find(")")
                    if start != -1 and end != -1:
                        return line[start + 1 : end], config.mac_address
            time.sleep(2)
    
        raise TimeoutError(f"IP not found for VM '{name}' (MAC: {mac}) after {timeout}s")
  • The VMConfig dataclass carries the MAC address used by get_vm_ip to search the ARP table.
    @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,
            }
  • The FastMCP instance 'mcp' and the @mcp.tool() decorator register get_vm_ip as an MCP tool in line 74.
    from mcp.server.fastmcp import FastMCP
    
    from . import applescript as utm
    
    mcp = FastMCP("utm")
Behavior3/5

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

With no annotations, the description covers the polling mechanism, timeout, and supported VMs. However, it lacks details on what happens if the IP is not found, error conditions, or authorization needs.

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 with three well-structured sentences plus a bullet list for arguments. The main purpose is front-loaded, and no unnecessary information is present.

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 simple tool with two parameters and no output schema, the description covers the purpose, mechanism, constraints, and parameters. It could mention return value behavior and prerequisites like 'VM must be running,' but is largely complete.

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 descriptions are missing (0% coverage), but the tool description includes an 'Args' section that explains both parameters: name (VM name) and timeout (seconds to wait), adding value beyond the 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 discovers a VM's IP address via ARP, specifying the resource (VM) and action (discover IP). It distinguishes from siblings like get_vm by mentioning the mechanism and supported VM types.

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 provides context on when to use (Apple VF or bridged QEMU VMs) and the subnet, but does not explicitly state when not to use or suggest alternatives for other VM types or scenarios.

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