@mks2508/coolify-mks-cli-mcp 0.6.1 → 0.6.2

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.
package/dist/cli/index.js CHANGED
@@ -14257,15 +14257,39 @@ var dbListCommand = () => runList("database(s)", (s) => s.databases.list(), [
14257
14257
  ]);
14258
14258
  var dbGetCommand = (uuid) => runGet(uuid, "database", (s, u) => s.databases.get(u), (db) => {
14259
14259
  console.log(source_default.cyan("Database Details:"));
14260
- console.log(source_default.gray("UUID: ") + db.uuid);
14261
- console.log(source_default.gray("Name: ") + db.name);
14262
- console.log(source_default.gray("Type: ") + (db.type || "-"));
14263
- console.log(source_default.gray("Status: ") + formatStatus(db.status));
14260
+ console.log(source_default.gray("UUID: ") + db.uuid);
14261
+ console.log(source_default.gray("Name: ") + db.name);
14262
+ console.log(source_default.gray("Type: ") + (db.type || "-"));
14263
+ console.log(source_default.gray("Status: ") + formatStatus(db.status));
14264
+ console.log(source_default.gray("Version: ") + (db.version || "-"));
14264
14265
  });
14266
+ async function dbCreateCommand(type, options) {
14267
+ try {
14268
+ const data = {
14269
+ server_uuid: options.server,
14270
+ project_uuid: options.project
14271
+ };
14272
+ if (options.environment)
14273
+ data.environment_name = options.environment;
14274
+ if (options.name)
14275
+ data.name = options.name;
14276
+ console.log(source_default.cyan(`Creating ${type} database...`));
14277
+ const result = await getCliSdk().databases.create(type, data);
14278
+ console.log(source_default.green(`Database created! UUID: ${source_default.cyan(result.uuid)}`));
14279
+ } catch (error) {
14280
+ console.error(source_default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
14281
+ }
14282
+ }
14265
14283
  var dbStartCommand = (uuid) => runAction(uuid, "Starting database", (s, u) => s.databases.start(u), (u) => `Database started: ${u}`);
14266
14284
  var dbStopCommand = (uuid) => runAction(uuid, "Stopping database", (s, u) => s.databases.stop(u), (u) => `Database stopped: ${u}`);
14267
14285
  var dbRestartCommand = (uuid) => runAction(uuid, "Restarting database", (s, u) => s.databases.restart(u), (u) => `Database restarted: ${u}`);
14268
14286
  var dbDeleteCommand = (uuid) => runAction(uuid, "Deleting database", (s, u) => s.databases.delete(u), (u) => `Database deleted: ${u}`);
14287
+ var dbBackupsCommand = (uuid) => runList("backup(s)", (s) => s.databases.backups(uuid), [
14288
+ { header: "UUID", value: (b) => b.uuid },
14289
+ { header: "Status", value: (b) => formatStatus(b.status) },
14290
+ { header: "Created", value: (b) => new Date(b.created_at).toLocaleString() },
14291
+ { header: "Size", value: (b) => b.size ? `${(b.size / 1024 / 1024).toFixed(1)}MB` : "-" }
14292
+ ]);
14269
14293
 
14270
14294
  // src/cli/commands/svc.ts
14271
14295
  var svcListCommand = () => runList("service(s)", (s) => s.services.list(), [
@@ -14285,6 +14309,25 @@ var svcStartCommand = (uuid) => runAction(uuid, "Starting service", (s, u) => s.
14285
14309
  var svcStopCommand = (uuid) => runAction(uuid, "Stopping service", (s, u) => s.services.stop(u), (u) => `Service stopped: ${u}`);
14286
14310
  var svcRestartCommand = (uuid) => runAction(uuid, "Restarting service", (s, u) => s.services.restart(u), (u) => `Service restarted: ${u}`);
14287
14311
  var svcDeleteCommand = (uuid) => runAction(uuid, "Deleting service", (s, u) => s.services.delete(u), (u) => `Service deleted: ${u}`);
14312
+ var svcEnvCommand = (uuid) => runList("env var(s)", (s) => s.services.envVars(uuid), [
14313
+ { header: "Key", value: (e) => e.key },
14314
+ { header: "Value", value: (e) => e.value },
14315
+ { header: "Runtime", value: (e) => e.is_runtime ? "Yes" : "No" }
14316
+ ]);
14317
+ async function svcSetEnvCommand(uuid, keyValue) {
14318
+ const [key, ...rest] = keyValue.split("=");
14319
+ const value = rest.join("=");
14320
+ if (!key || value === undefined) {
14321
+ console.error(source_default.red("Error: Use format KEY=VALUE"));
14322
+ return;
14323
+ }
14324
+ try {
14325
+ await getCliSdk().services.setEnv(uuid, { key, value });
14326
+ console.log(source_default.green(`✓ Set ${source_default.bold(key)} for service ${uuid}`));
14327
+ } catch (error) {
14328
+ console.error(source_default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
14329
+ }
14330
+ }
14288
14331
 
14289
14332
  // src/cli/commands/keys.ts
14290
14333
  var keysListCommand = () => runList("key(s)", (s) => s.keys.list(), [
@@ -14302,6 +14345,27 @@ var keysGetCommand = (uuid) => runGet(uuid, "private key", (s, u) => s.keys.get(
14302
14345
  console.log(source_default.gray("Name: ") + key.name);
14303
14346
  console.log(source_default.gray("Git-related:") + (key.is_git_related ? " Yes" : " No"));
14304
14347
  });
14348
+ async function keysCreateCommand(name, options) {
14349
+ try {
14350
+ let privateKey = options.key || "";
14351
+ if (options.file) {
14352
+ const { readFileSync: readFileSync2 } = await import("node:fs");
14353
+ privateKey = readFileSync2(options.file, "utf-8");
14354
+ }
14355
+ if (!privateKey) {
14356
+ console.error(source_default.red("Error: Provide --key <value> or --file <path>"));
14357
+ return;
14358
+ }
14359
+ const result = await getCliSdk().keys.create({
14360
+ name,
14361
+ private_key: privateKey,
14362
+ description: options.description
14363
+ });
14364
+ console.log(source_default.green(`Private key created! UUID: ${source_default.cyan(result.uuid)}`));
14365
+ } catch (error) {
14366
+ console.error(source_default.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
14367
+ }
14368
+ }
14305
14369
  var keysDeleteCommand = (uuid) => runAction(uuid, "Deleting private key", (s, u) => s.keys.delete(u), (u) => `Private key deleted: ${u}`);
14306
14370
 
14307
14371
  // src/cli/commands/teams.ts
@@ -14605,10 +14669,12 @@ program2.command("server-resources <server-uuid>").description("List resources d
14605
14669
  var db = program2.command("db").description("Manage databases");
14606
14670
  db.command("list").description("List all databases").action(dbListCommand);
14607
14671
  db.command("get <uuid>").description("Get database details").action(dbGetCommand);
14672
+ db.command("create <type>").description("Create database (postgresql, mysql, mariadb, mongodb, redis, keydb, clickhouse, dragonfly)").requiredOption("--server <uuid>", "Server UUID").requiredOption("--project <uuid>", "Project UUID").option("--environment <name>", "Environment name (default: production)").option("--name <name>", "Database name").action(dbCreateCommand);
14608
14673
  db.command("start <uuid>").description("Start a database").action(dbStartCommand);
14609
14674
  db.command("stop <uuid>").description("Stop a database").action(dbStopCommand);
14610
14675
  db.command("restart <uuid>").description("Restart a database").action(dbRestartCommand);
14611
14676
  db.command("delete <uuid>").description("Delete a database").action(dbDeleteCommand);
14677
+ db.command("backups <uuid>").description("List backups for a database").action(dbBackupsCommand);
14612
14678
  db.action(() => db.help());
14613
14679
  var svc = program2.command("svc").description("Manage services");
14614
14680
  svc.command("list").description("List all services").action(svcListCommand);
@@ -14617,10 +14683,13 @@ svc.command("start <uuid>").description("Start a service").action(svcStartComman
14617
14683
  svc.command("stop <uuid>").description("Stop a service").action(svcStopCommand);
14618
14684
  svc.command("restart <uuid>").description("Restart a service").action(svcRestartCommand);
14619
14685
  svc.command("delete <uuid>").description("Delete a service").action(svcDeleteCommand);
14686
+ svc.command("env <uuid>").description("List env vars for a service").action(svcEnvCommand);
14687
+ svc.command("set-env <uuid> <KEY=VALUE>").description("Set env var for a service").action(svcSetEnvCommand);
14620
14688
  svc.action(() => svc.help());
14621
14689
  var keys = program2.command("keys").description("Manage SSH private keys");
14622
14690
  keys.command("list").description("List all private keys").action(keysListCommand);
14623
14691
  keys.command("get <uuid>").description("Get private key details").action(keysGetCommand);
14692
+ keys.command("create <name>").description("Create a private key").option("--key <value>", "Private key content").option("--file <path>", "Path to private key file").option("--description <desc>", "Description").action(keysCreateCommand);
14624
14693
  keys.command("delete <uuid>").description("Delete a private key").action(keysDeleteCommand);
14625
14694
  keys.action(() => keys.help());
14626
14695
  var team = program2.command("team").description("Manage teams");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mks2508/coolify-mks-cli-mcp",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "MCP server and CLI for Coolify deployment management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -4,8 +4,18 @@
4
4
  * @module
5
5
  */
6
6
 
7
- import { runAction, runList, runGet, chalk, formatStatus } from "../actions.js";
8
- import type { ICoolifyDatabase } from "../../coolify/types.js";
7
+ import {
8
+ runAction,
9
+ runList,
10
+ runGet,
11
+ chalk,
12
+ formatStatus,
13
+ getCliSdk,
14
+ } from "../actions.js";
15
+ import type {
16
+ ICoolifyDatabase,
17
+ ICoolifyDatabaseBackup,
18
+ } from "../../coolify/types.js";
9
19
 
10
20
  /** List all databases. */
11
21
  export const dbListCommand = () =>
@@ -24,13 +34,46 @@ export const dbGetCommand = (uuid: string) =>
24
34
  (s, u) => s.databases.get(u),
25
35
  (db) => {
26
36
  console.log(chalk.cyan("Database Details:"));
27
- console.log(chalk.gray("UUID: ") + db.uuid);
28
- console.log(chalk.gray("Name: ") + db.name);
29
- console.log(chalk.gray("Type: ") + (db.type || "-"));
30
- console.log(chalk.gray("Status: ") + formatStatus(db.status));
37
+ console.log(chalk.gray("UUID: ") + db.uuid);
38
+ console.log(chalk.gray("Name: ") + db.name);
39
+ console.log(chalk.gray("Type: ") + (db.type || "-"));
40
+ console.log(chalk.gray("Status: ") + formatStatus(db.status));
41
+ console.log(chalk.gray("Version: ") + (db.version || "-"));
31
42
  },
32
43
  );
33
44
 
45
+ /** Create a database. */
46
+ export async function dbCreateCommand(
47
+ type: string,
48
+ options: {
49
+ server: string;
50
+ project: string;
51
+ environment?: string;
52
+ name?: string;
53
+ },
54
+ ): Promise<void> {
55
+ try {
56
+ const data: Record<string, unknown> = {
57
+ server_uuid: options.server,
58
+ project_uuid: options.project,
59
+ };
60
+ if (options.environment) data.environment_name = options.environment;
61
+ if (options.name) data.name = options.name;
62
+
63
+ console.log(chalk.cyan(`Creating ${type} database...`));
64
+ const result = await getCliSdk().databases.create(type, data);
65
+ console.log(
66
+ chalk.green(`Database created! UUID: ${chalk.cyan(result.uuid)}`),
67
+ );
68
+ } catch (error) {
69
+ console.error(
70
+ chalk.red(
71
+ `Error: ${error instanceof Error ? error.message : String(error)}`,
72
+ ),
73
+ );
74
+ }
75
+ }
76
+
34
77
  /** Start a database. */
35
78
  export const dbStartCommand = (uuid: string) =>
36
79
  runAction(
@@ -66,3 +109,22 @@ export const dbDeleteCommand = (uuid: string) =>
66
109
  (s, u) => s.databases.delete(u),
67
110
  (u) => `Database deleted: ${u}`,
68
111
  );
112
+
113
+ /** List backups for a database. */
114
+ export const dbBackupsCommand = (uuid: string) =>
115
+ runList<ICoolifyDatabaseBackup>(
116
+ "backup(s)",
117
+ (s) => s.databases.backups(uuid),
118
+ [
119
+ { header: "UUID", value: (b) => b.uuid },
120
+ { header: "Status", value: (b) => formatStatus(b.status) },
121
+ {
122
+ header: "Created",
123
+ value: (b) => new Date(b.created_at).toLocaleString(),
124
+ },
125
+ {
126
+ header: "Size",
127
+ value: (b) => (b.size ? `${(b.size / 1024 / 1024).toFixed(1)}MB` : "-"),
128
+ },
129
+ ],
130
+ );
@@ -4,7 +4,7 @@
4
4
  * @module
5
5
  */
6
6
 
7
- import { runAction, runList, runGet, chalk } from "../actions.js";
7
+ import { runAction, runList, runGet, chalk, getCliSdk } from "../actions.js";
8
8
  import type { ICoolifyPrivateKey } from "../../coolify/types.js";
9
9
 
10
10
  /** List all private keys. */
@@ -36,6 +36,38 @@ export const keysGetCommand = (uuid: string) =>
36
36
  },
37
37
  );
38
38
 
39
+ /** Create a private key. */
40
+ export async function keysCreateCommand(
41
+ name: string,
42
+ options: { key?: string; file?: string; description?: string },
43
+ ): Promise<void> {
44
+ try {
45
+ let privateKey = options.key || "";
46
+ if (options.file) {
47
+ const { readFileSync } = await import("node:fs");
48
+ privateKey = readFileSync(options.file, "utf-8");
49
+ }
50
+ if (!privateKey) {
51
+ console.error(chalk.red("Error: Provide --key <value> or --file <path>"));
52
+ return;
53
+ }
54
+ const result = await getCliSdk().keys.create({
55
+ name,
56
+ private_key: privateKey,
57
+ description: options.description,
58
+ });
59
+ console.log(
60
+ chalk.green(`Private key created! UUID: ${chalk.cyan(result.uuid)}`),
61
+ );
62
+ } catch (error) {
63
+ console.error(
64
+ chalk.red(
65
+ `Error: ${error instanceof Error ? error.message : String(error)}`,
66
+ ),
67
+ );
68
+ }
69
+ }
70
+
39
71
  /** Delete a private key. */
40
72
  export const keysDeleteCommand = (uuid: string) =>
41
73
  runAction(
@@ -4,8 +4,16 @@
4
4
  * @module
5
5
  */
6
6
 
7
- import { runAction, runList, runGet, chalk, formatStatus } from "../actions.js";
7
+ import {
8
+ runAction,
9
+ runList,
10
+ runGet,
11
+ chalk,
12
+ formatStatus,
13
+ getCliSdk,
14
+ } from "../actions.js";
8
15
  import type { ICoolifyService } from "../../coolify/types.js";
16
+ import type { ICoolifyEnvVar } from "../../coolify/index.js";
9
17
 
10
18
  /** List all services. */
11
19
  export const svcListCommand = () =>
@@ -66,3 +74,34 @@ export const svcDeleteCommand = (uuid: string) =>
66
74
  (s, u) => s.services.delete(u),
67
75
  (u) => `Service deleted: ${u}`,
68
76
  );
77
+
78
+ /** List env vars for a service. */
79
+ export const svcEnvCommand = (uuid: string) =>
80
+ runList<ICoolifyEnvVar>("env var(s)", (s) => s.services.envVars(uuid), [
81
+ { header: "Key", value: (e) => e.key },
82
+ { header: "Value", value: (e) => e.value },
83
+ { header: "Runtime", value: (e) => (e.is_runtime ? "Yes" : "No") },
84
+ ]);
85
+
86
+ /** Set env var for a service. */
87
+ export async function svcSetEnvCommand(
88
+ uuid: string,
89
+ keyValue: string,
90
+ ): Promise<void> {
91
+ const [key, ...rest] = keyValue.split("=");
92
+ const value = rest.join("=");
93
+ if (!key || value === undefined) {
94
+ console.error(chalk.red("Error: Use format KEY=VALUE"));
95
+ return;
96
+ }
97
+ try {
98
+ await getCliSdk().services.setEnv(uuid, { key, value });
99
+ console.log(chalk.green(`✓ Set ${chalk.bold(key)} for service ${uuid}`));
100
+ } catch (error) {
101
+ console.error(
102
+ chalk.red(
103
+ `Error: ${error instanceof Error ? error.message : String(error)}`,
104
+ ),
105
+ );
106
+ }
107
+ }
package/src/cli/index.ts CHANGED
@@ -36,10 +36,12 @@ import { serverResourcesCommand } from "./commands/server-resources.js";
36
36
  import {
37
37
  dbListCommand,
38
38
  dbGetCommand,
39
+ dbCreateCommand,
39
40
  dbStartCommand,
40
41
  dbStopCommand,
41
42
  dbRestartCommand,
42
43
  dbDeleteCommand,
44
+ dbBackupsCommand,
43
45
  } from "./commands/db.js";
44
46
  import {
45
47
  svcListCommand,
@@ -48,10 +50,13 @@ import {
48
50
  svcStopCommand,
49
51
  svcRestartCommand,
50
52
  svcDeleteCommand,
53
+ svcEnvCommand,
54
+ svcSetEnvCommand,
51
55
  } from "./commands/svc.js";
52
56
  import {
53
57
  keysListCommand,
54
58
  keysGetCommand,
59
+ keysCreateCommand,
55
60
  keysDeleteCommand,
56
61
  } from "./commands/keys.js";
57
62
  import {
@@ -330,6 +335,15 @@ db.command("list").description("List all databases").action(dbListCommand);
330
335
  db.command("get <uuid>")
331
336
  .description("Get database details")
332
337
  .action(dbGetCommand);
338
+ db.command("create <type>")
339
+ .description(
340
+ "Create database (postgresql, mysql, mariadb, mongodb, redis, keydb, clickhouse, dragonfly)",
341
+ )
342
+ .requiredOption("--server <uuid>", "Server UUID")
343
+ .requiredOption("--project <uuid>", "Project UUID")
344
+ .option("--environment <name>", "Environment name (default: production)")
345
+ .option("--name <name>", "Database name")
346
+ .action(dbCreateCommand);
333
347
  db.command("start <uuid>")
334
348
  .description("Start a database")
335
349
  .action(dbStartCommand);
@@ -340,6 +354,9 @@ db.command("restart <uuid>")
340
354
  db.command("delete <uuid>")
341
355
  .description("Delete a database")
342
356
  .action(dbDeleteCommand);
357
+ db.command("backups <uuid>")
358
+ .description("List backups for a database")
359
+ .action(dbBackupsCommand);
343
360
  db.action(() => db.help());
344
361
 
345
362
  // ─── Service subcommands ─────────────────────────────────────────────────────
@@ -363,6 +380,14 @@ svc
363
380
  .command("delete <uuid>")
364
381
  .description("Delete a service")
365
382
  .action(svcDeleteCommand);
383
+ svc
384
+ .command("env <uuid>")
385
+ .description("List env vars for a service")
386
+ .action(svcEnvCommand);
387
+ svc
388
+ .command("set-env <uuid> <KEY=VALUE>")
389
+ .description("Set env var for a service")
390
+ .action(svcSetEnvCommand);
366
391
  svc.action(() => svc.help());
367
392
 
368
393
  // ─── SSH Key subcommands ─────────────────────────────────────────────────────
@@ -376,6 +401,13 @@ keys
376
401
  .command("get <uuid>")
377
402
  .description("Get private key details")
378
403
  .action(keysGetCommand);
404
+ keys
405
+ .command("create <name>")
406
+ .description("Create a private key")
407
+ .option("--key <value>", "Private key content")
408
+ .option("--file <path>", "Path to private key file")
409
+ .option("--description <desc>", "Description")
410
+ .action(keysCreateCommand);
379
411
  keys
380
412
  .command("delete <uuid>")
381
413
  .description("Delete a private key")