@mks2508/coolify-mks-cli-mcp 0.1.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.
Files changed (42) hide show
  1. package/dist/cli/index.js +11788 -0
  2. package/dist/coolify/config.d.ts +64 -0
  3. package/dist/coolify/config.d.ts.map +1 -0
  4. package/dist/coolify/index.d.ts +201 -0
  5. package/dist/coolify/index.d.ts.map +1 -0
  6. package/dist/coolify/types.d.ts +282 -0
  7. package/dist/coolify/types.d.ts.map +1 -0
  8. package/dist/index.cjs +29150 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +14 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +29127 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/server/sse.d.ts +11 -0
  15. package/dist/server/sse.d.ts.map +1 -0
  16. package/dist/server/sse.js +32 -0
  17. package/dist/server/stdio.d.ts +13 -0
  18. package/dist/server/stdio.d.ts.map +1 -0
  19. package/dist/server/stdio.js +18326 -0
  20. package/dist/tools/definitions.d.ts +13 -0
  21. package/dist/tools/definitions.d.ts.map +1 -0
  22. package/dist/tools/handlers.d.ts +19 -0
  23. package/dist/tools/handlers.d.ts.map +1 -0
  24. package/dist/utils/format.d.ts +38 -0
  25. package/dist/utils/format.d.ts.map +1 -0
  26. package/package.json +67 -0
  27. package/src/cli/commands/config.ts +83 -0
  28. package/src/cli/commands/deploy.ts +56 -0
  29. package/src/cli/commands/env.ts +60 -0
  30. package/src/cli/commands/list.ts +63 -0
  31. package/src/cli/commands/logs.ts +49 -0
  32. package/src/cli/commands/servers.ts +52 -0
  33. package/src/cli/index.ts +81 -0
  34. package/src/coolify/config.ts +113 -0
  35. package/src/coolify/index.ts +688 -0
  36. package/src/coolify/types.ts +297 -0
  37. package/src/index.ts +864 -0
  38. package/src/server/sse.ts +50 -0
  39. package/src/server/stdio.ts +52 -0
  40. package/src/tools/definitions.ts +435 -0
  41. package/src/tools/handlers.ts +605 -0
  42. package/src/utils/format.ts +104 -0
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Configuration management for Coolify MCP server.
3
+ *
4
+ * Simplified config that reads from ~/.config/coolify-mks-cli-mcp/config.json
5
+ * or falls back to environment variables.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ import { readFile, writeFile, mkdir } from 'node:fs/promises'
11
+ import { existsSync } from 'node:fs'
12
+ import { homedir } from 'node:os'
13
+ import { join } from 'node:path'
14
+ import { ok, err, isOk, type Result } from '@mks2508/no-throw'
15
+
16
+ const CONFIG_DIR = join(homedir(), '.config', 'coolify-mks-cli-mcp')
17
+ const CONFIG_FILE = join(CONFIG_DIR, 'config.json')
18
+
19
+ /**
20
+ * Coolify configuration structure.
21
+ */
22
+ export interface ICoolifyConfig {
23
+ /** Coolify instance URL */
24
+ url?: string
25
+ /** Coolify API token */
26
+ token?: string
27
+ }
28
+
29
+ /**
30
+ * Loads Coolify configuration from config file or environment variables.
31
+ *
32
+ * Priority: Config file > Environment variables
33
+ *
34
+ * @returns Result with configuration or error
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const result = await loadConfig()
39
+ * if (isOk(result)) {
40
+ * console.log('Coolify URL:', result.value.url)
41
+ * }
42
+ * ```
43
+ */
44
+ export async function loadConfig(): Promise<Result<ICoolifyConfig, Error>> {
45
+ try {
46
+ if (existsSync(CONFIG_FILE)) {
47
+ const content = await readFile(CONFIG_FILE, 'utf-8')
48
+ const parsed = JSON.parse(content) as ICoolifyConfig
49
+ return ok(parsed)
50
+ }
51
+
52
+ // Fallback to environment variables
53
+ return ok({
54
+ url: process.env.COOLIFY_URL,
55
+ token: process.env.COOLIFY_TOKEN
56
+ })
57
+ } catch (error) {
58
+ return err(error instanceof Error ? error : new Error(String(error)))
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Saves Coolify configuration to file.
64
+ *
65
+ * Creates the config directory if it doesn't exist.
66
+ *
67
+ * @param config - Configuration to save
68
+ * @returns Result indicating success or error
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * const result = await saveConfig({ url: 'https://coolify.example.com', token: 'xxx' })
73
+ * ```
74
+ */
75
+ export async function saveConfig(config: ICoolifyConfig): Promise<Result<void, Error>> {
76
+ try {
77
+ if (!existsSync(CONFIG_DIR)) {
78
+ await mkdir(CONFIG_DIR, { recursive: true })
79
+ }
80
+ await writeFile(CONFIG_FILE, JSON.stringify(config, null, 2))
81
+ return ok(undefined)
82
+ } catch (error) {
83
+ return err(error instanceof Error ? error : new Error(String(error)))
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Gets the Coolify URL from config or environment.
89
+ *
90
+ * @returns Coolify URL or undefined
91
+ */
92
+ export async function getCoolifyUrl(): Promise<string | undefined> {
93
+ const result = await loadConfig()
94
+ if (isOk(result)) {
95
+ return result.value.url || process.env.COOLIFY_URL
96
+ }
97
+ return process.env.COOLIFY_URL
98
+ }
99
+
100
+ /**
101
+ * Gets the Coolify token from config or environment.
102
+ *
103
+ * @returns Coolify token or undefined
104
+ */
105
+ export async function getCoolifyToken(): Promise<string | undefined> {
106
+ const result = await loadConfig()
107
+ if (isOk(result)) {
108
+ return result.value.token || process.env.COOLIFY_TOKEN
109
+ }
110
+ return process.env.COOLIFY_TOKEN
111
+ }
112
+
113
+ export { CONFIG_DIR, CONFIG_FILE }