Skip to main content
Glama

liara_delete_env_vars

Remove environment variables from a Liara cloud application to manage configuration settings and maintain security.

Instructions

Delete/unset multiple environment variables for an app

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
appNameYesThe name of the app
keysYesArray of variable names to delete

Implementation Reference

  • Core handler function for the liara_delete_env_vars tool. Fetches current environment variables for the app, filters out the specified keys to delete, constructs an update request with remaining variables, and sends it to the Liara API to effectively delete the specified env vars.
    export async function deleteEnvVars( client: LiaraClient, appName: string, keys: string[] ): Promise<{ message: string }> { validateAppName(appName); validateRequired(keys, 'Environment variable keys'); if (keys.length === 0) { throw new Error('At least one environment variable key is required'); } // Get current env vars const currentVars = await getEnvVars(client, appName); // Filter out the keys to delete const updatedVars = currentVars.filter(v => !keys.includes(v.key)); // Update with remaining vars const request: UpdateEnvsRequest = { project: appName, variables: updatedVars, }; return await client.post<{ message: string }>('/v1/projects/update-envs', request); }
  • Type definition for individual environment variables, used in fetching and updating env vars.
    export interface EnvironmentVariable { key: string; value: string; }
  • Request type for updating environment variables via the Liara API, used by the delete handler to set the remaining vars.
    export interface UpdateEnvsRequest { project: string; variables: EnvironmentVariable[]; }
  • Helper function to retrieve current environment variables for an app, called by the delete handler to determine which vars to keep.
    export async function getEnvVars( client: LiaraClient, appName: string ): Promise<EnvironmentVariable[]> { validateAppName(appName); try { const project = await client.get<{ envs?: Array<{ key?: string; name?: string; value?: string }>; envVars?: Array<{ key?: string; name?: string; value?: string }>; project?: { envs?: Array<{ key?: string; name?: string; value?: string }> }; }>(`/v1/projects/${appName}`); // API returns 'envs' array in project object const envs = project.envs || project.envVars || project.project?.envs || []; // Map to EnvironmentVariable format (extract key and value) return envs.map((env) => ({ key: env.key || env.name || '', value: env.value || '', })); } catch (error: unknown) { const err = error as { statusCode?: number }; if (err.statusCode === 404) { const { LiaraMcpError } = await import('../utils/errors.js'); throw new LiaraMcpError( `App "${appName}" not found`, 'APP_NOT_FOUND', { appName }, [ 'Check if the app name is correct', 'Use liara_list_apps to see all available apps', 'Verify you have access to this app' ] ); } throw error; } }
  • Validation helper for environment variable keys, though not directly called in deleteEnvVars (used in set/update).
    export function validateEnvKey(key: string): void { validateRequired(key, 'Environment variable key'); if (!/^[A-Z_][A-Z0-9_]*$/.test(key)) { throw new LiaraMcpError( 'Environment variable key must start with a letter or underscore and contain only uppercase letters, numbers, and underscores' ); } }

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