Skip to main content
Glama

applications

List, create, update, delete, start, stop, restart Coolify applications and manage their environment variables.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesOperation to perform
idNoApplication UUID
env_idNoEnvironment variable ID
bodyNoJSON request body

Implementation Reference

  • The main handler function for the 'applications' tool. Routes operations (list, get, create, update, delete, start, stop, restart, logs, env management, execute_command) to the appropriate generated SDK functions, with input validation via validateRequiredParams, parseJsonBody, and validateCoolifyId.
    export async function applicationsHandler(args: ApplicationsToolArgs) {
      try {
        const { operation, id, env_id, body } = args;
        
        // Validate operation
        validateOperation(operation, ALLOWED_OPERATIONS);
        
        // Route to appropriate generated service method with proper validation
        switch (operation) {
          case 'list':
            return await safeApiCall(() => listApplications());
            
          case 'get':
            validateRequiredParams({ id }, ['id']);
            validateCoolifyId(id!, 'id');
            return await safeApiCall(() => getApplicationByUuid({ path: { uuid: id! } }));
            
          case 'create_public':
            validateRequiredParams({ body }, ['body']);
            const createPublicData = parseJsonBody(body);
            return await safeApiCall(() => createPublicApplication({ body: createPublicData }));
            
          case 'create_private_gh':
            validateRequiredParams({ body }, ['body']);
            const createPrivateGhData = parseJsonBody(body);
            return await safeApiCall(() => createPrivateGithubAppApplication({ body: createPrivateGhData }));
            
          case 'create_private_key':
            validateRequiredParams({ body }, ['body']);
            const createPrivateKeyData = parseJsonBody(body);
            return await safeApiCall(() => createPrivateDeployKeyApplication({ body: createPrivateKeyData }));
            
          case 'create_dockerfile':
            validateRequiredParams({ body }, ['body']);
            const createDockerfileData = parseJsonBody(body);
            return await safeApiCall(() => createDockerfileApplication({ body: createDockerfileData }));
            
          case 'create_docker_image':
            validateRequiredParams({ body }, ['body']);
            const createDockerImageData = parseJsonBody(body);
            return await safeApiCall(() => createDockerimageApplication({ body: createDockerImageData }));
            
          case 'create_docker_compose':
            validateRequiredParams({ body }, ['body']);
            const createDockerComposeData = parseJsonBody(body);
            return await safeApiCall(() => createDockercomposeApplication({ body: createDockerComposeData }));
            
          case 'update':
            validateRequiredParams({ id, body }, ['id', 'body']);
            validateCoolifyId(id!, 'id');
            const updateData = parseJsonBody(body);
            return await safeApiCall(() => updateApplicationByUuid({ 
              path: { uuid: id! },
              body: updateData 
            } as any));
            
          case 'delete':
            validateRequiredParams({ id }, ['id']);
            validateCoolifyId(id!, 'id');
            return await safeApiCall(() => deleteApplicationByUuid({ path: { uuid: id! } }));
            
          case 'get_logs':
            validateRequiredParams({ id }, ['id']);
            validateCoolifyId(id!, 'id');
            return await safeApiCall(() => getApplicationLogsByUuid({ path: { uuid: id! } }));
            
          case 'start':
            validateRequiredParams({ id }, ['id']);
            validateCoolifyId(id!, 'id');
            return await safeApiCall(() => startApplicationByUuid({ path: { uuid: id! } }));
            
          case 'stop':
            validateRequiredParams({ id }, ['id']);
            validateCoolifyId(id!, 'id');
            return await safeApiCall(() => stopApplicationByUuid({ path: { uuid: id! } }));
            
          case 'restart':
            validateRequiredParams({ id }, ['id']);
            validateCoolifyId(id!, 'id');
            return await safeApiCall(() => restartApplicationByUuid({ path: { uuid: id! } }));
            
          case 'list_envs':
            validateRequiredParams({ id }, ['id']);
            validateCoolifyId(id!, 'id');
            return await safeApiCall(() => listEnvsByApplicationUuid({ path: { uuid: id! } }));
            
          case 'create_env':
            validateRequiredParams({ id, body }, ['id', 'body']);
            validateCoolifyId(id!, 'id');
            const createEnvData = parseJsonBody(body);
            return await safeApiCall(() => createEnvByApplicationUuid({ 
              path: { uuid: id! }, 
              body: createEnvData 
            }));
            
          case 'update_env':
            validateRequiredParams({ id, env_id, body }, ['id', 'env_id', 'body']);
            validateCoolifyId(id!, 'id');
            validateCoolifyId(env_id!, 'env_id');
            const updateEnvData = parseJsonBody(body);
            return await safeApiCall(() => updateEnvByApplicationUuid({ 
              path: { uuid: id! },
              body: updateEnvData 
            }));
            
          case 'update_envs_bulk':
            validateRequiredParams({ id, body }, ['id', 'body']);
            validateCoolifyId(id!, 'id');
            const updateEnvsBulkData = parseJsonBody(body);
            return await safeApiCall(() => updateEnvsByApplicationUuid({ 
              path: { uuid: id! }, 
              body: updateEnvsBulkData 
            }));
            
          case 'delete_env':
            validateRequiredParams({ id, env_id }, ['id', 'env_id']);
            validateCoolifyId(id!, 'id');
            validateCoolifyId(env_id!, 'env_id');
            return await safeApiCall(() => deleteEnvByApplicationUuid({ 
              path: { uuid: id!, env_uuid: env_id! } 
            }));
            
          case 'execute_command':
            validateRequiredParams({ id, body }, ['id', 'body']);
            validateCoolifyId(id!, 'id');
            const commandData = parseJsonBody(body);
            
            if (!commandData.command) {
              throw new CoolifyError('Command is required in request body');
            }
            
            // Try the undocumented execute endpoint
            try {
              // Since this endpoint isn't in the generated SDK, we'll make a direct fetch call
              const response = await fetch(`${process.env.COOLIFY_API_URL}/api/v1/applications/${id}/execute`, {
                method: 'POST',
                headers: {
                  'Authorization': `Bearer ${process.env.COOLIFY_API_TOKEN}`,
                  'Content-Type': 'application/json',
                  'Accept': 'application/json'
                },
                body: JSON.stringify({ command: commandData.command })
              });
              
              if (!response.ok) {
                if (response.status === 404) {
                  throw new CoolifyError(
                    `Execute command endpoint not available in this Coolify version or application not found. ` +
                    `This feature may not be supported in your Coolify instance.`,
                    404
                  );
                }
                
                const errorText = await response.text();
                throw new CoolifyError(
                  `API request failed: ${response.status} ${response.statusText}. ${errorText}`,
                  response.status
                );
              }
              
              const result = await response.json();
              return { data: result };
              
            } catch (error) {
              if (error instanceof CoolifyError) {
                throw error;
              }
              
              // Handle network errors or other fetch errors
              throw new CoolifyError(
                `Failed to execute command: ${error instanceof Error ? error.message : String(error)}`,
                500,
                { command: commandData.command, applicationId: id }
              );
            }
            
          default:
            // This should never be reached due to validateOperation above
            throw new CoolifyError(`Unhandled operation: ${operation}`);
        }
      } catch (error) {
        // Re-throw CoolifyError instances as-is, wrap others
        if (error instanceof CoolifyError) {
          throw error;
        }
        throw new CoolifyError(
          `Applications tool error: ${error instanceof Error ? error.message : String(error)}`,
          500,
          { operation: args.operation, originalError: error }
        );
      }
    } 
  • Zod schema for the applications tool input. Defines operations (enum of 19 operations), id, env_id, and body as optional string parameters.
    export const applicationsToolSchema = z.object({
      operation: z.enum([
        'list', 'get', 'create_public', 'create_private_gh', 'create_private_key',
        'create_dockerfile', 'create_docker_image', 'create_docker_compose', 
        'update', 'delete', 'get_logs', 'start', 'stop', 'restart',
        'list_envs', 'create_env', 'update_env', 'update_envs_bulk', 'delete_env',
        'execute_command'
      ]).describe("Operation to perform"),
      id: z.string().optional().describe("Application UUID"),
      env_id: z.string().optional().describe("Environment variable ID"),
      body: z.string().optional().describe("JSON request body")
    });
  • Registration of the 'applications' tool with the MCP server. Defines the schema inline and calls applicationsHandler, wrapping the result in MCP content response format.
    // Register applications tool with proper Zod schema format
    server.tool(
      'applications',
      {
        operation: z.enum([
          'list', 'get', 'create_public', 'create_private_gh', 'create_private_key',
          'create_dockerfile', 'create_docker_image', 'create_docker_compose',
          'update', 'delete', 'get_logs', 'start', 'stop', 'restart',
          'list_envs', 'create_env', 'update_env', 'update_envs_bulk', 'delete_env'
        ]).describe("Operation to perform"),
        id: z.string().optional().describe("Application UUID"),
        env_id: z.string().optional().describe("Environment variable ID"),
        body: z.string().optional().describe("JSON request body")
      },
      async ({ operation, id, env_id, body }) => {
        try {
          console.error('Applications tool received args:', JSON.stringify({ operation, id, env_id, body }, null, 2));
          
          const result = await applicationsHandler({ 
            operation, 
            id, 
            env_id, 
            body 
          });
          return {
            content: [{ 
              type: 'text', 
              text: JSON.stringify(result, null, 2) 
            }]
          };
        } catch (error) {
          return {
            content: [{ 
              type: 'text', 
              text: `Error: ${error instanceof Error ? error.message : String(error)}` 
            }],
            isError: true
          };
        }
      }
    );
  • Imports from generated SDK (listApplications, getApplicationByUuid, etc.), core utilities (safeApiCall), and error handling helpers (validateRequiredParams, parseJsonBody, validateCoolifyId, CoolifyError) used by the handler.
    import { z } from 'zod';
    import {
      listApplications,
      getApplicationByUuid,
      createPublicApplication,
      createPrivateGithubAppApplication,
      createPrivateDeployKeyApplication,
      createDockerfileApplication,
      createDockerimageApplication,
      createDockercomposeApplication,
      updateApplicationByUuid,
      deleteApplicationByUuid,
      getApplicationLogsByUuid,
      startApplicationByUuid,
      stopApplicationByUuid,
      restartApplicationByUuid,
      listEnvsByApplicationUuid,
      createEnvByApplicationUuid,
      updateEnvByApplicationUuid,
      updateEnvsByApplicationUuid,
      deleteEnvByApplicationUuid
    } from '../../generated/sdk.gen.js';
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/FelixAllistar/coolify-mcp'

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