Skip to main content
Glama

liara_create_mail_server

Create a new mail server on Liara cloud platform by specifying domain, plan, and mode for email hosting setup.

Instructions

Create a new mail server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoMail server name
modeNoMail server mode
planIDYesPlan ID for the mail server (required)
domainYesDomain name for the mail server (required)

Implementation Reference

  • The core handler function that implements the logic to create a new mail server on Liara by posting to the mail service API endpoint with validated parameters (domain required, planID required, mode defaults to DEV). Returns the created MailServer object.
     * Create a new mail server
     */
    export async function createMailServer(
        client: LiaraClient,
        _name: string,
        mode?: 'DEV' | 'LIVE',
        planID?: string,
        domain?: string
    ): Promise<MailServer> {
        // Note: '_name' parameter is kept for backward compatibility but not sent to API
        validateRequired(planID, 'Plan ID');
        validateRequired(domain, 'Domain');
        const requestBody: { mode?: 'DEV' | 'LIVE'; plan?: string; planID?: string; domain?: string } = { 
            domain: domain!,
        };
        if (mode) {
            requestBody.mode = mode;
        } else {
            // Default to 'DEV' if mode is not provided
            requestBody.mode = 'DEV';
        }
        if (planID) {
            requestBody.plan = planID;
            requestBody.planID = planID;
        }
        const mailClient = createMailClient(client);
        const response = await mailClient.post<any>('/v1/mails', requestBody);
        return unwrapApiResponse<MailServer>(response, ['mail', 'mailServer', 'data']);
    }
  • TypeScript interface defining the structure of a MailServer object, which is the output type of the createMailServer function.
    export interface MailServer {
        _id: string;
        name: string;
        mode: 'DEV' | 'LIVE';
        status: 'ACTIVE' | 'INACTIVE';
        createdAt: string;
    }
  • Helper function that creates a specialized LiaraClient for the Mail service API with the correct baseURL and inherited authentication.
    function createMailClient(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 Mail operations');
        }
    
        // Create new client with Mail service base URL
        return new LiaraClient({
            apiToken,
            teamId,
            baseURL: 'https://mail-service.liara.ir/api',
        });
    }
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