list_volumes
Retrieve and filter storage volumes in CloudStack MCP Server by VM ID, zone, or type (ROOT, DATADISK). Manage cloud resources efficiently with precise volume listing.
Instructions
List storage volumes
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | No | Volume type (ROOT, DATADISK) | |
| virtualmachineid | No | VM ID to filter volumes | |
| zoneid | No | Zone ID to filter volumes |
Implementation Reference
- src/handlers/storage-handlers.ts:6-36 (handler)The handler function that executes the list_volumes tool logic. It fetches volumes using CloudStackClient, processes the response into a structured list, and formats it as a MCP-compatible text content response.async handleListVolumes(args: any) { const result = await this.cloudStackClient.listVolumes(args); const volumes = result.listvolumesresponse?.volume || []; const volumeList = volumes.map((volume: any) => ({ id: volume.id, name: volume.name, type: volume.type, size: volume.size, state: volume.state, zonename: volume.zonename, vmname: volume.vmname, deviceid: volume.deviceid, diskofferingname: volume.diskofferingname, created: volume.created, path: volume.path })); return { content: [ { type: 'text', text: `Found ${volumeList.length} volumes:\n\n${volumeList .map((vol: any) => `• ${vol.name} (${vol.id})\n Type: ${vol.type}\n Size: ${vol.size}GB\n State: ${vol.state}\n Zone: ${vol.zonename}\n VM: ${vol.vmname || 'Not attached'}\n Device ID: ${vol.deviceid || 'N/A'}\n Disk Offering: ${vol.diskofferingname}\n Created: ${vol.created}\n` ) .join('\n')}` } ] }; }
- Tool definition including name, description, and input schema for the list_volumes tool.name: 'list_volumes', description: 'List storage volumes', inputSchema: { type: 'object', properties: { virtualmachineid: { type: 'string', description: 'VM ID to filter volumes', }, zoneid: { type: 'string', description: 'Zone ID to filter volumes', }, type: { type: 'string', description: 'Volume type (ROOT, DATADISK)', }, }, additionalProperties: false, }, },
- src/server.ts:134-135 (registration)Registration of the list_volumes tool in the MCP server's CallToolRequest handler switch statement, dispatching to the StorageHandlers.handleListVolumes method.case 'list_volumes': return await this.storageHandlers.handleListVolumes(args);
- src/cloudstack-client.ts:160-162 (helper)Helper method in CloudStackClient that performs the actual API request to list volumes.async listVolumes(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listVolumes', params); }