@mks2508/coolify-mks-cli-mcp 0.5.0 → 0.6.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 (88) hide show
  1. package/dist/cli/coolify-state.d.ts +51 -0
  2. package/dist/cli/coolify-state.d.ts.map +1 -0
  3. package/dist/cli/index.js +2862 -631
  4. package/dist/coolify/config.d.ts +1 -1
  5. package/dist/coolify/config.d.ts.map +1 -1
  6. package/dist/coolify/index.d.ts +626 -12
  7. package/dist/coolify/index.d.ts.map +1 -1
  8. package/dist/coolify/types.d.ts +87 -3
  9. package/dist/coolify/types.d.ts.map +1 -1
  10. package/dist/dist-C4hIkHif.js +66 -0
  11. package/dist/dist-C4hIkHif.js.map +1 -0
  12. package/dist/dist-DEPvJhbP.js +3 -0
  13. package/dist/index.cjs +8511 -28542
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.ts +32 -8
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +8470 -28506
  18. package/dist/index.js.map +1 -1
  19. package/dist/network.d.ts +75 -0
  20. package/dist/network.d.ts.map +1 -0
  21. package/dist/sdk.d.ts +356 -0
  22. package/dist/sdk.d.ts.map +1 -0
  23. package/dist/server/index.d.ts +9 -0
  24. package/dist/server/index.d.ts.map +1 -0
  25. package/dist/server/sse.js +3 -1
  26. package/dist/server/stdio.d.ts +0 -2
  27. package/dist/server/stdio.d.ts.map +1 -1
  28. package/dist/server/stdio.js +3307 -1618
  29. package/dist/tools/definitions.d.ts +1 -1
  30. package/dist/tools/definitions.d.ts.map +1 -1
  31. package/dist/tools/handlers.d.ts +6 -7
  32. package/dist/tools/handlers.d.ts.map +1 -1
  33. package/dist/tools/index.d.ts +8 -0
  34. package/dist/tools/index.d.ts.map +1 -0
  35. package/dist/trace.d.ts +71 -0
  36. package/dist/trace.d.ts.map +1 -0
  37. package/dist/utils/format.d.ts +1 -1
  38. package/dist/utils/format.d.ts.map +1 -1
  39. package/package.json +13 -7
  40. package/src/cli/actions.ts +162 -0
  41. package/src/cli/commands/active-deployments.ts +24 -0
  42. package/src/cli/commands/build-logs.ts +25 -22
  43. package/src/cli/commands/cancel-deploy.ts +35 -0
  44. package/src/cli/commands/config.ts +53 -47
  45. package/src/cli/commands/create.ts +74 -53
  46. package/src/cli/commands/databases.ts +63 -0
  47. package/src/cli/commands/db.ts +68 -0
  48. package/src/cli/commands/delete.ts +41 -29
  49. package/src/cli/commands/deploy.ts +42 -21
  50. package/src/cli/commands/deployments.ts +41 -31
  51. package/src/cli/commands/destinations.ts +19 -27
  52. package/src/cli/commands/diagnose.ts +139 -0
  53. package/src/cli/commands/env.ts +66 -41
  54. package/src/cli/commands/environments.ts +36 -32
  55. package/src/cli/commands/exec.ts +39 -0
  56. package/src/cli/commands/keys.ts +46 -0
  57. package/src/cli/commands/list.ts +29 -27
  58. package/src/cli/commands/logs.ts +33 -18
  59. package/src/cli/commands/network.ts +145 -0
  60. package/src/cli/commands/projects.ts +51 -39
  61. package/src/cli/commands/restart.ts +34 -18
  62. package/src/cli/commands/server-resources.ts +71 -0
  63. package/src/cli/commands/servers.ts +23 -23
  64. package/src/cli/commands/service-logs.ts +24 -16
  65. package/src/cli/commands/services.ts +63 -0
  66. package/src/cli/commands/show.ts +72 -41
  67. package/src/cli/commands/start.ts +34 -18
  68. package/src/cli/commands/stop.ts +34 -18
  69. package/src/cli/commands/svc.ts +68 -0
  70. package/src/cli/commands/teams.ts +60 -0
  71. package/src/cli/commands/update.ts +73 -49
  72. package/src/cli/commands/version.ts +37 -0
  73. package/src/cli/coolify-state.ts +88 -0
  74. package/src/cli/index.ts +383 -151
  75. package/src/coolify/config.ts +29 -27
  76. package/src/coolify/index.ts +1829 -123
  77. package/src/coolify/types.ts +217 -124
  78. package/src/index.ts +82 -868
  79. package/src/network.ts +298 -0
  80. package/src/sdk.ts +597 -0
  81. package/src/server/index.ts +13 -0
  82. package/src/server/sse.ts +33 -25
  83. package/src/server/stdio.ts +24 -27
  84. package/src/tools/definitions.ts +893 -264
  85. package/src/tools/handlers.ts +556 -748
  86. package/src/tools/index.ts +8 -0
  87. package/src/trace.ts +116 -0
  88. package/src/utils/format.ts +36 -33
package/src/sdk.ts ADDED
@@ -0,0 +1,597 @@
1
+ /**
2
+ * Coolify SDK — Fluent, resource-based API for Coolify.
3
+ *
4
+ * Every parameter from CoolifyService is exposed. Nothing is lost.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ import { isErr, type Result } from "@mks2508/no-throw";
10
+ import { CoolifyService } from "./coolify/index.js";
11
+ import type {
12
+ ICoolifyAppOptions,
13
+ ICoolifyApplication,
14
+ ICoolifyDatabase,
15
+ ICoolifyDatabaseBackup,
16
+ ICoolifyDeleteResult,
17
+ ICoolifyDeployment,
18
+ ICoolifyDeployResult,
19
+ ICoolifyDestination,
20
+ ICoolifyEnvironment,
21
+ ICoolifyLogs,
22
+ ICoolifyLogsOptions,
23
+ ICoolifyPrivateKey,
24
+ ICoolifyProject,
25
+ ICoolifyServer,
26
+ ICoolifyServerDomain,
27
+ ICoolifyServerResource,
28
+ ICoolifyService as ICoolifyServiceType,
29
+ ICoolifyTeam,
30
+ ICoolifyUpdateOptions,
31
+ ICoolifyVersion,
32
+ IProgressCallback,
33
+ } from "./coolify/types.js";
34
+ import type { ICoolifyEnvVar } from "./coolify/index.js";
35
+
36
+ /** SDK configuration options. */
37
+ export interface ICoolifyOptions {
38
+ /** Coolify instance URL (e.g., https://coolify.example.com) */
39
+ url: string;
40
+ /** API token (generate in Coolify > Settings > API Tokens) */
41
+ token: string;
42
+ }
43
+
44
+ /** Cascade delete options. */
45
+ export interface IDeleteOptions {
46
+ deleteConfigurations?: boolean;
47
+ deleteVolumes?: boolean;
48
+ dockerCleanup?: boolean;
49
+ deleteConnectedNetworks?: boolean;
50
+ }
51
+
52
+ /** Pagination options. */
53
+ export interface IPaginationOptions {
54
+ page?: number;
55
+ perPage?: number;
56
+ }
57
+
58
+ function unwrap<T>(result: Result<T, Error>): T {
59
+ if (isErr(result)) throw result.error;
60
+ return result.value;
61
+ }
62
+
63
+ // ─── Resource Classes ────────────────────────────────────────────────────────
64
+
65
+ class ApplicationsResource {
66
+ constructor(private svc: CoolifyService) {}
67
+
68
+ /** List all applications. Supports filtering and pagination. */
69
+ async list(
70
+ options?: { teamId?: string; projectId?: string } & IPaginationOptions,
71
+ ): Promise<ICoolifyApplication[]> {
72
+ return unwrap(
73
+ await this.svc.listApplications(
74
+ options?.teamId,
75
+ options?.projectId,
76
+ options?.page,
77
+ options?.perPage,
78
+ ),
79
+ );
80
+ }
81
+
82
+ async listSummaries() {
83
+ return unwrap(await this.svc.listApplicationSummaries());
84
+ }
85
+
86
+ /** Resolve application by name, domain, or UUID. */
87
+ async resolve(query: string): Promise<ICoolifyApplication> {
88
+ return unwrap(await this.svc.resolveApplication(query));
89
+ }
90
+
91
+ /** Create a new application. All ICoolifyAppOptions supported. */
92
+ async create(options: ICoolifyAppOptions, onProgress?: IProgressCallback) {
93
+ return unwrap(await this.svc.createApplication(options, onProgress));
94
+ }
95
+
96
+ /** Deploy an application. Supports force rebuild and progress tracking. */
97
+ async deploy(
98
+ uuid: string,
99
+ options?: { force?: boolean; tag?: string },
100
+ onProgress?: IProgressCallback,
101
+ ): Promise<ICoolifyDeployResult> {
102
+ return unwrap(await this.svc.deploy({ uuid, ...options }, onProgress));
103
+ }
104
+
105
+ /** Start application. Supports force and instant_deploy. */
106
+ async start(
107
+ uuid: string,
108
+ options?: { force?: boolean; instantDeploy?: boolean },
109
+ ): Promise<ICoolifyApplication> {
110
+ return unwrap(await this.svc.startApplication(uuid, options));
111
+ }
112
+
113
+ async stop(uuid: string): Promise<ICoolifyApplication> {
114
+ return unwrap(await this.svc.stopApplication(uuid));
115
+ }
116
+
117
+ async restart(uuid: string): Promise<ICoolifyApplication> {
118
+ return unwrap(await this.svc.restartApplication(uuid));
119
+ }
120
+
121
+ /** Delete application with optional cascade options. */
122
+ async delete(
123
+ uuid: string,
124
+ options?: IDeleteOptions,
125
+ ): Promise<ICoolifyDeleteResult> {
126
+ return unwrap(await this.svc.deleteApplication(uuid, options));
127
+ }
128
+
129
+ /** Update application configuration. All ICoolifyUpdateOptions supported. */
130
+ async update(
131
+ uuid: string,
132
+ options: ICoolifyUpdateOptions,
133
+ ): Promise<ICoolifyApplication> {
134
+ return unwrap(await this.svc.updateApplication(uuid, options));
135
+ }
136
+
137
+ /** Get application logs. Supports lines, serviceName, follow. */
138
+ async logs(
139
+ uuid: string,
140
+ options?: ICoolifyLogsOptions,
141
+ ): Promise<ICoolifyLogs> {
142
+ return unwrap(await this.svc.getApplicationLogs(uuid, options));
143
+ }
144
+
145
+ /** Get deployment history with optional pagination. */
146
+ async deployments(
147
+ uuid: string,
148
+ skip?: number,
149
+ take?: number,
150
+ ): Promise<ICoolifyDeployment[]> {
151
+ return unwrap(await this.svc.getApplicationDeployments(uuid, skip, take));
152
+ }
153
+
154
+ async exec(uuid: string, command: string) {
155
+ return unwrap(await this.svc.executeCommand(uuid, command));
156
+ }
157
+
158
+ async envVars(uuid: string): Promise<ICoolifyEnvVar[]> {
159
+ return unwrap(await this.svc.getEnvironmentVariables(uuid));
160
+ }
161
+
162
+ async setEnv(
163
+ uuid: string,
164
+ key: string,
165
+ value: string,
166
+ isBuildTime?: boolean,
167
+ ) {
168
+ return unwrap(
169
+ await this.svc.setEnvironmentVariable(uuid, key, value, isBuildTime),
170
+ );
171
+ }
172
+
173
+ async bulkSetEnv(
174
+ uuid: string,
175
+ vars: Array<{ key: string; value: string; is_preview?: boolean }>,
176
+ ) {
177
+ return unwrap(await this.svc.bulkUpdateEnvironmentVariables(uuid, vars));
178
+ }
179
+
180
+ async deleteEnv(uuid: string, key: string) {
181
+ return unwrap(await this.svc.deleteEnvironmentVariable(uuid, key));
182
+ }
183
+ }
184
+
185
+ class DatabasesResource {
186
+ constructor(private svc: CoolifyService) {}
187
+
188
+ async list(options?: IPaginationOptions): Promise<ICoolifyDatabase[]> {
189
+ return unwrap(
190
+ await this.svc.listDatabases(options?.page, options?.perPage),
191
+ );
192
+ }
193
+
194
+ async listSummaries() {
195
+ return unwrap(await this.svc.listDatabaseSummaries());
196
+ }
197
+
198
+ async get(uuid: string): Promise<ICoolifyDatabase> {
199
+ return unwrap(await this.svc.getDatabase(uuid));
200
+ }
201
+
202
+ async create(type: string, data: Record<string, unknown>) {
203
+ return unwrap(await this.svc.createDatabase(type, data));
204
+ }
205
+
206
+ async update(uuid: string, data: Record<string, unknown>) {
207
+ return unwrap(await this.svc.updateDatabase(uuid, data));
208
+ }
209
+
210
+ async start(uuid: string) {
211
+ return unwrap(await this.svc.startDatabase(uuid));
212
+ }
213
+ async stop(uuid: string) {
214
+ return unwrap(await this.svc.stopDatabase(uuid));
215
+ }
216
+ async restart(uuid: string) {
217
+ return unwrap(await this.svc.restartDatabase(uuid));
218
+ }
219
+
220
+ /** Delete with optional cascade options. */
221
+ async delete(uuid: string, options?: IDeleteOptions) {
222
+ return unwrap(await this.svc.deleteDatabase(uuid, options));
223
+ }
224
+
225
+ async backups(uuid: string): Promise<ICoolifyDatabaseBackup[]> {
226
+ return unwrap(await this.svc.listDatabaseBackups(uuid));
227
+ }
228
+
229
+ async getBackup(dbUuid: string, backupUuid: string) {
230
+ return unwrap(await this.svc.getDatabaseBackup(dbUuid, backupUuid));
231
+ }
232
+
233
+ async createBackup(dbUuid: string, data: Record<string, unknown>) {
234
+ return unwrap(await this.svc.createDatabaseBackup(dbUuid, data));
235
+ }
236
+
237
+ async deleteBackup(dbUuid: string, backupUuid: string) {
238
+ return unwrap(await this.svc.deleteDatabaseBackup(dbUuid, backupUuid));
239
+ }
240
+ }
241
+
242
+ class ServicesResource {
243
+ constructor(private svc: CoolifyService) {}
244
+
245
+ async list(options?: IPaginationOptions): Promise<ICoolifyServiceType[]> {
246
+ return unwrap(await this.svc.listServices(options?.page, options?.perPage));
247
+ }
248
+
249
+ async listSummaries() {
250
+ return unwrap(await this.svc.listServiceSummaries());
251
+ }
252
+
253
+ async get(uuid: string): Promise<ICoolifyServiceType> {
254
+ return unwrap(await this.svc.getService(uuid));
255
+ }
256
+
257
+ async create(data: Record<string, unknown>) {
258
+ return unwrap(await this.svc.createService(data));
259
+ }
260
+
261
+ async update(uuid: string, data: Record<string, unknown>) {
262
+ return unwrap(await this.svc.updateService(uuid, data));
263
+ }
264
+
265
+ async start(uuid: string) {
266
+ return unwrap(await this.svc.startService(uuid));
267
+ }
268
+ async stop(uuid: string) {
269
+ return unwrap(await this.svc.stopService(uuid));
270
+ }
271
+ async restart(uuid: string) {
272
+ return unwrap(await this.svc.restartService(uuid));
273
+ }
274
+
275
+ /** Delete with optional cascade options. */
276
+ async delete(uuid: string, options?: IDeleteOptions) {
277
+ return unwrap(await this.svc.deleteService(uuid, options));
278
+ }
279
+
280
+ async envVars(uuid: string): Promise<ICoolifyEnvVar[]> {
281
+ return unwrap(await this.svc.listServiceEnvVars(uuid));
282
+ }
283
+
284
+ async setEnv(
285
+ uuid: string,
286
+ data: { key: string; value: string; is_preview?: boolean },
287
+ ) {
288
+ return unwrap(await this.svc.createServiceEnvVar(uuid, data));
289
+ }
290
+ }
291
+
292
+ class ServersResource {
293
+ constructor(private svc: CoolifyService) {}
294
+
295
+ async list(options?: IPaginationOptions): Promise<ICoolifyServer[]> {
296
+ return unwrap(await this.svc.listServers(options?.page, options?.perPage));
297
+ }
298
+
299
+ async listSummaries() {
300
+ return unwrap(await this.svc.listServerSummaries());
301
+ }
302
+
303
+ async resolve(query: string): Promise<ICoolifyServer> {
304
+ return unwrap(await this.svc.resolveServer(query));
305
+ }
306
+
307
+ async get(uuid: string): Promise<ICoolifyServer> {
308
+ return unwrap(await this.svc.getServer(uuid));
309
+ }
310
+
311
+ async create(data: Record<string, unknown>) {
312
+ return unwrap(await this.svc.createServer(data));
313
+ }
314
+
315
+ async delete(uuid: string) {
316
+ return unwrap(await this.svc.deleteServer(uuid));
317
+ }
318
+
319
+ async resources(uuid: string): Promise<ICoolifyServerResource[]> {
320
+ return unwrap(await this.svc.getServerResources(uuid));
321
+ }
322
+
323
+ async domains(uuid: string): Promise<ICoolifyServerDomain[]> {
324
+ return unwrap(await this.svc.getServerDomains(uuid));
325
+ }
326
+
327
+ async destinations(uuid: string): Promise<ICoolifyDestination[]> {
328
+ return unwrap(await this.svc.getServerDestinations(uuid));
329
+ }
330
+
331
+ async validate(uuid: string) {
332
+ return unwrap(await this.svc.validateServer(uuid));
333
+ }
334
+ }
335
+
336
+ class ProjectsResource {
337
+ constructor(private svc: CoolifyService) {}
338
+
339
+ async list(options?: IPaginationOptions): Promise<ICoolifyProject[]> {
340
+ return unwrap(await this.svc.listProjects(options?.page, options?.perPage));
341
+ }
342
+
343
+ async create(name: string, description?: string): Promise<ICoolifyProject> {
344
+ return unwrap(await this.svc.createProject(name, description));
345
+ }
346
+
347
+ async update(uuid: string, data: { name?: string; description?: string }) {
348
+ return unwrap(await this.svc.updateProject(uuid, data));
349
+ }
350
+
351
+ async delete(uuid: string) {
352
+ return unwrap(await this.svc.deleteProject(uuid));
353
+ }
354
+
355
+ async environments(projectUuid: string): Promise<ICoolifyEnvironment[]> {
356
+ return unwrap(await this.svc.getProjectEnvironments(projectUuid));
357
+ }
358
+
359
+ async createEnvironment(
360
+ projectUuid: string,
361
+ data: { name: string; description?: string },
362
+ ) {
363
+ return unwrap(await this.svc.createProjectEnvironment(projectUuid, data));
364
+ }
365
+ }
366
+
367
+ class TeamsResource {
368
+ constructor(private svc: CoolifyService) {}
369
+
370
+ async list(options?: IPaginationOptions): Promise<ICoolifyTeam[]> {
371
+ return unwrap(await this.svc.listTeams(options?.page, options?.perPage));
372
+ }
373
+
374
+ async current(): Promise<ICoolifyTeam> {
375
+ return unwrap(await this.svc.getCurrentTeam());
376
+ }
377
+
378
+ async get(id: number): Promise<ICoolifyTeam> {
379
+ return unwrap(await this.svc.getTeam(id));
380
+ }
381
+
382
+ async members(teamId: number) {
383
+ return unwrap(await this.svc.getTeamMembers(teamId));
384
+ }
385
+ }
386
+
387
+ class KeysResource {
388
+ constructor(private svc: CoolifyService) {}
389
+
390
+ async list(): Promise<ICoolifyPrivateKey[]> {
391
+ return unwrap(await this.svc.listPrivateKeys());
392
+ }
393
+
394
+ async get(uuid: string): Promise<ICoolifyPrivateKey> {
395
+ return unwrap(await this.svc.getPrivateKey(uuid));
396
+ }
397
+
398
+ async create(data: {
399
+ name: string;
400
+ private_key: string;
401
+ description?: string;
402
+ }) {
403
+ return unwrap(await this.svc.createPrivateKey(data));
404
+ }
405
+
406
+ async update(
407
+ uuid: string,
408
+ data: { name?: string; private_key?: string; description?: string },
409
+ ) {
410
+ return unwrap(await this.svc.updatePrivateKey(uuid, data));
411
+ }
412
+
413
+ async delete(uuid: string) {
414
+ return unwrap(await this.svc.deletePrivateKey(uuid));
415
+ }
416
+ }
417
+
418
+ class DeploymentsResource {
419
+ constructor(private svc: CoolifyService) {}
420
+
421
+ async active(options?: IPaginationOptions): Promise<ICoolifyDeployment[]> {
422
+ return unwrap(
423
+ await this.svc.listDeployments(options?.page, options?.perPage),
424
+ );
425
+ }
426
+
427
+ async get(uuid: string): Promise<ICoolifyDeployment> {
428
+ return unwrap(await this.svc.getDeployment(uuid));
429
+ }
430
+
431
+ /** Get deployment with build logs. */
432
+ async logs(uuid: string) {
433
+ return unwrap(await this.svc.getDeploymentLogs(uuid));
434
+ }
435
+
436
+ async cancel(uuid: string) {
437
+ return unwrap(await this.svc.cancelDeployment(uuid));
438
+ }
439
+ }
440
+
441
+ class DiagnoseResource {
442
+ constructor(private svc: CoolifyService) {}
443
+
444
+ async app(query: string) {
445
+ return unwrap(await this.svc.diagnoseApplication(query));
446
+ }
447
+
448
+ async server(query: string) {
449
+ return unwrap(await this.svc.diagnoseServer(query));
450
+ }
451
+
452
+ async infrastructure() {
453
+ return unwrap(await this.svc.findInfrastructureIssues());
454
+ }
455
+
456
+ /** Analyze a failed deployment — extracts errors from build logs. */
457
+ async deployFailure(deploymentUuid: string) {
458
+ const { analyzeDeployFailure } = await import("./network.js");
459
+ return unwrap(await analyzeDeployFailure(this.svc, deploymentUuid));
460
+ }
461
+ }
462
+
463
+ /**
464
+ * Network diagnostics — inspect Docker networks, proxy, DNS, connectivity.
465
+ */
466
+ class NetworkResource {
467
+ constructor(private svc: CoolifyService) {}
468
+
469
+ /**
470
+ * Inspect container network environment.
471
+ *
472
+ * @param appUuid - Application UUID
473
+ * @param servicesToTest - Service names to test connectivity (e.g., ['db', 'redis'])
474
+ */
475
+ async inspect(appUuid: string, servicesToTest?: string[]) {
476
+ const { inspectNetwork } = await import("./network.js");
477
+ return unwrap(await inspectNetwork(this.svc, appUuid, servicesToTest));
478
+ }
479
+ }
480
+
481
+ class BatchResource {
482
+ constructor(private svc: CoolifyService) {}
483
+
484
+ async restartProject(projectUuid: string) {
485
+ return unwrap(await this.svc.restartProjectApps(projectUuid));
486
+ }
487
+
488
+ async redeployProject(projectUuid: string, force?: boolean) {
489
+ return unwrap(await this.svc.redeployProjectApps(projectUuid, force));
490
+ }
491
+
492
+ async stopAll() {
493
+ return unwrap(await this.svc.stopAllApps());
494
+ }
495
+ }
496
+
497
+ class GitHubAppsResource {
498
+ constructor(private svc: CoolifyService) {}
499
+
500
+ async list(options?: IPaginationOptions) {
501
+ return unwrap(
502
+ await this.svc.listGithubApps(options?.page, options?.perPage),
503
+ );
504
+ }
505
+
506
+ async create(data: Record<string, unknown>) {
507
+ return unwrap(await this.svc.createGitHubApp(data));
508
+ }
509
+
510
+ async update(id: number, data: Record<string, unknown>) {
511
+ return unwrap(await this.svc.updateGitHubApp(id, data));
512
+ }
513
+
514
+ async delete(id: number) {
515
+ return unwrap(await this.svc.deleteGitHubApp(id));
516
+ }
517
+ }
518
+
519
+ // ─── Main SDK Class ──────────────────────────────────────────────────────────
520
+
521
+ /**
522
+ * Coolify SDK — The main entry point for interacting with a Coolify instance.
523
+ *
524
+ * Every parameter from the internal CoolifyService is exposed.
525
+ * Nothing is lost — progress callbacks, pagination, cascade deletes, all supported.
526
+ */
527
+ export class Coolify {
528
+ /** @internal */
529
+ readonly svc: CoolifyService;
530
+ private initialized = false;
531
+
532
+ readonly applications: ApplicationsResource;
533
+ readonly databases: DatabasesResource;
534
+ readonly services: ServicesResource;
535
+ readonly servers: ServersResource;
536
+ readonly projects: ProjectsResource;
537
+ readonly teams: TeamsResource;
538
+ readonly keys: KeysResource;
539
+ readonly deployments: DeploymentsResource;
540
+ readonly diagnose: DiagnoseResource;
541
+ readonly network: NetworkResource;
542
+ readonly batch: BatchResource;
543
+ readonly githubApps: GitHubAppsResource;
544
+
545
+ constructor(options?: ICoolifyOptions) {
546
+ this.svc = new CoolifyService();
547
+
548
+ if (options) {
549
+ process.env.COOLIFY_URL = options.url;
550
+ process.env.COOLIFY_TOKEN = options.token;
551
+ }
552
+
553
+ const autoInit = <T extends object>(resource: T): T => {
554
+ return new Proxy(resource, {
555
+ get: (target, prop, receiver) => {
556
+ const value = Reflect.get(target, prop, receiver);
557
+ if (typeof value !== "function") return value;
558
+ return async (...args: unknown[]) => {
559
+ await this.ensureInit();
560
+ return (value as Function).apply(target, args);
561
+ };
562
+ },
563
+ });
564
+ };
565
+
566
+ this.applications = autoInit(new ApplicationsResource(this.svc));
567
+ this.databases = autoInit(new DatabasesResource(this.svc));
568
+ this.services = autoInit(new ServicesResource(this.svc));
569
+ this.servers = autoInit(new ServersResource(this.svc));
570
+ this.projects = autoInit(new ProjectsResource(this.svc));
571
+ this.teams = autoInit(new TeamsResource(this.svc));
572
+ this.keys = autoInit(new KeysResource(this.svc));
573
+ this.deployments = autoInit(new DeploymentsResource(this.svc));
574
+ this.diagnose = autoInit(new DiagnoseResource(this.svc));
575
+ this.network = autoInit(new NetworkResource(this.svc));
576
+ this.batch = autoInit(new BatchResource(this.svc));
577
+ this.githubApps = autoInit(new GitHubAppsResource(this.svc));
578
+ }
579
+
580
+ static fromEnv(): Coolify {
581
+ return new Coolify();
582
+ }
583
+
584
+ private async ensureInit(): Promise<void> {
585
+ if (this.initialized) return;
586
+ const initResult = await this.svc.init();
587
+ if (isErr(initResult)) {
588
+ throw new Error(`Coolify connection failed: ${initResult.error.message}`);
589
+ }
590
+ this.initialized = true;
591
+ }
592
+
593
+ async version(): Promise<ICoolifyVersion> {
594
+ await this.ensureInit();
595
+ return unwrap(await this.svc.getVersion());
596
+ }
597
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * MCP Server barrel export.
3
+ *
4
+ * Use `stdio.ts` for Claude Desktop integration.
5
+ * Use `sse.ts` for web integrations.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ // Re-export nothing — server files are standalone entry points.
11
+ // Import them directly:
12
+ // import './server/stdio.js' // starts stdio server
13
+ // import './server/sse.js' // starts SSE server
package/src/server/sse.ts CHANGED
@@ -8,43 +8,51 @@
8
8
  * @module
9
9
  */
10
10
 
11
- import { createServer } from 'node:http'
11
+ import { createServer } from "node:http";
12
12
 
13
- const PORT = process.env.PORT || 3000
13
+ const PORT = process.env.PORT || 3000;
14
14
 
15
15
  const httpServer = createServer((req, res) => {
16
16
  // Set CORS headers
17
- res.setHeader('Access-Control-Allow-Origin', '*')
18
- res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
19
- res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
20
-
21
- if (req.method === 'OPTIONS') {
22
- res.writeHead(200)
23
- res.end()
24
- return
17
+ res.setHeader("Access-Control-Allow-Origin", "*");
18
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
19
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type");
20
+
21
+ if (req.method === "OPTIONS") {
22
+ res.writeHead(200);
23
+ res.end();
24
+ return;
25
25
  }
26
26
 
27
27
  // Health check endpoint
28
- if (req.url === '/health') {
29
- res.writeHead(200, { 'Content-Type': 'application/json' })
30
- res.end(JSON.stringify({ status: 'healthy', server: 'coolify-mcp' }))
31
- return
28
+ if (req.url === "/health") {
29
+ res.writeHead(200, { "Content-Type": "application/json" });
30
+ res.end(JSON.stringify({ status: "healthy", server: "coolify-mcp" }));
31
+ return;
32
32
  }
33
33
 
34
34
  // SSE endpoint - Note: This is a placeholder for future SSE support
35
- if (req.url === '/sse') {
36
- res.writeHead(200, { 'Content-Type': 'application/json' })
37
- res.end(JSON.stringify({ message: 'SSE not yet implemented. Use stdio transport.' }))
38
- return
35
+ if (req.url === "/sse") {
36
+ res.writeHead(200, { "Content-Type": "application/json" });
37
+ res.end(
38
+ JSON.stringify({
39
+ message: "SSE not yet implemented. Use stdio transport.",
40
+ }),
41
+ );
42
+ return;
39
43
  }
40
44
 
41
45
  // 404
42
- res.writeHead(404, { 'Content-Type': 'application/json' })
43
- res.end(JSON.stringify({ error: 'Not found' }))
44
- })
46
+ res.writeHead(404, { "Content-Type": "application/json" });
47
+ res.end(JSON.stringify({ error: "Not found" }));
48
+ });
45
49
 
46
50
  httpServer.listen(PORT, () => {
47
- console.warn(`Coolify MCP Server (SSE placeholder) listening on port ${PORT}`)
48
- console.warn(`Health check: http://localhost:${PORT}/health`)
49
- console.warn(`Note: SSE transport not yet implemented. Use stdio for Claude Desktop.`)
50
- })
51
+ console.warn(
52
+ `Coolify MCP Server (SSE placeholder) listening on port ${PORT}`,
53
+ );
54
+ console.warn(`Health check: http://localhost:${PORT}/health`);
55
+ console.warn(
56
+ `Note: SSE transport not yet implemented. Use stdio for Claude Desktop.`,
57
+ );
58
+ });