Skip to main content
Glama
michaelrice
by michaelrice

power_on_vm

Power on a virtual machine by display name or moref ID, enabling quick startup of VMs on vCenter or ESXi hosts.

Instructions

Power on a VM by display name or moref ID (e.g. 'vm-42').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
name_or_idYes
targetNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that powers on a VM by name or moref ID. Connects to vCenter, looks up the VM, calls PowerOn(), and waits for the task to complete.
    def power_on_vm(name_or_id: str, target: str | None = None) -> str:
        """Power on a VM by display name or moref ID (e.g. 'vm-42')."""
        try:
            cfg = load_config()
            target_cfg = resolve_target(cfg, target)
            with vcenter_connection(target_cfg) as si:
                vm = lookup_vm(si, name_or_id)
                task = vm.PowerOn()
                wait_for_task(task)
                return f"VM '{vm.name}' is now powered on"
        except Exception as e:
            return f"Error: {e}"
  • Imports register_power_tools from vm_power module and calls it to register power_on_vm (and power_off_vm) as MCP tools.
    from vcenter_mcp.tools.vm_power import register_power_tools
    from vcenter_mcp.tools.vm_delete import register_delete_tools
    
    register_list_tools(mcp)
    register_create_tools(mcp)
    register_power_tools(mcp)
    register_delete_tools(mcp)
  • Registration decorator that registers power_on_vm as an MCP tool via @mcp.tool()
    def register_power_tools(mcp) -> None:
        @mcp.tool()
        def power_on_vm(name_or_id: str, target: str | None = None) -> str:
            """Power on a VM by display name or moref ID (e.g. 'vm-42')."""
  • Helper function lookup_vm() used by power_on_vm to find a VM by moref ID or display name.
    def lookup_vm(si, name_or_id: str):
        """
        Find a VM by moref ID (e.g. 'vm-42') or display name.
        Raises ValueError if not found or if multiple VMs share the same display name.
        """
        content = si.RetrieveContent()
    
        if _is_moref(name_or_id):
            ref = vim.VirtualMachine(name_or_id)
            ref._stub = si._stub
            return ref
    
        container = content.viewManager.CreateContainerView(
            content.rootFolder, [vim.VirtualMachine], True
        )
        matches = [vm for vm in container.view if vm.name == name_or_id]
        container.Destroy()
    
        if not matches:
            raise ValueError(f"No VM found with name '{name_or_id}'")
        if len(matches) > 1:
            morefs = [vm._moId for vm in matches]
            raise ValueError(
                f"Multiple VMs named '{name_or_id}': {morefs}. Use a moref ID instead."
            )
        return matches[0]
    
    
    def wait_for_task(task) -> None:
        """Wait for a vSphere task to complete. Raises on task error."""
        WaitForTask(task)
  • Helper function resolve_target() used by power_on_vm to determine which vCenter target to connect to.
    def resolve_target(cfg: dict, target_name: str | None = None) -> dict:
        name = target_name or cfg.get("default_target")
        if not name:
            raise ValueError("No target specified and no default_target set in config")
        target = cfg.get("targets", {}).get(name)
        if not target:
            raise ValueError(f"Target '{name}' not found in config. Available: {list(cfg.get('targets', {}).keys())}")
        return target
Behavior2/5

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

The description only states the action without disclosing side effects (e.g., idempotency), required permissions, or error conditions. With no annotations, the agent lacks critical behavioral context 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?

A single, front-loaded sentence with no wasted words. Every piece of information earns its place.

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?

For a simple tool with two parameters and an output schema, the description covers the primary parameter but misses behavioral details (e.g., what happens if VM is already on) and the purpose of the 'target' parameter. Adequate but with clear gaps.

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?

The description explains that name_or_id accepts a display name or moref ID, adding value beyond the schema structure. However, the optional 'target' parameter is not explained, and schema coverage is 0%, so the description only partially compensates.

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 action ('Power on a VM') and the resource identifiers ('by display name or moref ID'), which distinguishes it from siblings like power_off_vm.

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 specifies how to identify the VM (name or moref ID) with an example, but does not provide guidance on when to choose one identifier over the other or mention when not to use the tool.

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/michaelrice/vcenter-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server