@mks2508/coolify-mks-cli-mcp 0.4.3 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mks2508/coolify-mks-cli-mcp",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "MCP server and CLI for Coolify deployment management",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Build logs command for CLI.
3
+ *
4
+ * Shows deployment/build logs for a specific deployment.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ import { isErr } from '@mks2508/no-throw'
10
+ import chalk from 'chalk'
11
+ import { getCoolifyService } from '../../coolify/index.js'
12
+
13
+ /**
14
+ * Build logs command handler.
15
+ *
16
+ * @param deploymentUuid - Deployment UUID
17
+ * @param options - Build logs options
18
+ */
19
+ export async function buildLogsCommand(deploymentUuid: string, options: { lines?: number }) {
20
+ const coolify = getCoolifyService()
21
+ const initResult = await coolify.init()
22
+
23
+ if (isErr(initResult)) {
24
+ console.error(chalk.red(`Error: ${initResult.error.message}`))
25
+ return
26
+ }
27
+
28
+ const result = await coolify.getDeploymentLogs(deploymentUuid)
29
+
30
+ if (isErr(result)) {
31
+ console.error(chalk.red(`Error: ${result.error.message}`))
32
+ return
33
+ }
34
+
35
+ const { status, logs } = result.value
36
+
37
+ console.log(chalk.cyan('Deployment:') + ' ' + chalk.white(deploymentUuid))
38
+ console.log(chalk.cyan('Status: ') + ' ' + chalk.white(status))
39
+ console.log('')
40
+
41
+ if (!logs || logs.length === 0) {
42
+ console.log(chalk.yellow('No build logs available'))
43
+ return
44
+ }
45
+
46
+ const lines = logs.split('\n')
47
+ const tail = options.lines || lines.length
48
+ const output = lines.slice(-tail)
49
+
50
+ console.log(chalk.gray(`Build logs (${output.length} lines):\n`))
51
+
52
+ for (const line of output) {
53
+ console.log(line)
54
+ }
55
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Restart command for CLI.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import { isErr } from '@mks2508/no-throw'
8
+ import ora from 'ora'
9
+ import chalk from 'chalk'
10
+ import { getCoolifyService } from '../../coolify/index.js'
11
+
12
+ /**
13
+ * Restart command handler.
14
+ *
15
+ * @param uuid - Application UUID
16
+ */
17
+ export async function restartCommand(uuid: string) {
18
+ const spinner = ora('Initializing Coolify connection...').start()
19
+
20
+ try {
21
+ const coolify = getCoolifyService()
22
+ const initResult = await coolify.init()
23
+
24
+ if (isErr(initResult)) {
25
+ spinner.fail(chalk.red(`Failed to initialize: ${initResult.error.message}`))
26
+ return
27
+ }
28
+
29
+ spinner.text = 'Restarting application...'
30
+
31
+ const result = await coolify.restartApplication(uuid)
32
+
33
+ if (isErr(result)) {
34
+ spinner.fail(chalk.red(`Failed to restart application: ${result.error.message}`))
35
+ return
36
+ }
37
+
38
+ spinner.succeed(chalk.green(`Application restarted: ${chalk.cyan(uuid.slice(0, 8))}`))
39
+ } catch (error) {
40
+ spinner.fail(
41
+ chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`)
42
+ )
43
+ }
44
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Service logs command for CLI.
3
+ *
4
+ * Shows per-service container logs for docker-compose applications.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ import { isErr } from '@mks2508/no-throw'
10
+ import chalk from 'chalk'
11
+ import { getCoolifyService } from '../../coolify/index.js'
12
+
13
+ /**
14
+ * Service logs command handler.
15
+ *
16
+ * @param uuid - Application UUID
17
+ * @param serviceName - Docker Compose service name
18
+ * @param options - Logs options
19
+ */
20
+ export async function serviceLogsCommand(uuid: string, serviceName: string, options: { lines?: number }) {
21
+ const coolify = getCoolifyService()
22
+ const initResult = await coolify.init()
23
+
24
+ if (isErr(initResult)) {
25
+ console.error(chalk.red(`Error: ${initResult.error.message}`))
26
+ return
27
+ }
28
+
29
+ const result = await coolify.getApplicationLogs(uuid, {
30
+ tail: options.lines || 50,
31
+ serviceName,
32
+ })
33
+
34
+ if (isErr(result)) {
35
+ console.error(chalk.red(`Error: ${result.error.message}`))
36
+ return
37
+ }
38
+
39
+ const logs = result.value
40
+
41
+ if (logs.logs.length === 0) {
42
+ console.log(chalk.yellow(`No logs available for service "${serviceName}"`))
43
+ return
44
+ }
45
+
46
+ console.log(chalk.gray(`Service "${chalk.white(serviceName)}" logs (${logs.logs.length} lines):\n`))
47
+
48
+ for (const line of logs.logs) {
49
+ console.log(line)
50
+ }
51
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Start command for CLI.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import { isErr } from '@mks2508/no-throw'
8
+ import ora from 'ora'
9
+ import chalk from 'chalk'
10
+ import { getCoolifyService } from '../../coolify/index.js'
11
+
12
+ /**
13
+ * Start command handler.
14
+ *
15
+ * @param uuid - Application UUID
16
+ */
17
+ export async function startCommand(uuid: string) {
18
+ const spinner = ora('Initializing Coolify connection...').start()
19
+
20
+ try {
21
+ const coolify = getCoolifyService()
22
+ const initResult = await coolify.init()
23
+
24
+ if (isErr(initResult)) {
25
+ spinner.fail(chalk.red(`Failed to initialize: ${initResult.error.message}`))
26
+ return
27
+ }
28
+
29
+ spinner.text = 'Starting application...'
30
+
31
+ const result = await coolify.startApplication(uuid)
32
+
33
+ if (isErr(result)) {
34
+ spinner.fail(chalk.red(`Failed to start application: ${result.error.message}`))
35
+ return
36
+ }
37
+
38
+ spinner.succeed(chalk.green(`Application started: ${chalk.cyan(uuid.slice(0, 8))}`))
39
+ } catch (error) {
40
+ spinner.fail(
41
+ chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`)
42
+ )
43
+ }
44
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Stop command for CLI.
3
+ *
4
+ * @module
5
+ */
6
+
7
+ import { isErr } from '@mks2508/no-throw'
8
+ import ora from 'ora'
9
+ import chalk from 'chalk'
10
+ import { getCoolifyService } from '../../coolify/index.js'
11
+
12
+ /**
13
+ * Stop command handler.
14
+ *
15
+ * @param uuid - Application UUID
16
+ */
17
+ export async function stopCommand(uuid: string) {
18
+ const spinner = ora('Initializing Coolify connection...').start()
19
+
20
+ try {
21
+ const coolify = getCoolifyService()
22
+ const initResult = await coolify.init()
23
+
24
+ if (isErr(initResult)) {
25
+ spinner.fail(chalk.red(`Failed to initialize: ${initResult.error.message}`))
26
+ return
27
+ }
28
+
29
+ spinner.text = 'Stopping application...'
30
+
31
+ const result = await coolify.stopApplication(uuid)
32
+
33
+ if (isErr(result)) {
34
+ spinner.fail(chalk.red(`Failed to stop application: ${result.error.message}`))
35
+ return
36
+ }
37
+
38
+ spinner.succeed(chalk.green(`Application stopped: ${chalk.cyan(uuid.slice(0, 8))}`))
39
+ } catch (error) {
40
+ spinner.fail(
41
+ chalk.red(`Error: ${error instanceof Error ? error.message : String(error)}`)
42
+ )
43
+ }
44
+ }
package/src/cli/index.ts CHANGED
@@ -23,6 +23,11 @@ import { deleteCommand } from './commands/delete.js'
23
23
  import { destinationsCommand } from './commands/destinations.js'
24
24
  import { showCommand } from './commands/show.js'
25
25
  import { deploymentsCommand } from './commands/deployments.js'
26
+ import { startCommand } from './commands/start.js'
27
+ import { stopCommand } from './commands/stop.js'
28
+ import { restartCommand } from './commands/restart.js'
29
+ import { buildLogsCommand } from './commands/build-logs.js'
30
+ import { serviceLogsCommand } from './commands/service-logs.js'
26
31
 
27
32
  const program = new Command()
28
33
 
@@ -172,6 +177,44 @@ program
172
177
  deploymentsCommand(uuid, { full: options.full, limit })
173
178
  })
174
179
 
180
+ // Start application
181
+ program
182
+ .command('start <uuid>')
183
+ .description('Start a stopped application')
184
+ .action(startCommand)
185
+
186
+ // Stop application
187
+ program
188
+ .command('stop <uuid>')
189
+ .description('Stop a running application')
190
+ .action(stopCommand)
191
+
192
+ // Restart application
193
+ program
194
+ .command('restart <uuid>')
195
+ .description('Restart an application')
196
+ .action(restartCommand)
197
+
198
+ // Build/deployment logs
199
+ program
200
+ .command('build-logs <deployment-uuid>')
201
+ .description('View build/deployment logs for a specific deployment')
202
+ .option('-n, --lines <number>', 'Number of lines to show (tail)')
203
+ .action((deploymentUuid, options) => {
204
+ const lines = options.lines ? parseInt(options.lines, 10) : undefined
205
+ buildLogsCommand(deploymentUuid, { lines })
206
+ })
207
+
208
+ // Service logs (docker-compose)
209
+ program
210
+ .command('service-logs <uuid> <service-name>')
211
+ .description('View logs for a specific docker-compose service')
212
+ .option('-n, --lines <number>', 'Number of lines to retrieve', '50')
213
+ .action((uuid, serviceName, options) => {
214
+ const lines = parseInt(options.lines, 10)
215
+ serviceLogsCommand(uuid, serviceName, { lines })
216
+ })
217
+
175
218
  // Show help by default
176
219
  program.action(() => {
177
220
  console.log(chalk.cyan('Coolify MCP CLI'))