@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,50 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Coolify MCP Server - SSE Transport.
4
+ *
5
+ * Entry point for running the MCP server with SSE transport.
6
+ * This is useful for web integrations and testing.
7
+ *
8
+ * @module
9
+ */
10
+
11
+ import { createServer } from 'node:http'
12
+
13
+ const PORT = process.env.PORT || 3000
14
+
15
+ const httpServer = createServer((req, res) => {
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
25
+ }
26
+
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
32
+ }
33
+
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
39
+ }
40
+
41
+ // 404
42
+ res.writeHead(404, { 'Content-Type': 'application/json' })
43
+ res.end(JSON.stringify({ error: 'Not found' }))
44
+ })
45
+
46
+ 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
+ })
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Coolify MCP Server - Stdio Transport.
4
+ *
5
+ * Entry point for running the MCP server with stdio transport.
6
+ * This is the standard way to use the MCP server with Claude Desktop.
7
+ *
8
+ * Uses @modelcontextprotocol/sdk for proper MCP stdio server implementation.
9
+ *
10
+ * @module
11
+ */
12
+
13
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js'
14
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
15
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js'
16
+ import { getCoolifyService } from '../coolify/index.js'
17
+ import { coolifyTools } from '../tools/definitions.js'
18
+ import { handleToolCall } from '../tools/handlers.js'
19
+
20
+ const coolify = getCoolifyService()
21
+
22
+ const server = new Server(
23
+ {
24
+ name: 'coolify-mks-cli',
25
+ version: '0.1.0'
26
+ },
27
+ {
28
+ capabilities: {
29
+ tools: {}
30
+ }
31
+ }
32
+ )
33
+
34
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
35
+ tools: coolifyTools
36
+ }))
37
+
38
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
39
+ const { name, arguments: args } = request.params
40
+
41
+ return await handleToolCall(name, args as Record<string, unknown>, coolify)
42
+ })
43
+
44
+ async function main() {
45
+ const transport = new StdioServerTransport()
46
+ await server.connect(transport)
47
+ }
48
+
49
+ main().catch((error) => {
50
+ console.error('Fatal error starting MCP server:', error)
51
+ process.exit(1)
52
+ })
@@ -0,0 +1,435 @@
1
+ /**
2
+ * MCP Tool definitions for Coolify.
3
+ *
4
+ * Defines all 21 tools with their input schemas.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js'
10
+
11
+ /**
12
+ * All Coolify MCP tool definitions.
13
+ */
14
+ export const coolifyTools: Tool[] = [
15
+ {
16
+ name: 'deploy',
17
+ description: `Deploy or redeploy an application to Coolify.
18
+
19
+ Triggers a new deployment for the specified application UUID.
20
+ Can force rebuild without cache if needed.`,
21
+ inputSchema: {
22
+ type: 'object' as const,
23
+ properties: {
24
+ uuid: {
25
+ type: 'string' as const,
26
+ description: 'Application UUID in Coolify',
27
+ format: 'uuid'
28
+ },
29
+ force: {
30
+ type: 'boolean' as const,
31
+ description: 'Force rebuild without cache',
32
+ default: false
33
+ },
34
+ tag: {
35
+ type: 'string' as const,
36
+ description: 'Deploy specific tag/version'
37
+ }
38
+ },
39
+ required: ['uuid']
40
+ }
41
+ },
42
+ {
43
+ name: 'get_env_vars',
44
+ description: `Get environment variables for a Coolify application.
45
+
46
+ Returns all environment variables with metadata including whether
47
+ they are runtime or buildtime, and if they are required.`,
48
+ inputSchema: {
49
+ type: 'object' as const,
50
+ properties: {
51
+ uuid: {
52
+ type: 'string' as const,
53
+ description: 'Application UUID',
54
+ format: 'uuid'
55
+ }
56
+ },
57
+ required: ['uuid']
58
+ }
59
+ },
60
+ {
61
+ name: 'set_env_vars',
62
+ description: `Set environment variables for a Coolify application.
63
+
64
+ Updates or adds environment variables. Existing vars not in the
65
+ input are preserved. Redeploy after setting to apply changes.`,
66
+ inputSchema: {
67
+ type: 'object' as const,
68
+ properties: {
69
+ uuid: {
70
+ type: 'string' as const,
71
+ description: 'Application UUID',
72
+ format: 'uuid'
73
+ },
74
+ envVars: {
75
+ type: 'object' as const,
76
+ description: 'Key-value pairs of environment variables',
77
+ additionalProperties: { type: 'string' as const }
78
+ }
79
+ },
80
+ required: ['uuid', 'envVars']
81
+ }
82
+ },
83
+ {
84
+ name: 'get_deployment_status',
85
+ description: `Get the current status of a Coolify application.
86
+
87
+ Returns deployment state, health status, and resource usage.`,
88
+ inputSchema: {
89
+ type: 'object' as const,
90
+ properties: {
91
+ uuid: {
92
+ type: 'string' as const,
93
+ description: 'Application UUID',
94
+ format: 'uuid'
95
+ }
96
+ },
97
+ required: ['uuid']
98
+ }
99
+ },
100
+ {
101
+ name: 'list_applications',
102
+ description: `List all applications in Coolify.
103
+
104
+ Optionally filter by team or project ID.`,
105
+ inputSchema: {
106
+ type: 'object' as const,
107
+ properties: {
108
+ teamId: {
109
+ type: 'string' as const,
110
+ description: 'Filter by Team ID'
111
+ },
112
+ projectId: {
113
+ type: 'string' as const,
114
+ description: 'Filter by Project ID'
115
+ }
116
+ }
117
+ }
118
+ },
119
+ {
120
+ name: 'delete_application',
121
+ description: `Delete an application from Coolify.
122
+
123
+ WARNING: This action is irreversible. All deployments, environment
124
+ variables, domains, and history will be permanently deleted.`,
125
+ inputSchema: {
126
+ type: 'object' as const,
127
+ properties: {
128
+ uuid: {
129
+ type: 'string' as const,
130
+ description: 'Application UUID to delete',
131
+ format: 'uuid'
132
+ }
133
+ },
134
+ required: ['uuid']
135
+ }
136
+ },
137
+ {
138
+ name: 'get_application_logs',
139
+ description: `Get logs for a Coolify application.
140
+
141
+ Retrieve recent logs with optional tail limit.`,
142
+ inputSchema: {
143
+ type: 'object' as const,
144
+ properties: {
145
+ uuid: {
146
+ type: 'string' as const,
147
+ description: 'Application UUID',
148
+ format: 'uuid'
149
+ },
150
+ tail: {
151
+ type: 'number' as const,
152
+ description: 'Number of log lines to retrieve'
153
+ }
154
+ },
155
+ required: ['uuid']
156
+ }
157
+ },
158
+ {
159
+ name: 'start_application',
160
+ description: `Start a stopped Coolify application.
161
+
162
+ Use this to start applications that were previously stopped.`,
163
+ inputSchema: {
164
+ type: 'object' as const,
165
+ properties: {
166
+ uuid: {
167
+ type: 'string' as const,
168
+ description: 'Application UUID to start',
169
+ format: 'uuid'
170
+ }
171
+ },
172
+ required: ['uuid']
173
+ }
174
+ },
175
+ {
176
+ name: 'stop_application',
177
+ description: `Stop a running Coolify application.
178
+
179
+ WARNING: This will make the application temporarily unavailable.
180
+ Containers will be stopped but not deleted.`,
181
+ inputSchema: {
182
+ type: 'object' as const,
183
+ properties: {
184
+ uuid: {
185
+ type: 'string' as const,
186
+ description: 'Application UUID to stop',
187
+ format: 'uuid'
188
+ }
189
+ },
190
+ required: ['uuid']
191
+ }
192
+ },
193
+ {
194
+ name: 'restart_application',
195
+ description: `Restart a Coolify application.
196
+
197
+ Equivalent to stopping and then starting the application.
198
+ Useful to apply configuration changes or recover from errors.`,
199
+ inputSchema: {
200
+ type: 'object' as const,
201
+ properties: {
202
+ uuid: {
203
+ type: 'string' as const,
204
+ description: 'Application UUID to restart',
205
+ format: 'uuid'
206
+ }
207
+ },
208
+ required: ['uuid']
209
+ }
210
+ },
211
+ {
212
+ name: 'get_deployment_history',
213
+ description: `Get deployment history for a Coolify application.
214
+
215
+ Returns list of all deployments with status, timestamps, and commit info.`,
216
+ inputSchema: {
217
+ type: 'object' as const,
218
+ properties: {
219
+ uuid: {
220
+ type: 'string' as const,
221
+ description: 'Application UUID',
222
+ format: 'uuid'
223
+ }
224
+ },
225
+ required: ['uuid']
226
+ }
227
+ },
228
+ {
229
+ name: 'update_application',
230
+ description: `Update configuration for a Coolify application.
231
+
232
+ Can modify name, description, build settings, and commands.
233
+ Redeploy after updating to apply changes.`,
234
+ inputSchema: {
235
+ type: 'object' as const,
236
+ properties: {
237
+ uuid: {
238
+ type: 'string' as const,
239
+ description: 'Application UUID',
240
+ format: 'uuid'
241
+ },
242
+ name: {
243
+ type: 'string' as const,
244
+ description: 'New application name'
245
+ },
246
+ description: {
247
+ type: 'string' as const,
248
+ description: 'New description'
249
+ },
250
+ buildPack: {
251
+ type: 'string' as const,
252
+ description: 'Build pack type',
253
+ enum: ['dockerfile', 'nixpacks', 'static']
254
+ },
255
+ gitBranch: {
256
+ type: 'string' as const,
257
+ description: 'Git branch to deploy'
258
+ },
259
+ portsExposes: {
260
+ type: 'string' as const,
261
+ description: 'Ports to expose (comma-separated)'
262
+ },
263
+ installCommand: {
264
+ type: 'string' as const,
265
+ description: 'Install command (nixpacks)'
266
+ },
267
+ buildCommand: {
268
+ type: 'string' as const,
269
+ description: 'Build command'
270
+ },
271
+ startCommand: {
272
+ type: 'string' as const,
273
+ description: 'Start command'
274
+ }
275
+ },
276
+ required: ['uuid']
277
+ }
278
+ },
279
+ {
280
+ name: 'list_servers',
281
+ description: `List all available servers in Coolify.
282
+
283
+ Returns server UUIDs, names, and IPs. Use server UUID when creating applications.`,
284
+ inputSchema: {
285
+ type: 'object' as const,
286
+ properties: {}
287
+ }
288
+ },
289
+ {
290
+ name: 'get_server',
291
+ description: `Get details of a specific Coolify server.
292
+
293
+ Returns server information including name, IP, status, and configuration.`,
294
+ inputSchema: {
295
+ type: 'object' as const,
296
+ properties: {
297
+ serverUuid: {
298
+ type: 'string' as const,
299
+ description: 'Server UUID to get details for',
300
+ format: 'uuid'
301
+ }
302
+ },
303
+ required: ['serverUuid']
304
+ }
305
+ },
306
+ {
307
+ name: 'list_projects',
308
+ description: `List all projects in Coolify.
309
+
310
+ Returns project UUIDs, names, and associated environments.`,
311
+ inputSchema: {
312
+ type: 'object' as const,
313
+ properties: {}
314
+ }
315
+ },
316
+ {
317
+ name: 'list_teams',
318
+ description: `List all teams in Coolify.
319
+
320
+ Returns team IDs, names, and configuration.`,
321
+ inputSchema: {
322
+ type: 'object' as const,
323
+ properties: {}
324
+ }
325
+ },
326
+ {
327
+ name: 'get_server_destinations',
328
+ description: `Get available destinations for a Coolify server.
329
+
330
+ Returns destination UUIDs needed when creating applications.
331
+ Each destination represents a Docker network/environment on the server.`,
332
+ inputSchema: {
333
+ type: 'object' as const,
334
+ properties: {
335
+ serverUuid: {
336
+ type: 'string' as const,
337
+ description: 'Server UUID to get destinations for',
338
+ format: 'uuid'
339
+ }
340
+ },
341
+ required: ['serverUuid']
342
+ }
343
+ },
344
+ {
345
+ name: 'create_application',
346
+ description: `Create a new application in Coolify from a GitHub repository.
347
+
348
+ Requires server UUID and destination UUID (get them from list_servers and get_server_destinations).
349
+ The GitHub repository must be accessible via the configured GitHub App.`,
350
+ inputSchema: {
351
+ type: 'object' as const,
352
+ properties: {
353
+ name: {
354
+ type: 'string' as const,
355
+ description: 'Application name'
356
+ },
357
+ serverUuid: {
358
+ type: 'string' as const,
359
+ description: 'Server UUID to deploy to',
360
+ format: 'uuid'
361
+ },
362
+ destinationUuid: {
363
+ type: 'string' as const,
364
+ description: 'Destination UUID (Docker network)',
365
+ format: 'uuid'
366
+ },
367
+ githubRepoUrl: {
368
+ type: 'string' as const,
369
+ description: 'GitHub repository URL (e.g., https://github.com/user/repo)'
370
+ },
371
+ description: {
372
+ type: 'string' as const,
373
+ description: 'Application description'
374
+ },
375
+ branch: {
376
+ type: 'string' as const,
377
+ description: 'Git branch to deploy',
378
+ default: 'main'
379
+ },
380
+ buildPack: {
381
+ type: 'string' as const,
382
+ description: 'Build pack type',
383
+ enum: ['dockerfile', 'nixpacks', 'static'],
384
+ default: 'nixpacks'
385
+ }
386
+ },
387
+ required: ['name', 'serverUuid', 'destinationUuid', 'githubRepoUrl']
388
+ }
389
+ },
390
+ {
391
+ name: 'get_resource_usage',
392
+ description: `Get resource usage for a Coolify application.
393
+
394
+ Returns current resource consumption metrics.`,
395
+ inputSchema: {
396
+ type: 'object' as const,
397
+ properties: {
398
+ uuid: {
399
+ type: 'string' as const,
400
+ description: 'Application UUID',
401
+ format: 'uuid'
402
+ }
403
+ },
404
+ required: ['uuid']
405
+ }
406
+ },
407
+ {
408
+ name: 'health_check',
409
+ description: `Check if Coolify API is accessible and credentials are valid.
410
+
411
+ Returns connection status and API version info if available.`,
412
+ inputSchema: {
413
+ type: 'object' as const,
414
+ properties: {}
415
+ }
416
+ },
417
+ {
418
+ name: 'get_application_details',
419
+ description: `Get detailed information about a Coolify application.
420
+
421
+ Returns full application configuration including name, description,
422
+ build settings, environment, and deployment status.`,
423
+ inputSchema: {
424
+ type: 'object' as const,
425
+ properties: {
426
+ uuid: {
427
+ type: 'string' as const,
428
+ description: 'Application UUID',
429
+ format: 'uuid'
430
+ }
431
+ },
432
+ required: ['uuid']
433
+ }
434
+ }
435
+ ]