@vibetools/dokploy-mcp 0.4.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 (68) hide show
  1. package/README.md +692 -0
  2. package/dist/api/client.d.ts +11 -0
  3. package/dist/api/client.js +103 -0
  4. package/dist/cli/index.d.ts +1 -0
  5. package/dist/cli/index.js +48 -0
  6. package/dist/cli/setup.d.ts +1 -0
  7. package/dist/cli/setup.js +112 -0
  8. package/dist/config/resolver.d.ts +38 -0
  9. package/dist/config/resolver.js +290 -0
  10. package/dist/config/types.d.ts +25 -0
  11. package/dist/config/types.js +33 -0
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.js +25 -0
  14. package/dist/server.d.ts +2 -0
  15. package/dist/server.js +17 -0
  16. package/dist/tools/_factory.d.ts +53 -0
  17. package/dist/tools/_factory.js +86 -0
  18. package/dist/tools/admin.d.ts +2 -0
  19. package/dist/tools/admin.js +61 -0
  20. package/dist/tools/application.d.ts +2 -0
  21. package/dist/tools/application.js +464 -0
  22. package/dist/tools/auth.d.ts +2 -0
  23. package/dist/tools/auth.js +150 -0
  24. package/dist/tools/backup.d.ts +2 -0
  25. package/dist/tools/backup.js +103 -0
  26. package/dist/tools/certificates.d.ts +2 -0
  27. package/dist/tools/certificates.js +54 -0
  28. package/dist/tools/cluster.d.ts +2 -0
  29. package/dist/tools/cluster.js +38 -0
  30. package/dist/tools/compose.d.ts +2 -0
  31. package/dist/tools/compose.js +213 -0
  32. package/dist/tools/deployment.d.ts +2 -0
  33. package/dist/tools/deployment.js +27 -0
  34. package/dist/tools/destination.d.ts +2 -0
  35. package/dist/tools/destination.js +78 -0
  36. package/dist/tools/docker.d.ts +2 -0
  37. package/dist/tools/docker.js +50 -0
  38. package/dist/tools/domain.d.ts +2 -0
  39. package/dist/tools/domain.js +134 -0
  40. package/dist/tools/index.d.ts +2 -0
  41. package/dist/tools/index.js +48 -0
  42. package/dist/tools/mariadb.d.ts +2 -0
  43. package/dist/tools/mariadb.js +170 -0
  44. package/dist/tools/mongo.d.ts +2 -0
  45. package/dist/tools/mongo.js +168 -0
  46. package/dist/tools/mounts.d.ts +2 -0
  47. package/dist/tools/mounts.js +65 -0
  48. package/dist/tools/mysql.d.ts +2 -0
  49. package/dist/tools/mysql.js +170 -0
  50. package/dist/tools/port.d.ts +2 -0
  51. package/dist/tools/port.js +54 -0
  52. package/dist/tools/postgres.d.ts +2 -0
  53. package/dist/tools/postgres.js +169 -0
  54. package/dist/tools/project.d.ts +2 -0
  55. package/dist/tools/project.js +94 -0
  56. package/dist/tools/redirects.d.ts +2 -0
  57. package/dist/tools/redirects.js +53 -0
  58. package/dist/tools/redis.d.ts +2 -0
  59. package/dist/tools/redis.js +167 -0
  60. package/dist/tools/registry.d.ts +2 -0
  61. package/dist/tools/registry.js +81 -0
  62. package/dist/tools/security.d.ts +2 -0
  63. package/dist/tools/security.js +48 -0
  64. package/dist/tools/settings.d.ts +2 -0
  65. package/dist/tools/settings.js +258 -0
  66. package/dist/tools/user.d.ts +2 -0
  67. package/dist/tools/user.js +12 -0
  68. package/package.json +64 -0
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ const args = process.argv.slice(2);
3
+ if (args.length > 0) {
4
+ // CLI mode - handle subcommands
5
+ import('./cli/index.js')
6
+ .then(({ runCli }) => runCli(args))
7
+ .catch((err) => {
8
+ console.error('Error:', err instanceof Error ? err.message : err);
9
+ process.exit(1);
10
+ });
11
+ }
12
+ else {
13
+ // MCP server mode - start stdio transport
14
+ Promise.all([import('@modelcontextprotocol/sdk/server/stdio.js'), import('./server.js')])
15
+ .then(async ([{ StdioServerTransport }, { createServer }]) => {
16
+ const server = createServer();
17
+ const transport = new StdioServerTransport();
18
+ await server.connect(transport);
19
+ })
20
+ .catch((err) => {
21
+ console.error('Fatal error:', err);
22
+ process.exit(1);
23
+ });
24
+ }
25
+ export {};
@@ -0,0 +1,2 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function createServer(): McpServer;
package/dist/server.js ADDED
@@ -0,0 +1,17 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { allTools } from './tools/index.js';
3
+ export function createServer() {
4
+ const server = new McpServer({
5
+ name: 'dokploy-mcp-server',
6
+ version: '0.1.0',
7
+ });
8
+ for (const tool of allTools) {
9
+ server.registerTool(tool.name, {
10
+ title: tool.title,
11
+ description: tool.description,
12
+ inputSchema: tool.schema,
13
+ annotations: tool.annotations,
14
+ }, tool.handler);
15
+ }
16
+ return server;
17
+ }
@@ -0,0 +1,53 @@
1
+ import type { ZodObject, z } from 'zod';
2
+ import { api } from '../api/client.js';
3
+ type AnyZodObject = ZodObject;
4
+ export interface ToolAnnotations {
5
+ title?: string;
6
+ readOnlyHint?: boolean;
7
+ destructiveHint?: boolean;
8
+ idempotentHint?: boolean;
9
+ openWorldHint?: boolean;
10
+ }
11
+ export interface ToolDefinition {
12
+ name: string;
13
+ title: string;
14
+ description: string;
15
+ schema: AnyZodObject;
16
+ annotations: ToolAnnotations;
17
+ handler: (input: Record<string, unknown>) => Promise<{
18
+ content: {
19
+ type: 'text';
20
+ text: string;
21
+ }[];
22
+ structuredContent?: Record<string, unknown>;
23
+ isError?: boolean;
24
+ }>;
25
+ }
26
+ export declare function createTool<T extends AnyZodObject>(def: {
27
+ name: string;
28
+ title: string;
29
+ description: string;
30
+ schema: T;
31
+ annotations: ToolAnnotations;
32
+ handler: (params: {
33
+ input: z.infer<T>;
34
+ api: typeof api;
35
+ }) => Promise<unknown>;
36
+ }): ToolDefinition;
37
+ export declare function postTool<T extends AnyZodObject>(opts: {
38
+ name: string;
39
+ title: string;
40
+ description: string;
41
+ schema: T;
42
+ endpoint: string;
43
+ annotations?: Partial<ToolAnnotations>;
44
+ }): ToolDefinition;
45
+ export declare function getTool<T extends AnyZodObject>(opts: {
46
+ name: string;
47
+ title: string;
48
+ description: string;
49
+ schema: T;
50
+ endpoint: string;
51
+ annotations?: Partial<ToolAnnotations>;
52
+ }): ToolDefinition;
53
+ export {};
@@ -0,0 +1,86 @@
1
+ import { ApiError, api } from '../api/client.js';
2
+ function success(data) {
3
+ return {
4
+ content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
5
+ structuredContent: data,
6
+ };
7
+ }
8
+ function error(message, details) {
9
+ return {
10
+ content: [
11
+ {
12
+ type: 'text',
13
+ text: JSON.stringify({ error: message, ...(details ? { details } : {}) }, null, 2),
14
+ },
15
+ ],
16
+ isError: true,
17
+ };
18
+ }
19
+ function mapApiError(err) {
20
+ switch (err.status) {
21
+ case 401:
22
+ return error('Authentication failed', 'Check your DOKPLOY_API_KEY environment variable.');
23
+ case 403:
24
+ return error('Permission denied', 'Your API key lacks permission for this operation.');
25
+ case 404:
26
+ return error('Resource not found', err.message);
27
+ case 422:
28
+ return error('Validation error', typeof err.body === 'object' && err.body !== null ? JSON.stringify(err.body) : err.message);
29
+ default:
30
+ return error(`Dokploy API error (${err.status})`, err.message);
31
+ }
32
+ }
33
+ export function createTool(def) {
34
+ return {
35
+ name: def.name,
36
+ title: def.title,
37
+ description: def.description,
38
+ schema: def.schema,
39
+ annotations: { openWorldHint: true, ...def.annotations },
40
+ handler: async (input) => {
41
+ try {
42
+ const result = await def.handler({ input: input, api });
43
+ return success(result);
44
+ }
45
+ catch (err) {
46
+ if (err instanceof ApiError) {
47
+ return mapApiError(err);
48
+ }
49
+ return error(`Failed to execute ${def.name}`, err instanceof Error ? err.message : 'Unknown error');
50
+ }
51
+ },
52
+ };
53
+ }
54
+ export function postTool(opts) {
55
+ return createTool({
56
+ name: opts.name,
57
+ title: opts.title,
58
+ description: opts.description,
59
+ schema: opts.schema,
60
+ annotations: { openWorldHint: true, ...opts.annotations },
61
+ handler: async ({ input, api }) => api.post(opts.endpoint, input),
62
+ });
63
+ }
64
+ export function getTool(opts) {
65
+ return createTool({
66
+ name: opts.name,
67
+ title: opts.title,
68
+ description: opts.description,
69
+ schema: opts.schema,
70
+ annotations: {
71
+ readOnlyHint: true,
72
+ idempotentHint: true,
73
+ openWorldHint: true,
74
+ ...opts.annotations,
75
+ },
76
+ handler: async ({ input, api }) => {
77
+ const params = {};
78
+ for (const [k, v] of Object.entries(input)) {
79
+ if (v !== undefined && v !== null) {
80
+ params[k] = v;
81
+ }
82
+ }
83
+ return api.get(opts.endpoint, Object.keys(params).length > 0 ? params : undefined);
84
+ },
85
+ });
86
+ }
@@ -0,0 +1,2 @@
1
+ import { type ToolDefinition } from './_factory.js';
2
+ export declare const adminTools: ToolDefinition[];
@@ -0,0 +1,61 @@
1
+ import { z } from 'zod';
2
+ import { postTool } from './_factory.js';
3
+ // ── tools ────────────────────────────────────────────────────────────
4
+ const setupMonitoring = postTool({
5
+ name: 'dokploy_admin_setup_monitoring',
6
+ title: 'Setup Monitoring',
7
+ description: 'Configure server and container monitoring metrics. Sets up refresh rates, retention policies, callback URLs, resource thresholds, and container service filters for the monitoring system.',
8
+ schema: z
9
+ .object({
10
+ metricsConfig: z
11
+ .object({
12
+ server: z
13
+ .object({
14
+ refreshRate: z
15
+ .number()
16
+ .min(2)
17
+ .describe('Metrics refresh rate in seconds (minimum 2)'),
18
+ port: z.number().min(1).describe('Monitoring port number'),
19
+ token: z.string().describe('Authentication token for metrics endpoint'),
20
+ urlCallback: z.string().url().describe('Callback URL for metrics data'),
21
+ retentionDays: z.number().min(1).describe('Number of days to retain metrics data'),
22
+ cronJob: z
23
+ .string()
24
+ .min(1)
25
+ .describe('Cron expression for scheduled metrics collection'),
26
+ thresholds: z
27
+ .object({
28
+ cpu: z.number().min(0).describe('CPU usage threshold percentage'),
29
+ memory: z.number().min(0).describe('Memory usage threshold percentage'),
30
+ })
31
+ .strict(),
32
+ })
33
+ .strict(),
34
+ containers: z
35
+ .object({
36
+ refreshRate: z
37
+ .number()
38
+ .min(2)
39
+ .describe('Container metrics refresh rate in seconds (minimum 2)'),
40
+ services: z
41
+ .object({
42
+ include: z
43
+ .array(z.string())
44
+ .optional()
45
+ .describe('Service names to include in monitoring'),
46
+ exclude: z
47
+ .array(z.string())
48
+ .optional()
49
+ .describe('Service names to exclude from monitoring'),
50
+ })
51
+ .strict(),
52
+ })
53
+ .strict(),
54
+ })
55
+ .strict(),
56
+ })
57
+ .strict(),
58
+ endpoint: '/admin.setupMonitoring',
59
+ });
60
+ // ── export ───────────────────────────────────────────────────────────
61
+ export const adminTools = [setupMonitoring];
@@ -0,0 +1,2 @@
1
+ import { type ToolDefinition } from './_factory.js';
2
+ export declare const applicationTools: ToolDefinition[];