Skip to main content
Glama
yeahdongcn

VMware Fusion MCP Server

by yeahdongcn

get_vm_power_state

Check the current power status of a VMware Fusion virtual machine to determine if it's running, powered off, or suspended.

Instructions

Get the power state of a specific VM.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vm_idYes

Implementation Reference

  • Core handler implementation that creates a VMwareClient instance and calls its get_vm_power_state method to retrieve the VM power state.
    async def _get_vm_power_state_impl(vm_id: str) -> Dict[str, Any]:
        """Get the power state of a specific VM."""
        async with VMwareClient(username=VMREST_USER, password=VMREST_PASS) as client:
            state = await client.get_vm_power_state(vm_id)
            return state  # type: ignore[no-any-return]
  • Registers the 'get_vm_power_state' tool with the MCP server via @mcp.tool decorator. The tool handler delegates execution to the private implementation function.
    @mcp.tool
    async def get_vm_power_state(vm_id: str) -> Dict[str, Any]:
        """Get the power state of a specific VM."""
        return await _get_vm_power_state_impl(vm_id)
  • Supporting utility in VMwareClient class that performs the HTTP GET request to the Fusion REST API endpoint /api/vms/{vm_id}/power to obtain the power state.
    async def get_vm_power_state(
        self, vm_id: str, vm_password: Optional[str] = None
    ) -> Dict[str, Any]:
        """Get the power state of a specific VM.
    
        Args:
            vm_id: The ID of the VM
            vm_password: The password for the VM (if required)
    
        Returns:
            Dictionary with the VM's power state
        """
        try:
            url = f"{self.base_url}/api/vms/{vm_id}/power"
            params = {}
            if vm_password:
                params["vmPassword"] = vm_password
            response = await self._client.get(
                url,
                headers=self._auth_header,
                params=params or None,
            )
            response.raise_for_status()
            return response.json()  # type: ignore[no-any-return]
        except httpx.RequestError as e:
            raise Exception(f"Failed to connect to VMware Fusion API: {e}")
        except httpx.HTTPStatusError as e:
            if e.response.status_code == 404:
                raise Exception(f"VM with ID '{vm_id}' not found")
            raise Exception(
                f"VMware Fusion API error: {e.response.status_code} - "
                f"{e.response.text}"
            )

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/yeahdongcn/vmware-fusion-mcp-server'

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