Skip to main content
Glama

get_vm_ip

Retrieve the IP address of a running VM by polling the ARP table using the VM's MAC address. Works for Apple VF and bridged QEMU VMs.

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

  • Core implementation: polls ARP table for the VM's MAC address to discover its IP. Reads MAC from UTM config, handles stripped leading zeros in ARP output, retries every 2s up to 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")
  • MCP tool handler: wraps the AppleScript get_vm_ip function, returns name/ip/mac_address dict.
    @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}
  • Tool registered via @mcp.tool() decorator on the get_vm_ip function.
    @mcp.tool()
    def get_vm_ip(name: str, timeout: int = 60) -> dict:
  • Helper: _validate_timeout clamps timeout between 1 and 600 seconds, used inside get_vm_ip.
    def _validate_timeout(timeout: int) -> int:
        return max(1, min(timeout, _MAX_TIMEOUT))
  • Helper: _validate_vm_name validates VM name format, called at the start of get_vm_ip.
    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
Behavior4/5

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

With no annotations, the description carries full burden. It discloses polling behavior, applicable VM types, and timeout. It does not contradict any annotations (none provided) and is consistent with a read-only operation.

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

Conciseness4/5

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

The description is clear and well-structured with a summary line followed by details and argument documentation. It is appropriately concise without being overly brief.

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 2 parameters, no output schema, and no annotations, the description sufficiently covers the purpose, mechanism, and parameters. It lacks return value details but is adequate for an agent.

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?

Schema coverage is 0%, so description compensates by explaining 'name' as VM name and 'timeout' with default 60. However, it does not specify name format or constraints, leaving some ambiguity.

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 it discovers the IP of a running VM via ARP, specifying VM types and subnet. It is distinct from sibling tools like get_vm or list_vms.

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

Usage Guidelines4/5

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

The description explains the mechanism (ARP table polling) and provides context for when it works (Apple VF and QEMU VMs). It does not explicitly state when not to use, but the context implies usage after VM is running.

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