deploy_virtual_machine
Create and configure a virtual machine using specified service offering, template, and zone IDs on the CloudStack MCP Server. Optionally, assign a name, networks, security groups, SSH key pairs, and user data.
Instructions
Deploy a new virtual machine
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| displayname | No | VM display name | |
| keypair | No | SSH key pair name | |
| name | No | VM name | |
| networkids | No | Network IDs (comma-separated) | |
| securitygroupids | No | Security group IDs (comma-separated) | |
| serviceofferingid | Yes | Service offering ID | |
| templateid | Yes | Template ID | |
| userdata | No | User data (base64 encoded) | |
| zoneid | Yes | Zone ID |
Implementation Reference
- The handler function that implements the core logic for the 'deploy_virtual_machine' tool. It calls the CloudStack client to deploy the VM and returns a formatted text response with job ID and VM ID.async handleDeployVirtualMachine(args: any) { const result = await this.cloudStackClient.deployVirtualMachine(args); return { content: [ { type: 'text', text: `Deployed virtual machine. Job ID: ${result.deployvirtualmachineresponse?.jobid}\nVM ID: ${result.deployvirtualmachineresponse?.id}` } ] }; }
- The tool definition including name, description, and input schema (parameters with types, descriptions, and required fields) for 'deploy_virtual_machine'.{ name: 'deploy_virtual_machine', description: 'Deploy a new virtual machine', inputSchema: { type: 'object', properties: { serviceofferingid: { type: 'string', description: 'Service offering ID', }, templateid: { type: 'string', description: 'Template ID', }, zoneid: { type: 'string', description: 'Zone ID', }, name: { type: 'string', description: 'VM name', }, displayname: { type: 'string', description: 'VM display name', }, networkids: { type: 'string', description: 'Network IDs (comma-separated)', }, securitygroupids: { type: 'string', description: 'Security group IDs (comma-separated)', }, keypair: { type: 'string', description: 'SSH key pair name', }, userdata: { type: 'string', description: 'User data (base64 encoded)', }, }, required: ['serviceofferingid', 'templateid', 'zoneid'], additionalProperties: false, }, },
- src/server.ts:120-121 (registration)The switch case in the MCP server request handler that registers and routes calls to the 'deploy_virtual_machine' tool to its handler.case 'deploy_virtual_machine': return await this.vmHandlers.handleDeployVirtualMachine(args);
- src/cloudstack-client.ts:96-98 (helper)Helper method in the CloudStackClient class that wraps the API request for the 'deployVirtualMachine' CloudStack API command.async deployVirtualMachine(params: CloudStackParams): Promise<CloudStackResponse> { return this.request('deployVirtualMachine', params); }