Skip to main content
Glama

liara_deploy_release

Deploy applications on Liara cloud platform using uploaded source code and configure environment variables for deployment management.

Instructions

Deploy a release using a source ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNameYesThe name of the app
sourceIDYesSource ID from previous source upload
envVarsNoOptional environment variables for this deployment

Implementation Reference

  • The main handler function that performs the deploy release operation by calling the Liara API with the provided appName and DeployReleaseRequest containing sourceID and optional envVars.
    export async function deployRelease(
        client: LiaraClient,
        appName: string,
        request: DeployReleaseRequest
    ): Promise<DeployReleaseResponse> {
        validateAppName(appName);
        validateRequired(request.sourceID, 'Source ID');
    
        return await client.post<DeployReleaseResponse>(
            `/v2/projects/${appName}/releases`,
            request
        );
    }
  • Type definitions for the input (DeployReleaseRequest) and output (DeployReleaseResponse) of the deploy release operation.
    export interface DeployReleaseRequest {
        sourceID: string;
        envVars?: EnvironmentVariable[];
    }
    
    export interface DeployReleaseResponse {
        releaseID: string;
    }
  • Supporting function to upload source code (tar.gz) to obtain sourceID required for deployRelease.
    export async function uploadSource(
        client: LiaraClient,
        appName: string,
        filePath: string
    ): Promise<DeploySourceResponse> {
        validateAppName(appName);
        validateRequired(filePath, 'File path');
    
        // Create FormData with file stream
        const formData = new FormData();
        const fileName = filePath.split('/').pop() || 'source.tar.gz';
        formData.append('source', createReadStream(filePath), {
            filename: fileName,
            contentType: 'application/gzip',
        });
    
        return await client.postFormData<DeploySourceResponse>(
            `/v2/projects/${appName}/sources`,
            formData
        );
    }
  • The API client class used by all service functions, including post and postFormData methods for deployment.
    export class LiaraClient {
        private client: AxiosInstance;
        private teamId?: string;
        private maxRetries: number;
        private retryDelay: number;
    
        constructor(config: LiaraClientConfig) {
            const baseURL = config.baseURL || process.env.LIARA_API_BASE_URL || 'https://api.iran.liara.ir';
    
            this.client = axios.create({
                baseURL,
                headers: {
                    'Authorization': `Bearer ${config.apiToken}`,
                    'Content-Type': 'application/json',
                },
                timeout: 30000, // 30 seconds
            });
    
            this.teamId = config.teamId;
            this.maxRetries = config.maxRetries ?? 3;
            this.retryDelay = config.retryDelay ?? 1000;
    
            // Add response interceptor for error handling
            this.client.interceptors.response.use(
                (response) => response,
                (error: AxiosError<LiaraApiError>) => {
                    return Promise.reject(this.handleError(error));
                }
            );
        }
    
        /**
         * Sleep for a given number of milliseconds
         */
        private sleep(ms: number): Promise<void> {
            return new Promise(resolve => setTimeout(resolve, ms));
        }
    
        /**
         * Execute request with retry logic for rate limiting
         */
        private async executeWithRetry<T>(
            requestFn: () => Promise<T>,
            retryCount = 0
        ): Promise<T> {
            try {
                return await requestFn();
            } catch (error: unknown) {
                const err = error as { statusCode?: number; response?: { status?: number } };
                // Retry on rate limiting (429) or server errors (5xx)
                const statusCode = err.statusCode || err.response?.status;
                const isRetryable = statusCode === 429 || (statusCode !== undefined && statusCode >= 500 && statusCode < 600);
                
                if (isRetryable && retryCount < this.maxRetries) {
                    // Exponential backoff: 1s, 2s, 4s...
                    const delay = this.retryDelay * Math.pow(2, retryCount);
                    await this.sleep(delay);
                    return this.executeWithRetry(requestFn, retryCount + 1);
                }
                
                throw error;
            }
        }
    
        /**
         * Handle API errors and convert to user-friendly messages
         */
        private handleError(error: AxiosError<LiaraApiError>): Error {
            if (error.response) {
                const status = error.response.status;
                const data = error.response.data;
    
                let message = data?.message || data?.error || 'Unknown API error';
    
                switch (status) {
                    case 401:
                        message = 'Authentication failed. Please check your API token.';
                        break;
                    case 403:
                        message = 'Access forbidden. You may not have permission for this operation.';
                        break;
                    case 404:
                        message = data?.message || 'Resource not found.';
                        break;
                    case 409:
                        message = data?.message || 'Conflict: Resource already exists or operation cannot be completed.';
                        break;
                    case 429:
                        message = 'Rate limit exceeded. Please try again later.';
                        break;
                    case 500:
                    case 502:
                    case 503:
                        message = 'Liara API is temporarily unavailable. Please try again later.';
                        break;
                }
    
                const apiError = new Error(message);
                (apiError as any).statusCode = status;
                (apiError as any).originalError = data;
                return apiError;
            } else if (error.request) {
                return new Error('Unable to connect to Liara API. Please check your internet connection.');
            } else {
                return new Error(error.message || 'An unexpected error occurred.');
            }
        }
    
        /**
         * Add team ID parameter to request if configured
         */
        private addTeamId(params: Record<string, unknown> = {}): Record<string, unknown> {
            if (this.teamId) {
                return { ...params, teamID: this.teamId };
            }
            return params;
        }
    
        /**
         * GET request with automatic retry for rate limiting
         */
        async get<T>(url: string, params?: Record<string, string | number | boolean>): Promise<T> {
            return this.executeWithRetry(async () => {
                const response = await this.client.get<T>(url, {
                    params: this.addTeamId(params) as Record<string, string | number | boolean>
                });
                return response.data;
            });
        }
    
        /**
         * POST request with automatic retry for rate limiting
         */
        async post<T>(url: string, data?: unknown, params?: Record<string, string | number | boolean>): Promise<T> {
            return this.executeWithRetry(async () => {
                const response = await this.client.post<T>(url, data, {
                    params: this.addTeamId(params) as Record<string, string | number | boolean>
                });
                return response.data;
            });
        }
    
        /**
         * PUT request with automatic retry for rate limiting
         */
        async put<T>(url: string, data?: unknown, params?: Record<string, string | number | boolean>): Promise<T> {
            return this.executeWithRetry(async () => {
                const response = await this.client.put<T>(url, data, {
                    params: this.addTeamId(params) as Record<string, string | number | boolean>
                });
                return response.data;
            });
        }
    
        /**
         * DELETE request with automatic retry for rate limiting
         */
        async delete<T>(url: string, params?: Record<string, string | number | boolean>): Promise<T> {
            return this.executeWithRetry(async () => {
                const response = await this.client.delete<T>(url, {
                    params: this.addTeamId(params) as Record<string, string | number | boolean>
                });
                return response.data;
            });
        }
    
        /**
         * POST multipart/form-data request with automatic retry for rate limiting
         */
        async postFormData<T>(url: string, formData: { getHeaders?: () => Record<string, string> }, params?: Record<string, string | number | boolean>): Promise<T> {
            return this.executeWithRetry(async () => {
                // form-data sets its own Content-Type with boundary, so we use its headers
                const headers = formData.getHeaders ? formData.getHeaders() : {
                    'Content-Type': 'multipart/form-data',
                };
                
                const response = await this.client.post<T>(url, formData, {
                    params: this.addTeamId(params),
                    headers: {
                        ...headers,
                        'Authorization': this.client.defaults.headers['Authorization'],
                    },
                    maxContentLength: Infinity,
                    maxBodyLength: Infinity,
                });
                return response.data;
            });
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the action without details. It doesn't cover critical aspects like whether this is a mutating operation (likely yes, given 'deploy'), potential side effects (e.g., downtime, environment changes), authentication needs, rate limits, or response format. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, direct sentence with zero wasted words. It's front-loaded with the core action ('Deploy a release') and efficiently states the key input ('using a source ID'), making it easy to parse quickly without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a deployment operation likely involving mutating changes), lack of annotations, and no output schema, the description is insufficient. It doesn't explain what 'deploy' entails, potential impacts, or return values, leaving the agent with inadequate context to use the tool safely and effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the parameters (appName, sourceID, envVars). The description adds no additional meaning beyond implying 'sourceID' comes from a previous upload, which is minimal value. This meets the baseline of 3, as the schema handles the heavy lifting without description enhancement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the action ('Deploy a release') and mentions the resource ('using a source ID'), which provides a basic purpose. However, it lacks specificity about what 'deploy' entails (e.g., activating a release, triggering a build) and doesn't distinguish it from sibling tools like 'liara_rollback_release' or 'liara_start_app', leaving ambiguity about its unique function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an uploaded source via 'liara_upload_source'), exclusions, or comparisons to related tools like 'liara_rollback_release' or 'liara_restart_app', leaving the agent to infer usage context without explicit direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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