Skip to main content
Glama
michaelrice
by michaelrice

power_off_vm

Hard power off a virtual machine by specifying its display name or managed object reference ID.

Instructions

Hard power off 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 actual handler function that powers off a VM. It loads config, resolves the target, connects to vCenter, finds the VM by name/ID, calls PowerOff(), and waits for the task to complete.
    @mcp.tool()
    def power_off_vm(name_or_id: str, target: str | None = None) -> str:
        """Hard power off 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.PowerOff()
                wait_for_task(task)
                return f"VM '{vm.name}' is now powered off"
        except Exception as e:
            return f"Error: {e}"
  • The register_power_tools function uses @mcp.tool() decorator to register power_off_vm as an 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')."""
            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}"
    
        @mcp.tool()
        def power_off_vm(name_or_id: str, target: str | None = None) -> str:
  • Imports register_power_tools from vm_power module and calls it on line 20 to register the tool.
    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)
  • lookup_vm helper used by power_off_vm to find a VM by display name or moref ID.
    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.
        """
  • wait_for_task helper waits for the PowerOff vSphere task to complete.
    def wait_for_task(task) -> None:
        """Wait for a vSphere task to complete. Raises on task error."""
        WaitForTask(task)
Behavior2/5

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

With no annotations, the description should disclose more behavioral details. It states 'hard power off' implying forceful shutdown but does not mention risks (data loss), prerequisites, or behavior if VM is already off or not found.

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 a single concise sentence with no wasted words, but lacks structure such as separate sections for usage or parameters.

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 an output schema, the description is adequate for the core action, but fails to explain the optional parameter and lacks behavioral context, leaving gaps for an AI agent.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must explain parameters. It explains name_or_id (display name or moref ID) but completely ignores the 'target' parameter, leaving its purpose unclear.

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 (hard power off) and the resource (VM), and specifies the identification methods (display name or moref ID), distinguishing it from siblings like power_on_vm or delete_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 implies when to use (to hard power off a VM) but provides no explicit guidance on when not to use, such as preferring a soft shutdown or prerequisites like the VM being powered on.

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