liara_create_vm
Create a new virtual machine on the Liara cloud platform by specifying name, plan, operating system, and network configuration.
Instructions
Create a new virtual machine
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | VM name | |
| planID | Yes | Plan ID for the VM | |
| os | Yes | Operating system | |
| sshKey | No | SSH public key (optional) | |
| network | Yes | Network ID (required by the API) |
Implementation Reference
- src/services/iaas.ts:57-71 (handler)The core handler function that implements the liara_create_vm tool logic by calling the Liara IaaS API to create a new virtual machine./** * Create a new virtual machine */ export async function createVM( client: LiaraClient, request: CreateVmRequest ): Promise<VirtualMachine> { validateRequired(request.name, 'VM name'); validateRequired(request.planID, 'Plan ID'); validateRequired(request.os, 'Operating system'); validateRequired(request.network, 'Network ID'); const iaasClient = createIaaSClient(client); return await iaasClient.post<VirtualMachine>('/vm', request); }
- src/api/types.ts:278-284 (schema)Input schema (type definition) for the createVM request parameters.export interface CreateVmRequest { name: string; planID: string; os: string; sshKey?: string; network: string; }
- src/api/types.ts:266-274 (schema)Output schema for the created VirtualMachine.export interface VirtualMachine { _id: string; name: string; planID: string; status: VmStatus; os: string; ip?: string; createdAt: string; }
- src/services/iaas.ts:10-31 (helper)Helper function to create a specialized LiaraClient for IaaS API (different base URL). Used internally by createVM./** * Create a specialized IaaS client with the IaaS API base URL */ function createIaaSClient(client: LiaraClient): LiaraClient { // Access the internal client to get the API token const internalClient = (client as any).client; const apiToken = internalClient?.defaults?.headers?.Authorization?.replace('Bearer ', '') || process.env.LIARA_API_TOKEN; const teamId = (client as any).teamId || process.env.LIARA_TEAM_ID; if (!apiToken) { throw new Error('API token is required for IaaS operations'); } // Create new client with IaaS base URL // Import LiaraClient class dynamically return new LiaraClient({ apiToken, teamId, baseURL: 'https://iaas-api.liara.ir', }); }