Skip to main content
Glama
yeahdongcn

VMware Fusion MCP Server

by yeahdongcn

power_vm

Control VMware Fusion virtual machines by executing power actions such as turning on, off, shutting down, suspending, pausing, or unpausing a specified VM.

Instructions

Perform a power action on a VM. Valid actions are 'on', 'off', 'shutdown', 'suspend', 'pause', 'unpause'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
vm_idYes

Implementation Reference

  • MCP tool handler for 'power_vm', registered via @mcp.tool decorator. Defines input parameters (vm_id, action) and delegates to _power_vm_impl. Docstring provides schema details on valid actions.
    @mcp.tool async def power_vm(vm_id: str, action: str) -> Dict[str, Any]: """Perform a power action on a VM. Valid actions are 'on', 'off', 'shutdown', 'suspend', 'pause', 'unpause'.""" return await _power_vm_impl(vm_id, action)
  • Internal helper implementation that instantiates VMwareClient using environment credentials and invokes the client's power_vm method to perform the action.
    async def _power_vm_impl(vm_id: str, action: str) -> Dict[str, Any]: """Perform a power action on a VM. Valid actions are 'on', 'off', 'shutdown', 'suspend', 'pause', 'unpause'.""" async with VMwareClient(username=VMREST_USER, password=VMREST_PASS) as client: result = await client.power_vm(vm_id, action) return result # type: ignore[no-any-return]
  • Core low-level implementation in VMwareClient.power_vm. Validates the action against allowed values, constructs the API URL, sets authentication headers, and sends a PUT request to the VMware Fusion REST API /api/vms/{vm_id}/power endpoint with the action as the request body.
    async def power_vm( self, vm_id: str, action: str, vm_password: Optional[str] = None ) -> Dict[str, Any]: """Perform a power action on a VM. Args: vm_id: The ID of the VM action: Power action (on, off, shutdown, suspend, pause, unpause) vm_password: The password for the VM (if required) Returns: Dictionary with the result of the power action """ valid_actions = ["on", "off", "shutdown", "suspend", "pause", "unpause"] if action not in valid_actions: raise ValueError( f"Invalid action '{action}'. Valid actions: {valid_actions}" ) try: url = f"{self.base_url}/api/vms/{vm_id}/power" params = {} if vm_password: params["vmPassword"] = vm_password headers = self._auth_header.copy() headers["Content-Type"] = "application/vnd.vmware.vmw.rest-v1+json" response = await self._client.put( url, headers=headers, params=params or None, content=action.encode(), ) response.raise_for_status() return ( response.json() if response.content else {"status": "success", "action": action} ) 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}" )

Other Tools

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

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