Skip to main content
Glama
michaelrice
by michaelrice

list_vms

Lists virtual machines on a standalone ESXi host or groups them by host within a vCenter datacenter.

Instructions

List VMs on a target.

  • Standalone ESXi: lists all VMs on the host.

  • vCenter: groups VMs by host within the specified datacenter (defaults to the target's configured datacenter).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetNo
datacenterNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main handler function for the 'list_vms' tool. Accepts optional 'target' and 'datacenter' parameters. Loads config, resolves the target, connects to vCenter/ESXi, and delegates to _list_esxi or _list_vcenter depending on target type.
    def list_vms(target: str | None = None, datacenter: str | None = None) -> str:
        """
        List VMs on a target.
        - Standalone ESXi: lists all VMs on the host.
        - vCenter: groups VMs by host within the specified datacenter
          (defaults to the target's configured datacenter).
        """
        try:
            cfg = load_config()
            target_cfg = resolve_target(cfg, target)
            with vcenter_connection(target_cfg) as si:
                content = si.RetrieveContent()
                if target_cfg["type"] == "esxi":
                    return _list_esxi(content)
                dc_name = datacenter or target_cfg.get("datacenter")
                return _list_vcenter(content, dc_name)
        except Exception as e:
            return f"Error: {e}"
  • Helper handler for listing VMs on a standalone ESXi host. Queries all VirtualMachine objects via ContainerView and formats name, managed object ID, power state, and guest ID.
    def _list_esxi(content) -> str:
        container = content.viewManager.CreateContainerView(
            content.rootFolder, [vim.VirtualMachine], True
        )
        lines = ["VMs:"]
        for vm in container.view:
            state = vm.runtime.powerState
            guest = vm.config.guestId if vm.config else "unknown"
            lines.append(f"  {vm.name} ({vm._moId}) — {state} — {guest}")
        container.Destroy()
        return "\n".join(lines) if len(lines) > 1 else "No VMs found"
  • Helper handler for listing VMs in a vCenter datacenter. Groups VMs by host and formats name, managed object ID, power state, and guest ID for each VM.
    def _list_vcenter(content, dc_name: str) -> str:
        dc = get_obj(content, [vim.Datacenter], dc_name)
        if not dc:
            return f"Error: Datacenter '{dc_name}' not found"
    
        host_view = content.viewManager.CreateContainerView(
            dc, [vim.HostSystem], True
        )
        lines = []
        for host in host_view.view:
            lines.append(f"Host: {host.name}")
            for vm in host.vm:
                state = vm.runtime.powerState
                guest = vm.config.guestId if vm.config else "unknown"
                lines.append(f"  {vm.name} ({vm._moId}) — {state} — {guest}")
        host_view.Destroy()
        return "\n".join(lines) if lines else "No VMs found"
  • Registration function that registers the 'list_vms' tool with the MCP server via the @mcp.tool() decorator.
    def register_list_tools(mcp) -> None:
        @mcp.tool()
  • Import and invocation of register_list_tools in the main server module, which wires up the tool at server startup.
    from vcenter_mcp.tools.vm_list import register_list_tools
    from vcenter_mcp.tools.vm_create import register_create_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)
Behavior4/5

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

The description discloses significant behavioral differences between standalone ESXi and vCenter, including optional datacenter grouping. Without annotations, it carries the full burden and does so well. It implies read-only operation (list) but does not explicitly state lack of side effects.

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 two bullet points, front-loading the main action. Every sentence provides value, no redundancy.

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?

The description covers the tool's core behavior and parameter roles. With an output schema present (context signal), return values need not be described. It is fairly complete for a list tool, though explicit mention of read-only nature would strengthen it further.

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?

With 0% schema description coverage, the description must compensate. It explains the 'datacenter' parameter defaults to the target's configured datacenter but lacks detail on the 'target' parameter (e.g., format, valid values). Some meaning added, but insufficient given the gap.

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 lists VMs on a target, with specific behavior for standalone ESXi vs vCenter. It uniquely identifies the resource (VMs) and action (list), distinguishing it from sibling tools like create_vm, delete_vm, etc.

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 provides clear context for when to use the tool (listing VMs on a target) and mentions key parameters (target, datacenter). However, it does not explicitly state when not to use or suggest alternative tools, though siblings are distinct actions.

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