list_templates
Retrieve and filter templates from the CloudStack MCP Server by type, hypervisor, or zone, enabling efficient management of virtual machine configurations.
Instructions
List templates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hypervisor | No | Hypervisor type | |
| templatefilter | Yes | Template filter (featured, self, selfexecutable, sharedexecutable, executable, community) | featured |
| zoneid | No | Zone ID to filter templates |
Implementation Reference
- src/handlers/admin-handlers.ts:34-61 (handler)Main handler function that executes the list_templates tool logic: fetches templates via CloudStack client, processes them, and returns formatted text response.async handleListTemplates(args: any) { const result = await this.cloudStackClient.listTemplates(args); const templates = result.listtemplatesresponse?.template || []; const templateList = templates.map((template: any) => ({ id: template.id, name: template.name, displaytext: template.displaytext, ostypename: template.ostypename, size: template.size, created: template.created, isready: template.isready, ispublic: template.ispublic, isfeatured: template.isfeatured })); return { content: [ { type: 'text', text: `Found ${templateList.length} templates:\n\n${templateList .map((template: any) => `• ${template.name} (${template.id})\n Display Text: ${template.displaytext}\n OS Type: ${template.ostypename}\n Size: ${template.size}GB\n Ready: ${template.isready}\n Public: ${template.ispublic}\n Featured: ${template.isfeatured}\n Created: ${template.created}\n` ) .join('\n')}` } ] };
- Input schema and definition for the list_templates tool.{ name: 'list_templates', description: 'List templates', inputSchema: { type: 'object', properties: { templatefilter: { type: 'string', description: 'Template filter (featured, self, selfexecutable, sharedexecutable, executable, community)', default: 'featured', }, zoneid: { type: 'string', description: 'Zone ID to filter templates', }, hypervisor: { type: 'string', description: 'Hypervisor type', }, }, required: ['templatefilter'], additionalProperties: false, },
- src/server.ts:180-181 (registration)Dispatch/registration in server switch statement mapping tool name to handler.case 'list_templates': return await this.adminHandlers.handleListTemplates(args);
- src/cloudstack-client.ts:122-125 (helper)Helper method in CloudStack client that sends the actual API request for listing templates.async listTemplates(params: CloudStackParams = {}): Promise<CloudStackResponse> { const defaultParams = { templatefilter: 'featured', ...params }; return this.request('listTemplates', defaultParams); }