Skip to main content
Glama

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
NameRequiredDescriptionDefault
nameYesVM name
planIDYesPlan ID for the VM
osYesOperating system
sshKeyNoSSH public key (optional)
networkYesNetwork ID (required by the API)

Implementation Reference

  • 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);
    }
  • Input schema (type definition) for the createVM request parameters.
    export interface CreateVmRequest {
        name: string;
        planID: string;
        os: string;
        sshKey?: string;
        network: string;
    }
  • Output schema for the created VirtualMachine.
    export interface VirtualMachine {
        _id: string;
        name: string;
        planID: string;
        status: VmStatus;
        os: string;
        ip?: string;
        createdAt: string;
    }
  • 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',
        });
    }
Install Server

Other 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/razavioo/liara-mcp'

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