@mks2508/coolify-mks-cli-mcp 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17173,7 +17173,7 @@ class CoolifyService {
17173
17173
  const parsed = data;
17174
17174
  let errorMessage = parsed?.message || `HTTP ${response.status}`;
17175
17175
  if (parsed?.errors) {
17176
- const details = Object.entries(parsed.errors).map(([field, reasons]) => `${field}: ${reasons.join(", ")}`).join("; ");
17176
+ const details = Object.entries(parsed.errors).map(([field, reasons]) => `${field}: ${Array.isArray(reasons) ? reasons.join(", ") : String(reasons)}`).join("; ");
17177
17177
  errorMessage += ` — ${details}`;
17178
17178
  }
17179
17179
  return { error: errorMessage, status: response.status, durationMs };
@@ -17247,7 +17247,10 @@ class CoolifyService {
17247
17247
  };
17248
17248
  if (appType === "public" || appType === "private-github-app" || appType === "private-deploy-key") {
17249
17249
  if (options.githubRepoUrl) {
17250
- body.git_repository = options.githubRepoUrl;
17250
+ body.git_repository = options.githubRepoUrl.replace(/^https?:\/\/github\.com\//, "").replace(/\.git$/, "");
17251
+ }
17252
+ if (options.githubAppUuid) {
17253
+ body.github_app_uuid = options.githubAppUuid;
17251
17254
  }
17252
17255
  body.git_branch = options.branch || "main";
17253
17256
  body.build_pack = options.buildPack || "dockerfile";
@@ -17286,21 +17289,24 @@ class CoolifyService {
17286
17289
  });
17287
17290
  }
17288
17291
  async setEnvironmentVariables(appUuid, envVars) {
17289
- log.info(`Setting environment variables for ${appUuid}`);
17290
- const envArray = Object.entries(envVars).map(([key, value]) => ({
17291
- key,
17292
- value,
17293
- is_build_time: false
17294
- }));
17295
- const result = await this.request(`/applications/${appUuid}/envs`, {
17296
- method: "POST",
17297
- body: JSON.stringify({ data: envArray })
17298
- });
17299
- if (result.error) {
17300
- log.error(`Failed to set env vars: ${result.error}`);
17301
- return err(new Error(result.error));
17292
+ log.info(`Setting ${Object.keys(envVars).length} environment variables for ${appUuid}`);
17293
+ for (const [key, value] of Object.entries(envVars)) {
17294
+ const result = await this.request(`/applications/${appUuid}/envs`, {
17295
+ method: "POST",
17296
+ body: JSON.stringify({
17297
+ key,
17298
+ value,
17299
+ is_preview: false,
17300
+ is_build_time: false,
17301
+ is_literal: false
17302
+ })
17303
+ });
17304
+ if (result.error) {
17305
+ log.error(`Failed to set env var ${key}: ${result.error}`);
17306
+ return err(new Error(`Failed to set ${key}: ${result.error}`));
17307
+ }
17302
17308
  }
17303
- log.success("Environment variables set");
17309
+ log.success(`${Object.keys(envVars).length} environment variables set`);
17304
17310
  return ok(undefined);
17305
17311
  }
17306
17312
  async getEnvironmentVariables(appUuid) {
@@ -17389,6 +17395,12 @@ class CoolifyService {
17389
17395
  log.success(`Server details retrieved: ${serverUuid}`);
17390
17396
  return ok(result.data);
17391
17397
  }
17398
+ async listGithubApps() {
17399
+ const result = await this.request("/github-apps");
17400
+ if (result.error)
17401
+ return err(new Error(result.error));
17402
+ return ok(result.data || []);
17403
+ }
17392
17404
  async listProjects() {
17393
17405
  const result = await this.request("/projects");
17394
17406
  if (result.error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mks2508/coolify-mks-cli-mcp",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "MCP server and CLI for Coolify deployment management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -169,7 +169,7 @@ export class CoolifyService {
169
169
  // Include validation errors if present (Coolify returns { message, errors: { field: [reasons] } })
170
170
  if (parsed?.errors) {
171
171
  const details = Object.entries(parsed.errors)
172
- .map(([field, reasons]) => `${field}: ${reasons.join(', ')}`)
172
+ .map(([field, reasons]) => `${field}: ${Array.isArray(reasons) ? reasons.join(', ') : String(reasons)}`)
173
173
  .join('; ')
174
174
  errorMessage += ` — ${details}`
175
175
  }
@@ -300,7 +300,13 @@ export class CoolifyService {
300
300
  // Type-specific fields
301
301
  if (appType === 'public' || appType === 'private-github-app' || appType === 'private-deploy-key') {
302
302
  if (options.githubRepoUrl) {
303
+ // Coolify expects 'user/repo' format, not full URL
303
304
  body.git_repository = options.githubRepoUrl
305
+ .replace(/^https?:\/\/github\.com\//, '')
306
+ .replace(/\.git$/, '')
307
+ }
308
+ if (options.githubAppUuid) {
309
+ body.github_app_uuid = options.githubAppUuid
304
310
  }
305
311
  body.git_branch = options.branch || 'main'
306
312
  body.build_pack = options.buildPack || 'dockerfile'
@@ -356,25 +362,28 @@ export class CoolifyService {
356
362
  appUuid: string,
357
363
  envVars: Record<string, string>
358
364
  ): Promise<Result<void, Error>> {
359
- log.info(`Setting environment variables for ${appUuid}`)
360
-
361
- const envArray = Object.entries(envVars).map(([key, value]) => ({
362
- key,
363
- value,
364
- is_build_time: false,
365
- }))
365
+ log.info(`Setting ${Object.keys(envVars).length} environment variables for ${appUuid}`)
366
366
 
367
- const result = await this.request(`/applications/${appUuid}/envs`, {
368
- method: 'POST',
369
- body: JSON.stringify({ data: envArray }),
370
- })
367
+ // Coolify API accepts one env var per POST request
368
+ for (const [key, value] of Object.entries(envVars)) {
369
+ const result = await this.request(`/applications/${appUuid}/envs`, {
370
+ method: 'POST',
371
+ body: JSON.stringify({
372
+ key,
373
+ value,
374
+ is_preview: false,
375
+ is_build_time: false,
376
+ is_literal: false,
377
+ }),
378
+ })
371
379
 
372
- if (result.error) {
373
- log.error(`Failed to set env vars: ${result.error}`)
374
- return err(new Error(result.error))
380
+ if (result.error) {
381
+ log.error(`Failed to set env var ${key}: ${result.error}`)
382
+ return err(new Error(`Failed to set ${key}: ${result.error}`))
383
+ }
375
384
  }
376
385
 
377
- log.success('Environment variables set')
386
+ log.success(`${Object.keys(envVars).length} environment variables set`)
378
387
  return ok(undefined)
379
388
  }
380
389
 
@@ -553,6 +562,17 @@ export class CoolifyService {
553
562
  return ok(result.data as ICoolifyServer)
554
563
  }
555
564
 
565
+ /**
566
+ * Lists all GitHub Apps configured in Coolify.
567
+ *
568
+ * @returns Result with GitHub Apps list or error
569
+ */
570
+ async listGithubApps(): Promise<Result<Array<{ id: number; uuid: string; name: string; is_public: boolean }>, Error>> {
571
+ const result = await this.request<Array<{ id: number; uuid: string; name: string; is_public: boolean }>>('/github-apps')
572
+ if (result.error) return err(new Error(result.error))
573
+ return ok(result.data || [])
574
+ }
575
+
556
576
  /**
557
577
  * Lists all projects.
558
578
  *
@@ -50,6 +50,8 @@ export interface ICoolifyAppOptions {
50
50
  destinationUuid?: string
51
51
  /** Application type */
52
52
  type?: TCoolifyApplicationType
53
+ /** GitHub App UUID (required for private-github-app type — get from listGithubApps) */
54
+ githubAppUuid?: string
53
55
  /** GitHub repository URL (for git-based apps) */
54
56
  githubRepoUrl?: string
55
57
  /** Git branch */