@vibetools/dokploy-mcp 1.2.0 → 2.0.1

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 (126) hide show
  1. package/README.md +61 -168
  2. package/dist/api/client.d.ts +2 -1
  3. package/dist/api/client.js +3 -11
  4. package/dist/cli/index.js +1 -0
  5. package/dist/codemode/context/execute-context.d.ts +590 -0
  6. package/dist/codemode/context/execute-context.js +64 -0
  7. package/dist/codemode/context/search-context.d.ts +13851 -0
  8. package/dist/codemode/context/search-context.js +42 -0
  9. package/dist/codemode/gateway/api-gateway.d.ts +12 -0
  10. package/dist/codemode/gateway/api-gateway.js +160 -0
  11. package/dist/codemode/gateway/error-format.d.ts +13 -0
  12. package/dist/codemode/gateway/error-format.js +9 -0
  13. package/dist/codemode/gateway/request-normalizer.d.ts +3 -0
  14. package/dist/codemode/gateway/request-normalizer.js +21 -0
  15. package/dist/codemode/gateway/trace.d.ts +13 -0
  16. package/dist/codemode/gateway/trace.js +11 -0
  17. package/dist/codemode/sandbox/host.d.ts +11 -0
  18. package/dist/codemode/sandbox/host.js +28 -0
  19. package/dist/codemode/sandbox/limits.d.ts +2 -0
  20. package/dist/codemode/sandbox/limits.js +20 -0
  21. package/dist/codemode/sandbox/runner.d.ts +8 -0
  22. package/dist/codemode/sandbox/runner.js +113 -0
  23. package/dist/codemode/sandbox/runtime.d.ts +2 -0
  24. package/dist/codemode/sandbox/runtime.js +3 -0
  25. package/dist/codemode/sandbox/serialize.d.ts +1 -0
  26. package/dist/codemode/sandbox/serialize.js +45 -0
  27. package/dist/codemode/sandbox/subprocess-runner.d.ts +10 -0
  28. package/dist/codemode/sandbox/subprocess-runner.js +91 -0
  29. package/dist/codemode/sandbox/types.d.ts +12 -0
  30. package/dist/codemode/sandbox/types.js +1 -0
  31. package/dist/codemode/sandbox/worker-entry.d.ts +1 -0
  32. package/dist/codemode/sandbox/worker-entry.js +70 -0
  33. package/dist/codemode/server-codemode.d.ts +2 -0
  34. package/dist/codemode/server-codemode.js +17 -0
  35. package/dist/codemode/tools/execute.d.ts +583 -0
  36. package/dist/codemode/tools/execute.js +64 -0
  37. package/dist/codemode/tools/index.d.ts +2 -0
  38. package/dist/codemode/tools/index.js +3 -0
  39. package/dist/codemode/tools/search.d.ts +2 -0
  40. package/dist/codemode/tools/search.js +73 -0
  41. package/dist/generated/dokploy-catalog.d.ts +27 -0
  42. package/dist/generated/dokploy-catalog.js +16 -0
  43. package/dist/generated/dokploy-schemas.d.ts +17533 -0
  44. package/dist/generated/dokploy-schemas.js +20639 -0
  45. package/dist/generated/dokploy-sdk.d.ts +558 -0
  46. package/dist/generated/dokploy-sdk.js +561 -0
  47. package/dist/generated/openapi-index.json +10591 -0
  48. package/dist/{tools/_factory.js → mcp/tool-factory.js} +7 -5
  49. package/dist/server.d.ts +1 -1
  50. package/dist/server.js +2 -15
  51. package/package.json +22 -11
  52. package/dist/tools/_database.d.ts +0 -12
  53. package/dist/tools/_database.js +0 -115
  54. package/dist/tools/admin.d.ts +0 -2
  55. package/dist/tools/admin.js +0 -61
  56. package/dist/tools/application.d.ts +0 -2
  57. package/dist/tools/application.js +0 -601
  58. package/dist/tools/backup.d.ts +0 -2
  59. package/dist/tools/backup.js +0 -133
  60. package/dist/tools/certificates.d.ts +0 -2
  61. package/dist/tools/certificates.js +0 -54
  62. package/dist/tools/cluster.d.ts +0 -2
  63. package/dist/tools/cluster.js +0 -38
  64. package/dist/tools/compose.d.ts +0 -2
  65. package/dist/tools/compose.js +0 -451
  66. package/dist/tools/deployment.d.ts +0 -2
  67. package/dist/tools/deployment.js +0 -107
  68. package/dist/tools/destination.d.ts +0 -2
  69. package/dist/tools/destination.js +0 -78
  70. package/dist/tools/docker.d.ts +0 -2
  71. package/dist/tools/docker.js +0 -110
  72. package/dist/tools/domain.d.ts +0 -2
  73. package/dist/tools/domain.js +0 -147
  74. package/dist/tools/environment.d.ts +0 -2
  75. package/dist/tools/environment.js +0 -104
  76. package/dist/tools/git-provider.d.ts +0 -2
  77. package/dist/tools/git-provider.js +0 -22
  78. package/dist/tools/github.d.ts +0 -2
  79. package/dist/tools/github.js +0 -66
  80. package/dist/tools/gitlab.d.ts +0 -2
  81. package/dist/tools/gitlab.js +0 -98
  82. package/dist/tools/index.d.ts +0 -2
  83. package/dist/tools/index.js +0 -72
  84. package/dist/tools/mariadb.d.ts +0 -1
  85. package/dist/tools/mariadb.js +0 -14
  86. package/dist/tools/mongo.d.ts +0 -1
  87. package/dist/tools/mongo.js +0 -13
  88. package/dist/tools/mounts.d.ts +0 -2
  89. package/dist/tools/mounts.js +0 -109
  90. package/dist/tools/mysql.d.ts +0 -1
  91. package/dist/tools/mysql.js +0 -14
  92. package/dist/tools/notification.d.ts +0 -2
  93. package/dist/tools/notification.js +0 -559
  94. package/dist/tools/patch.d.ts +0 -2
  95. package/dist/tools/patch.js +0 -179
  96. package/dist/tools/port.d.ts +0 -2
  97. package/dist/tools/port.js +0 -54
  98. package/dist/tools/postgres.d.ts +0 -1
  99. package/dist/tools/postgres.js +0 -13
  100. package/dist/tools/preview-deployment.d.ts +0 -2
  101. package/dist/tools/preview-deployment.js +0 -50
  102. package/dist/tools/project.d.ts +0 -2
  103. package/dist/tools/project.js +0 -125
  104. package/dist/tools/redirects.d.ts +0 -2
  105. package/dist/tools/redirects.js +0 -53
  106. package/dist/tools/redis.d.ts +0 -1
  107. package/dist/tools/redis.js +0 -11
  108. package/dist/tools/registry.d.ts +0 -2
  109. package/dist/tools/registry.js +0 -81
  110. package/dist/tools/rollback.d.ts +0 -2
  111. package/dist/tools/rollback.js +0 -28
  112. package/dist/tools/schedule.d.ts +0 -2
  113. package/dist/tools/schedule.js +0 -92
  114. package/dist/tools/security.d.ts +0 -2
  115. package/dist/tools/security.js +0 -48
  116. package/dist/tools/server.d.ts +0 -2
  117. package/dist/tools/server.js +0 -192
  118. package/dist/tools/settings.d.ts +0 -2
  119. package/dist/tools/settings.js +0 -509
  120. package/dist/tools/ssh-key.d.ts +0 -2
  121. package/dist/tools/ssh-key.js +0 -74
  122. package/dist/tools/user.d.ts +0 -2
  123. package/dist/tools/user.js +0 -85
  124. package/dist/tools/volume-backups.d.ts +0 -2
  125. package/dist/tools/volume-backups.js +0 -96
  126. /package/dist/{tools/_factory.d.ts → mcp/tool-factory.d.ts} +0 -0
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+ import { createTool } from '../../mcp/tool-factory.js';
3
+ import { createExecuteContext } from '../context/execute-context.js';
4
+ import { createSandboxHost } from '../sandbox/host.js';
5
+ import { resolveSandboxLimits } from '../sandbox/limits.js';
6
+ import { runSandboxedFunction } from '../sandbox/runner.js';
7
+ import { resolveSandboxRuntime } from '../sandbox/runtime.js';
8
+ import { runExecuteInSubprocess } from '../sandbox/subprocess-runner.js';
9
+ const executeSchema = z
10
+ .object({
11
+ code: z
12
+ .string()
13
+ .min(1)
14
+ .describe('An async arrow function receiving ({ dokploy, helpers }). ' +
15
+ 'Example: async ({ dokploy }) => { const p = await dokploy.project.all(); return p }. ' +
16
+ 'dokploy.<module>.<method>(params) calls the Dokploy API. ' +
17
+ 'helpers: sleep(ms), assert(cond, msg), pick(obj, keys), limit(arr, n), selectOne(arr, pred).'),
18
+ })
19
+ .strict();
20
+ export function buildExecuteContext(executor, maxCalls = resolveSandboxLimits().maxCalls) {
21
+ return createExecuteContext(executor, maxCalls);
22
+ }
23
+ export async function runExecuteWithHost(code, host) {
24
+ const execution = resolveSandboxRuntime() === 'subprocess'
25
+ ? await runExecuteInSubprocess({
26
+ code,
27
+ onCall: async (procedure, input) => {
28
+ const result = await host.call(procedure, input);
29
+ return result.data;
30
+ },
31
+ })
32
+ : await runSandboxedFunction({
33
+ code,
34
+ context: (() => {
35
+ const context = buildExecuteContext((procedure, payload) => host.call(procedure, payload));
36
+ return {
37
+ dokploy: context.dokploy,
38
+ helpers: context.helpers,
39
+ };
40
+ })(),
41
+ });
42
+ return {
43
+ result: execution.result,
44
+ logs: execution.logs,
45
+ calls: host.getCalls(),
46
+ };
47
+ }
48
+ export const executeTool = createTool({
49
+ name: 'execute',
50
+ title: 'Execute Dokploy Workflow',
51
+ description: 'Execute a sandboxed Dokploy workflow. ' +
52
+ 'The code parameter must be an async arrow function: async ({ dokploy, helpers }) => { ... }. ' +
53
+ 'Use dokploy.<module>.<method>(params) to call any Dokploy API procedure ' +
54
+ '(e.g. dokploy.application.one({ applicationId }), dokploy.project.all()). ' +
55
+ 'Available modules: project, environment, application, compose, domain, postgres, mysql, mariadb, mongo, redis, ' +
56
+ 'deployment, docker, server, settings, user, notification, backup, mounts, registry, certificates, and more. ' +
57
+ 'Use search tool first to discover exact procedure names and required parameters.',
58
+ schema: executeSchema,
59
+ annotations: { openWorldHint: true },
60
+ handler: async ({ input }) => {
61
+ const host = createSandboxHost();
62
+ return runExecuteWithHost(input.code, host);
63
+ },
64
+ });
@@ -0,0 +1,2 @@
1
+ import type { ToolDefinition } from '../../mcp/tool-factory.js';
2
+ export declare const codeModeTools: ToolDefinition[];
@@ -0,0 +1,3 @@
1
+ import { executeTool } from './execute.js';
2
+ import { searchTool } from './search.js';
3
+ export const codeModeTools = [searchTool, executeTool];
@@ -0,0 +1,2 @@
1
+ import { type ToolDefinition } from '../../mcp/tool-factory.js';
2
+ export declare const searchTool: ToolDefinition;
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ import { createTool } from '../../mcp/tool-factory.js';
3
+ import { createSearchCatalogView } from '../context/search-context.js';
4
+ import { runSandboxedFunction } from '../sandbox/runner.js';
5
+ import { resolveSandboxRuntime } from '../sandbox/runtime.js';
6
+ import { runSearchInSubprocess } from '../sandbox/subprocess-runner.js';
7
+ const searchSchema = z
8
+ .object({
9
+ code: z
10
+ .string()
11
+ .min(1)
12
+ .describe('An async arrow function receiving ({ catalog }). ' +
13
+ 'Example: async ({ catalog }) => catalog.searchText("application deploy"). ' +
14
+ 'catalog methods: searchText(query), get(procedure), getByTag(tag), ' +
15
+ 'endpoints (array of all procedures), byTag (grouped by module).'),
16
+ })
17
+ .strict();
18
+ const searchCatalog = createSearchCatalogView();
19
+ const MAX_SEARCH_OUTPUT_BYTES = 32 * 1024;
20
+ function boundSearchResult(value) {
21
+ if (Array.isArray(value)) {
22
+ return trimArrayToBytes(value);
23
+ }
24
+ if (value && typeof value === 'object' && 'matches' in value) {
25
+ const typed = value;
26
+ if (Array.isArray(typed.matches)) {
27
+ return {
28
+ ...typed,
29
+ matches: trimArrayToBytes(typed.matches),
30
+ };
31
+ }
32
+ }
33
+ return value;
34
+ }
35
+ function trimArrayToBytes(items) {
36
+ const limited = items.slice(0, 50);
37
+ let length = limited.length;
38
+ while (length > 0) {
39
+ const candidate = limited.slice(0, length);
40
+ const bytes = Buffer.byteLength(JSON.stringify(candidate), 'utf8');
41
+ if (bytes <= MAX_SEARCH_OUTPUT_BYTES) {
42
+ return candidate;
43
+ }
44
+ length -= 1;
45
+ }
46
+ return [];
47
+ }
48
+ export const searchTool = createTool({
49
+ name: 'search',
50
+ title: 'Search Dokploy API',
51
+ description: 'Search the Dokploy API catalog to discover procedures, parameters, and modules. ' +
52
+ 'The code parameter must be an async arrow function: async ({ catalog }) => { ... }. ' +
53
+ 'Use catalog.searchText("query") to find procedures by keyword, ' +
54
+ 'catalog.getByTag("application") to list all procedures in a module, ' +
55
+ 'catalog.get("application.one") to get details of a specific procedure. ' +
56
+ 'Returns procedure names, required/optional parameters, and HTTP methods.',
57
+ schema: searchSchema,
58
+ annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true },
59
+ handler: async ({ input }) => {
60
+ const execution = resolveSandboxRuntime() === 'subprocess'
61
+ ? await runSearchInSubprocess({ code: input.code })
62
+ : await runSandboxedFunction({
63
+ code: input.code,
64
+ context: {
65
+ catalog: searchCatalog,
66
+ },
67
+ });
68
+ return {
69
+ result: boundSearchResult(execution.result),
70
+ logs: execution.logs,
71
+ };
72
+ },
73
+ });
@@ -0,0 +1,27 @@
1
+ export interface CatalogEndpoint {
2
+ procedure: string;
3
+ method: string;
4
+ path: string;
5
+ tag: string;
6
+ summary: string | null;
7
+ description: string | null;
8
+ inputKind: 'query' | 'body';
9
+ requiredInputs: string[];
10
+ optionalInputs: string[];
11
+ response: {
12
+ type: string;
13
+ keys: string[];
14
+ };
15
+ }
16
+ export interface DokployCatalog {
17
+ version: string;
18
+ endpointCount: number;
19
+ tagCount: number;
20
+ endpoints: CatalogEndpoint[];
21
+ byTag: Record<string, number[]>;
22
+ byProcedure: Record<string, number>;
23
+ byPath: Record<string, number>;
24
+ }
25
+ export declare const dokployCatalog: DokployCatalog;
26
+ export declare function getCatalogEndpoint(id: string): CatalogEndpoint | undefined;
27
+ export declare function getCatalogEndpointsByTag(tag: string): (CatalogEndpoint | undefined)[];
@@ -0,0 +1,16 @@
1
+ // Generated by scripts/v2/build-openapi-index.mjs
2
+ import openapiIndex from './openapi-index.json' with { type: 'json' };
3
+ export const dokployCatalog = openapiIndex;
4
+ export function getCatalogEndpoint(id) {
5
+ const byProcedureIndex = dokployCatalog.byProcedure[id];
6
+ if (byProcedureIndex !== undefined)
7
+ return dokployCatalog.endpoints[byProcedureIndex];
8
+ const byPathIndex = dokployCatalog.byPath[id];
9
+ if (byPathIndex !== undefined)
10
+ return dokployCatalog.endpoints[byPathIndex];
11
+ return undefined;
12
+ }
13
+ export function getCatalogEndpointsByTag(tag) {
14
+ const indexes = dokployCatalog.byTag[tag] ?? [];
15
+ return indexes.map((index) => dokployCatalog.endpoints[index]).filter(Boolean);
16
+ }