Skip to main content
Glama

wait_for_vm

Block until a VM reaches a target status like started, stopped, or paused. Ideal for orchestration to confirm VM readiness.

Instructions

Wait until a VM reaches a target status.

Useful for orchestration — start a VM then wait for it to be ready.

Args: name: VM name target_status: Status to wait for: "stopped", "started", or "paused" timeout: Seconds to wait (default: 120)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
target_statusNostarted
timeoutNo

Implementation Reference

  • The @mcp.tool() decorator registers 'wait_for_vm' as an MCP tool. The function delegates to applescript.wait_for_vm().
    @mcp.tool()
    def wait_for_vm(name: str, target_status: str = "started", timeout: int = 120) -> dict:
        """Wait until a VM reaches a target status.
  • The MCP tool handler for 'wait_for_vm': accepts name, target_status (default 'started'), and timeout (default 120s); calls utm.wait_for_vm() and returns a dict with name and status.
    def wait_for_vm(name: str, target_status: str = "started", timeout: int = 120) -> dict:
        """Wait until a VM reaches a target status.
    
        Useful for orchestration — start a VM then wait for it to be ready.
    
        Args:
            name: VM name
            target_status: Status to wait for: "stopped", "started", or "paused"
            timeout: Seconds to wait (default: 120)
        """
        status = utm.wait_for_vm(name, target_status=target_status, timeout=timeout)
        return {"name": name, "status": status}
  • Core polling logic: validates inputs, then polls get_vm_status() every 2 seconds until the target status is reached or timeout expires. Raises TimeoutError on timeout.
    def wait_for_vm(name: str, target_status: str = "started", timeout: int = 120) -> str:
        """Poll VM status until it matches target or timeout is reached."""
        _validate_vm_name(name)
        if target_status not in _VALID_STATUSES:
            raise ValueError(f"Invalid target_status '{target_status}'. Must be one of: {_VALID_STATUSES}")
        timeout = _validate_timeout(timeout)
    
        status = get_vm_status(name)
        deadline = time.monotonic() + timeout
        while time.monotonic() < deadline:
            if status == target_status:
                return status
            time.sleep(2)
            status = get_vm_status(name)
        raise TimeoutError(f"VM '{name}' did not reach '{target_status}' within {timeout}s (current: {status})")
  • Defines _VALID_STATUSES = {'stopped', 'started', 'paused', 'starting', 'stopping', 'pausing', 'resuming'} used for validation of the target_status parameter.
    _VALID_STATUSES = {"stopped", "started", "paused", "starting", "stopping", "pausing", "resuming"}
  • _validate_timeout clamps the timeout value between 1 and _MAX_TIMEOUT (600).
    def _validate_timeout(timeout: int) -> int:
        return max(1, min(timeout, _MAX_TIMEOUT))
Behavior4/5

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

No annotations provided, so description bears full burden. Describes blocking behavior, possible statuses, and timeout. Lacks mention of non-destructive nature but sufficient.

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?

Concise, front-loaded with purpose, then usage hint, then parameter list with bullet points. No wasted text.

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?

Covers purpose, parameters, and usage context. Lacks return value info but given no output schema and moderate complexity, it's adequately complete.

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?

Input schema has 0% description coverage; description lists all three parameters with meaningful details (values for target_status, default for timeout). Adds value beyond 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?

Description clearly states 'Wait until a VM reaches a target status' with specific verb and resource. Distinguishes from sibling tools like start_vm, which perform actions rather than waits.

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?

Provides context: 'Useful for orchestration — start a VM then wait for it to be ready.' Implies usage but does not explicitly exclude alternatives or state when not to use.

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