/** * Coolify service for MCP server and CLI. * * Provides all Coolify API operations for deployment management. * * @module */ import { type Result } from "@mks2508/no-throw"; import { type ICoolifyAppOptions, type ICoolifyAppResult, type ICoolifyApplication, type ICoolifyDatabase, type ICoolifyDatabaseBackup, type ICoolifyDeleteResult, type ICoolifyDeployment, type ICoolifyDeployOptions, type ICoolifyDeployResult, type ICoolifyDestination, type ICoolifyEnvironment, type ICoolifyGithubApp, type ICoolifyLogs, type ICoolifyLogsOptions, type ICoolifyPrivateKey, type ICoolifyProject, type ICoolifyServer, type ICoolifyServerDomain, type ICoolifyServerResource, type ICoolifyService as ICoolifyServiceType, type ICoolifyTeam, type ICoolifyUpdateOptions, type ICoolifyVersion, type ICoolifyInfrastructureTree, type IProgressCallback } from "./types.js"; /** * Environment variable from Coolify API. */ export interface ICoolifyEnvVar { uuid: string; key: string; value: string; real_value?: string; is_buildtime: boolean; is_runtime: boolean; is_required: boolean; } /** * Coolify service for deployment operations. * * @example * ```typescript * const coolify = new CoolifyService() * const initResult = await coolify.init() * if (initResult.isErr()) { * console.error(initResult.error.message) * return * } * * const deployResult = await coolify.deploy({ uuid: 'app-uuid' }) * if (deployResult.isOk()) { * console.log('Deployment UUID:', deployResult.value.deploymentUuid) * } * ``` */ export declare class CoolifyService { private baseUrl; private token; private config; /** * Checks if the service is configured with URL and token. * * @returns true if both URL and token are set */ isConfigured(): boolean; /** * Initializes the Coolify service by loading configuration. * * @returns Result indicating success or error */ init(): Promise>; /** * Makes a request to the Coolify API. * * @param endpoint - API endpoint * @param options - Fetch options * @returns API response with data or error */ private request; /** * Deploys an application. * * @param options - Deployment options * @param onProgress - Optional progress callback (0-100, message, step) * @returns Result with deployment info or error */ deploy(options: ICoolifyDeployOptions, onProgress?: IProgressCallback): Promise>; /** * Creates a new application in Coolify. * * Uses type-specific endpoints for different application types: * - /applications/public - Public Git repository * - /applications/private-github-app - Private repo with GitHub App * - /applications/private-deploy-key - Private repo with deploy key * - /applications/dockerfile - Dockerfile-based application * - /applications/docker-image - Docker image * - /applications/docker-compose - Docker Compose application * * @param options - Application options * @param onProgress - Optional progress callback (0-100, message, step) * @returns Result with application UUID or error */ createApplication(options: ICoolifyAppOptions, onProgress?: IProgressCallback): Promise>; /** * Sets environment variables for an application. * * Delegates to {@link bulkUpdateEnvironmentVariables} so the same * create-or-update logic applies. This fixes the post-delete scenario * (where the variable was deleted via the API and only its base value * from docker-compose/git remains visible) and prevents duplicates * that the singular POST endpoint would create when called for a key * that already exists. Also eliminates the N+1 API calls and the * TOCTOU race between the DELETE and the re-POST that the previous * per-key POST -> DELETE -> re-POST dance had. * * @param appUuid - Application UUID * @param envVars - Environment variables to set * @returns Result indicating success or error */ setEnvironmentVariables(appUuid: string, envVars: Record): Promise>; /** * Gets environment variables for an application. * * @param appUuid - Application UUID * @returns Result with environment variables or error */ getEnvironmentVariables(appUuid: string): Promise>; /** * Sets a single environment variable for an application. * * Delegates to {@link bulkUpdateEnvironmentVariables} so the same * create-or-update logic applies. This fixes the post-delete scenario * (where the variable was deleted via the API and only its base value * from docker-compose/git remains visible) and prevents duplicates * that the singular PATCH endpoint would create when called without * the variable's UUID. * * @param appUuid - Application UUID * @param key - Variable name * @param value - Variable value * @param isBuildTime - Whether the variable is available at build time * (only for new vars; existing runtime-only vars will be flipped to * build-time and vice versa). * @returns Result indicating success or error */ setEnvironmentVariable(appUuid: string, key: string, value: string, isBuildTime?: boolean): Promise>; /** * Deletes an environment variable from an application. * * @param appUuid - Application UUID * @param key - Variable name to delete * @returns Result indicating success or error */ deleteEnvironmentVariable(appUuid: string, key: string): Promise>; /** * Gets the status of an application. * * @param appUuid - Application UUID * @returns Result with status or error */ getApplicationStatus(appUuid: string): Promise>; /** * Lists available servers in Coolify. * * @param page - Optional page number for pagination * @param perPage - Optional number of items per page * @returns Result with servers or error */ listServers(page?: number, perPage?: number): Promise>; /** * Gets details of a specific server. * * @param serverUuid - Server UUID * @returns Result with server details or error */ getServer(serverUuid: string): Promise>; /** * Lists all GitHub Apps configured in Coolify. * * @param page - Optional page number for pagination * @param perPage - Optional number of items per page * @returns Result with GitHub Apps list or error */ listGithubApps(page?: number, perPage?: number): Promise>; /** * Lists all GitHub Apps configured in Coolify. * Fetches all pages internally and returns a flat list. * * @param perPage - Items per page for each request (default: 50) * @returns Result with all GitHub Apps or error */ listGithubAppsAll(perPage?: number): Promise>; /** * Lists all projects. * * @param page - Optional page number for pagination * @param perPage - Optional number of items per page * @returns Result with projects list or error */ listProjects(page?: number, perPage?: number): Promise>; /** * Creates a new project. * * @param name - Project name * @param description - Optional project description * @returns Result with created project or error */ createProject(name: string, description?: string): Promise>; /** * Gets environments for a project. * * @param projectUuid - Project UUID * @returns Result with environments list or error */ getProjectEnvironments(projectUuid: string): Promise>; /** * Lists all teams. * * @param page - Optional page number for pagination * @param perPage - Optional number of items per page * @returns Result with teams list or error */ listTeams(page?: number, perPage?: number): Promise>; /** * Gets available destinations for a server. * * @param serverUuid - Server UUID * @returns Result with destinations or error */ getServerDestinations(serverUuid: string): Promise>; /** * Lists all applications. * * @param teamId - Optional team ID to filter by * @param projectId - Optional project ID to filter by * @param page - Optional page number for pagination * @param perPage - Optional number of items per page * @returns Result with applications list or error */ listApplications(teamId?: string, projectId?: string, page?: number, perPage?: number): Promise>; /** * Deletes an application. * * @param appUuid - Application UUID * @param options - Delete options for cascade deletion * @returns Result indicating success or error */ deleteApplication(appUuid: string, options?: { deleteConfigurations?: boolean; deleteVolumes?: boolean; dockerCleanup?: boolean; deleteConnectedNetworks?: boolean; }): Promise>; /** * Updates an application configuration. * * @param appUuid - Application UUID * @param options - Update options * @returns Result with updated application or error */ updateApplication(appUuid: string, options: ICoolifyUpdateOptions): Promise>; /** * Gets application logs. * * @param appUuid - Application UUID * @param options - Log retrieval options * @returns Result with logs or error */ getApplicationLogs(appUuid: string, options?: ICoolifyLogsOptions): Promise>; /** * Executes a command on an application's running container. * * @param appUuid - Application UUID * @param command - Shell command to execute * @returns Result with command output or error */ executeCommand(appUuid: string, command: string): Promise>; /** * Bulk updates environment variables for an application. * * Uses the bulk endpoint `PATCH /applications/{appUuid}/envs/bulk` which * has create-or-update semantics: if the variable exists in the override * table, its value is updated; otherwise a new override is created. This * is the only reliable way to update a variable that has been deleted * (i.e. its base value from docker-compose/git is still visible in * `getEnvironmentVariables` but no override row exists). * * @param appUuid - Application UUID * @param envVars - Array of variable definitions to upsert * @returns Result indicating success or error */ bulkUpdateEnvironmentVariables(appUuid: string, envVars: Array<{ key: string; value: string; is_preview?: boolean; is_buildtime?: boolean; is_runtime?: boolean; }>): Promise>; /** * Bulk updates environment variables for a database. * * Uses the bulk endpoint `PATCH /databases/{databaseUuid}/envs/bulk` which * has create-or-update semantics. Note: the database schema is narrower * than applications — it accepts `key`, `value`, `is_literal`, * `is_multiline`, `is_shown_once` but does NOT accept `is_preview`, * `is_buildtime` or `is_runtime` (those flags are application-only). * * @param databaseUuid - Database UUID * @param envVars - Array of variable definitions to upsert * @returns Result indicating success or error */ bulkUpdateDatabaseEnvVars(databaseUuid: string, envVars: Array<{ key: string; value: string; is_literal?: boolean; is_multiline?: boolean; is_shown_once?: boolean; }>): Promise>; /** * Gets deployment history for an application. * * @param appUuid - Application UUID * @returns Result with deployment history or error */ getApplicationDeploymentHistory(appUuid: string): Promise>; /** * Starts a stopped application. * Note: Coolify API uses GET for application start/stop/restart. * * @param appUuid - Application UUID * @param options - Optional start options (force, instant_deploy) * @returns Result with application status or error */ startApplication(appUuid: string, options?: { force?: boolean; instantDeploy?: boolean; }): Promise>; /** * Stops a running application. * Note: Coolify API uses GET for application start/stop/restart. * * @param appUuid - Application UUID * @returns Result with application status or error */ stopApplication(appUuid: string): Promise>; /** * Restarts an application. * Note: Coolify API uses GET for application start/stop/restart. * * @param appUuid - Application UUID * @returns Result with application status or error */ restartApplication(appUuid: string): Promise>; /** * Gets the Coolify server version. * * @returns Result with version info or error */ getVersion(): Promise>; /** * Lists all databases. * * @param page - Optional page number * @param perPage - Optional items per page * @returns Result with databases list or error */ listDatabases(page?: number, perPage?: number): Promise>; /** * Gets details of a specific database. * * @param uuid - Database UUID * @returns Result with database details or error */ getDatabase(uuid: string): Promise>; /** * Creates a database of the specified type. * * @param dbType - Database type (postgresql, mysql, mariadb, mongodb, redis, keydb, clickhouse, dragonfly) * @param data - Database creation data * @returns Result with created database UUID or error */ createDatabase(dbType: string, data: Record): Promise>; /** * Updates a database configuration. * * @param uuid - Database UUID * @param data - Update data * @returns Result with updated database or error */ updateDatabase(uuid: string, data: Record): Promise>; /** * Deletes a database. * * @param uuid - Database UUID * @param options - Delete options for cascade deletion * @returns Result indicating success or error */ deleteDatabase(uuid: string, options?: { deleteConfigurations?: boolean; deleteVolumes?: boolean; dockerCleanup?: boolean; deleteConnectedNetworks?: boolean; }): Promise>; /** * Starts a database. * * @param uuid - Database UUID * @returns Result indicating success or error */ startDatabase(uuid: string): Promise>; /** * Stops a database. * * @param uuid - Database UUID * @returns Result indicating success or error */ stopDatabase(uuid: string): Promise>; /** * Restarts a database. * * @param uuid - Database UUID * @returns Result indicating success or error */ restartDatabase(uuid: string): Promise>; /** * Lists backups for a database. * * @param databaseUuid - Database UUID * @returns Result with backups list or error */ listDatabaseBackups(databaseUuid: string): Promise>; /** * Gets a specific database backup. * * @param databaseUuid - Database UUID * @param backupUuid - Backup UUID * @returns Result with backup details or error */ getDatabaseBackup(databaseUuid: string, backupUuid: string): Promise>; /** * Creates a database backup. * * @param databaseUuid - Database UUID * @param data - Backup creation data * @returns Result with created backup or error */ createDatabaseBackup(databaseUuid: string, data: Record): Promise>; /** * Updates a database backup. * * @param databaseUuid - Database UUID * @param backupUuid - Backup UUID * @param data - Update data * @returns Result indicating success or error */ updateDatabaseBackup(databaseUuid: string, backupUuid: string, data: Record): Promise>; /** * Deletes a database backup. * * @param databaseUuid - Database UUID * @param backupUuid - Backup UUID * @returns Result indicating success or error */ deleteDatabaseBackup(databaseUuid: string, backupUuid: string): Promise>; /** * Lists all services. * * @param page - Optional page number * @param perPage - Optional items per page * @returns Result with services list or error */ listServices(page?: number, perPage?: number): Promise>; /** * Gets details of a specific service. * * @param uuid - Service UUID * @returns Result with service details or error */ getService(uuid: string): Promise>; /** * Creates a new service. * * @param data - Service creation data * @returns Result with created service or error */ createService(data: Record): Promise>; /** * Updates a service configuration. * * @param uuid - Service UUID * @param data - Update data * @returns Result with updated service or error */ updateService(uuid: string, data: Record): Promise>; /** * Deletes a service. * * @param uuid - Service UUID * @param options - Delete options for cascade deletion * @returns Result indicating success or error */ deleteService(uuid: string, options?: { deleteConfigurations?: boolean; deleteVolumes?: boolean; dockerCleanup?: boolean; deleteConnectedNetworks?: boolean; }): Promise>; /** * Gets the full infrastructure tree: Projects → Environments → Resources. * * Fetches all projects, apps, databases, and services in parallel, * then groups them by environment_id into a hierarchical tree. * * @returns Result with the full infrastructure tree or error */ getInfrastructureTree(): Promise>; /** * Starts a service. * Note: Coolify API uses GET for service start/stop/restart. * * @param uuid - Service UUID * @returns Result indicating success or error */ startService(uuid: string): Promise>; /** * Stops a service. * Note: Coolify API uses GET for service start/stop/restart. * * @param uuid - Service UUID * @returns Result indicating success or error */ stopService(uuid: string): Promise>; /** * Restarts a service. * Note: Coolify API uses GET for service start/stop/restart. * * @param uuid - Service UUID * @returns Result indicating success or error */ restartService(uuid: string): Promise>; /** * Lists environment variables for a service. * * @param uuid - Service UUID * @returns Result with env vars list or error */ listServiceEnvVars(uuid: string): Promise>; /** * Bulk updates environment variables for a service. * * Uses the bulk endpoint `PATCH /services/{uuid}/envs/bulk` which has * create-or-update semantics: if the variable exists in the override * table, its value is updated; otherwise a new override is created. * * This is the only reliable way to update a variable that has been * deleted (i.e. its base value from docker-compose/git is still visible * in `listServiceEnvVars` but no override row exists), and the only way * to set the same key twice without the `POST /services/{uuid}/envs` * returning 409 "already exists". * * @param serviceUuid - Service UUID * @param envVars - Array of variable definitions to upsert * @returns Result indicating success or error */ bulkUpdateServiceEnvVars(serviceUuid: string, envVars: Array<{ key: string; value: string; is_preview?: boolean; is_buildtime?: boolean; is_runtime?: boolean; }>): Promise>; /** * Creates an environment variable for a service. * * NOTE: Prefer `bulkUpdateServiceEnvVars` for any non-trivial use case. * This endpoint uses `POST /services/{uuid}/envs` and returns 409 * "already exists" when the key is already present as an override, * with no recovery path on the server side. Bulk has create-or-update * semantics and handles both new and existing keys reliably. * * Kept for callers that explicitly want a strict create-only operation. * * @param uuid - Service UUID * @param data - Env var data (key, value, is_preview) * @returns Result with created env var UUID or error */ createServiceEnvVar(uuid: string, data: { key: string; value: string; is_preview?: boolean; }): Promise>; /** * Deletes an environment variable from a service. * * @param serviceUuid - Service UUID * @param key - Variable name to delete * @returns Result indicating success or error */ deleteServiceEnvVar(serviceUuid: string, key: string): Promise>; /** * Lists environment variables for a database. * * @param databaseUuid - Database UUID * @returns Result with env vars list or error */ listDatabaseEnvVars(databaseUuid: string): Promise>; /** * Deletes an environment variable from a database. * * @param databaseUuid - Database UUID * @param key - Variable name to delete * @returns Result indicating success or error */ deleteDatabaseEnvVar(databaseUuid: string, key: string): Promise>; /** * Gets resources deployed on a server. * * @param serverUuid - Server UUID * @returns Result with server resources or error */ getServerResources(serverUuid: string): Promise>; /** * Gets domains configured on a server. * * @param serverUuid - Server UUID * @returns Result with server domains or error */ getServerDomains(serverUuid: string): Promise>; /** * Validates a server connection. * * @param serverUuid - Server UUID * @returns Result with validation status or error */ validateServer(serverUuid: string): Promise>; /** * Creates a new server. * * @param data - Server creation data * @returns Result with created server UUID or error */ createServer(data: Record): Promise>; /** * Deletes a server. * * @param serverUuid - Server UUID * @returns Result indicating success or error */ deleteServer(serverUuid: string): Promise>; /** * Updates a project. * * @param uuid - Project UUID * @param data - Update data (name, description) * @returns Result with updated project or error */ updateProject(uuid: string, data: { name?: string; description?: string; }): Promise>; /** * Deletes a project. * * @param uuid - Project UUID * @returns Result indicating success or error */ deleteProject(uuid: string): Promise>; /** * Creates a new environment within a project. * * @param projectUuid - Project UUID * @param data - Environment creation data (name, description) * @returns Result with created environment UUID or error */ createProjectEnvironment(projectUuid: string, data: { name: string; description?: string; }): Promise>; /** * Gets the current team. * * @returns Result with current team or error */ getCurrentTeam(): Promise>; /** * Gets a specific team by ID. * * @param id - Team ID * @returns Result with team details or error */ getTeam(id: number): Promise>; /** * Gets members of a specific team. * * @param id - Team ID * @returns Result with team members or error */ getTeamMembers(id: number): Promise, Error>>; /** * Cancels a deployment. * * @param deploymentUuid - Deployment UUID * @returns Result indicating success or error */ cancelDeployment(deploymentUuid: string): Promise>; /** * Lists all private keys. * * @returns Result with private keys list or error */ listPrivateKeys(): Promise>; /** * Gets a specific private key. * * @param uuid - Private key UUID * @returns Result with private key details or error */ getPrivateKey(uuid: string): Promise>; /** * Creates a new private key. * * @param data - Key creation data (name, private_key, description) * @returns Result with created key UUID or error */ createPrivateKey(data: { name: string; private_key: string; description?: string; }): Promise>; /** * Updates a private key. * * @param uuid - Private key UUID * @param data - Update data * @returns Result with updated key or error */ updatePrivateKey(uuid: string, data: { name?: string; private_key?: string; description?: string; }): Promise>; /** * Deletes a private key. * * @param uuid - Private key UUID * @returns Result indicating success or error */ deletePrivateKey(uuid: string): Promise>; /** * Creates a GitHub App configuration. * * @param data - GitHub App creation data * @returns Result with created app or error */ createGitHubApp(data: Record): Promise>; /** * Updates a GitHub App configuration. * * @param id - GitHub App ID * @param data - Update data * @returns Result with updated app or error */ updateGitHubApp(id: number, data: Record): Promise>; /** * Deletes a GitHub App configuration. * * @param id - GitHub App ID * @returns Result indicating success or error */ deleteGitHubApp(id: number): Promise>; /** * Lists all active and queued deployments. * * @param page - Optional page number for pagination * @param perPage - Optional number of items per page * @returns Result with deployments list or error */ listDeployments(page?: number, perPage?: number): Promise>; /** * Gets detailed information about a specific deployment. * * @param deploymentUuid - Deployment UUID * @returns Result with deployment details or error */ getDeployment(deploymentUuid: string): Promise>; /** * Gets logs for a specific deployment. * * @param deploymentUuid - Deployment UUID * @returns Result with deployment status and logs or error */ getDeploymentLogs(deploymentUuid: string): Promise>; /** * Gets deployment history for a specific application. * * @param appUuid - Application UUID * @param skip - Number of deployments to skip * @param take - Number of deployments to return * @returns Result with deployments list or error */ getApplicationDeployments(appUuid: string, skip?: number, take?: number): Promise>; /** * Lists deployments for a specific application. * * Uses the /deployments/applications/{appUuid} endpoint which returns * all deployments (active, queued, and completed) for a single application. * This differs from listDeployments() which returns ALL deployments globally. * * @param appUuid - Application UUID * @returns Result with deployments list or error */ listApplicationDeployments(appUuid: string): Promise>; /** * Gets full application details by UUID. * * Makes a direct GET request to /api/v1/applications/{uuid} which returns * complete application data including project_uuid and environment_uuid. * * @param appUuid - Application UUID * @returns Result with full application details or error */ getApplication(appUuid: string): Promise>; /** * Resolves an application by UUID, name, or domain (FQDN). * * @param query - UUID, name, or domain to search for * @returns Result with application or error */ resolveApplication(query: string): Promise>; /** * Resolves a server by UUID, name, or IP address. * * @param query - UUID, name, or IP to search for * @returns Result with server or error */ resolveServer(query: string): Promise>; /** * Checks if a string looks like a UUID (Coolify or standard format). * * @param query - String to check * @returns true if it looks like a UUID */ private isLikelyUuid; /** * Diagnoses an application by aggregating health, logs, deployments, and env vars. * * @param query - Application UUID, name, or domain * @returns Result with diagnostic report or error */ diagnoseApplication(query: string): Promise>; /** * Diagnoses a server by aggregating health, resources, and domains. * * @param query - Server UUID, name, or IP * @returns Result with diagnostic report or error */ diagnoseServer(query: string): Promise>; /** * Scans all infrastructure for potential issues. * * @returns Result with issues report or error */ findInfrastructureIssues(): Promise; }, Error>>; /** * Restarts all applications in a project. * * @param projectUuid - Project UUID * @returns Result with batch operation results */ restartProjectApps(projectUuid: string): Promise>; /** * Redeploys all applications in a project. * * @param projectUuid - Project UUID * @param force - Force rebuild * @returns Result with batch operation results */ redeployProjectApps(projectUuid: string, force?: boolean): Promise>; /** * Stops all running applications. * * @returns Result with batch operation results */ stopAllApps(): Promise>; /** * Lists applications with minimal fields for token efficiency. * * @returns Result with application summaries or error */ listApplicationSummaries(): Promise, Error>>; /** * Lists servers with minimal fields for token efficiency. * * @returns Result with server summaries or error */ listServerSummaries(): Promise, Error>>; /** * Lists databases with minimal fields for token efficiency. * * @returns Result with database summaries or error */ listDatabaseSummaries(): Promise, Error>>; /** * Lists services with minimal fields for token efficiency. * * @returns Result with service summaries or error */ listServiceSummaries(): Promise, Error>>; } /** * Gets the singleton CoolifyService instance. * * @returns The CoolifyService instance */ export declare function getCoolifyService(): CoolifyService; export type { ICoolifyServer, ICoolifyServerResource, ICoolifyServerDomain, ICoolifyDestination, ICoolifyProject, ICoolifyTeam, ICoolifyApplication, ICoolifyDatabase, ICoolifyDatabaseBackup, ICoolifyService as ICoolifyServiceType, ICoolifyPrivateKey, ICoolifyDeployment, ICoolifyVersion, ICoolifyAppOptions, ICoolifyAppResult, ICoolifyDeployOptions, ICoolifyDeployResult, ICoolifyDeleteResult, ICoolifyUpdateOptions, ICoolifyLogsOptions, ICoolifyLogs, IProgressCallback, ICoolifyInfrastructureTree, ICoolifyProjectNode, ICoolifyEnvironmentNode, ICoolifyResource, } from "./types.js"; //# sourceMappingURL=index.d.ts.map