@daileyos/mcp-server 1.20.0 → 1.20.2

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 (40) hide show
  1. package/.github/workflows/publish.yml +10 -3
  2. package/dist/index.js +6 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/tools/buddy.d.ts +3 -0
  5. package/dist/tools/buddy.d.ts.map +1 -0
  6. package/dist/tools/buddy.js +765 -0
  7. package/dist/tools/buddy.js.map +1 -0
  8. package/dist/tools/dailey-images.d.ts +14 -0
  9. package/dist/tools/dailey-images.d.ts.map +1 -0
  10. package/dist/tools/dailey-images.js +87 -0
  11. package/dist/tools/dailey-images.js.map +1 -0
  12. package/dist/tools/environments.d.ts +3 -0
  13. package/dist/tools/environments.d.ts.map +1 -0
  14. package/dist/tools/environments.js +75 -0
  15. package/dist/tools/environments.js.map +1 -0
  16. package/dist/tools/payments.d.ts +3 -0
  17. package/dist/tools/payments.d.ts.map +1 -0
  18. package/dist/tools/payments.js +96 -0
  19. package/dist/tools/payments.js.map +1 -0
  20. package/dist/tools/redis.d.ts +3 -0
  21. package/dist/tools/redis.d.ts.map +1 -0
  22. package/dist/tools/redis.js +72 -0
  23. package/dist/tools/redis.js.map +1 -0
  24. package/dist/tools/wordpress-import.d.ts +3 -0
  25. package/dist/tools/wordpress-import.d.ts.map +1 -0
  26. package/dist/tools/wordpress-import.js +151 -0
  27. package/dist/tools/wordpress-import.js.map +1 -0
  28. package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
  29. package/dist/tools/wordpress-snapshot.js +5 -4
  30. package/dist/tools/wordpress-snapshot.js.map +1 -1
  31. package/package.json +5 -2
  32. package/src/index.ts +6 -0
  33. package/src/tools/dailey-images.ts +151 -0
  34. package/src/tools/environments.ts +138 -0
  35. package/src/tools/wordpress-import.ts +174 -0
  36. package/src/tools/wordpress-snapshot.ts +8 -4
  37. package/test/wordpress-import.test.ts +223 -0
  38. package/tests/dailey-images.test.mjs +156 -0
  39. package/tests/environments.test.mjs +230 -0
  40. package/tests/wp-snapshot-labels.test.mjs +21 -0
@@ -1 +1 @@
1
- {"version":3,"file":"wordpress-snapshot.d.ts","sourceRoot":"","sources":["../../src/tools/wordpress-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA8DpE,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,SAAS,QA8J/D"}
1
+ {"version":3,"file":"wordpress-snapshot.d.ts","sourceRoot":"","sources":["../../src/tools/wordpress-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAiEpE,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,SAAS,QA+J/D"}
@@ -24,18 +24,19 @@ export function registerWordPressSnapshotTools(server) {
24
24
  }
25
25
  const lines = [
26
26
  `Snapshots for project ${project_id}`,
27
- `${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'Kind'.padEnd(12)} ${'Status'.padEnd(12)} ${'DB'.padEnd(10)} Uploads`,
27
+ `${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'Reason'.padEnd(10)} ${'Label'.padEnd(24)} ${'Status'.padEnd(12)} ${'DB'.padEnd(10)} Content`,
28
28
  '─'.repeat(115),
29
29
  ];
30
30
  for (const s of snapshots) {
31
- lines.push(`${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.kind || '-').padEnd(12)} ${(s.status || '-').padEnd(12)} ${fmtBytes(s.db_bytes).padEnd(10)} ${fmtBytes(s.uploads_bytes)}`);
31
+ lines.push(`${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.reason || 'manual').padEnd(10)} ${((s.label ?? '').slice(0, 24) || '—').padEnd(24)} ${(s.status || '-').padEnd(12)} ${fmtBytes(s.db_bytes).padEnd(10)} ${fmtBytes(s.content_bytes ?? s.uploads_bytes)}`);
32
32
  }
33
33
  return textResult(lines.join('\n'));
34
34
  });
35
35
  server.tool('dailey_wp_snapshot', 'Create a snapshot (DB + uploads) of a WordPress project', {
36
36
  project_id: z.string().describe('The project ID'),
37
- }, async ({ project_id }) => {
38
- const res = await apiRequest('POST', `/projects/${project_id}/wp/snapshot`);
37
+ label: z.string().optional().describe('Optional human label; labeled points are kept until deleted (never auto-expire)'),
38
+ }, async ({ project_id, label }) => {
39
+ const res = await apiRequest('POST', `/projects/${project_id}/wp/snapshot`, label ? { label } : undefined);
39
40
  if (!res.ok)
40
41
  return textResult(formatError(res));
41
42
  const { operation_id } = res.data;
@@ -1 +1 @@
1
- {"version":3,"file":"wordpress-snapshot.js","sourceRoot":"","sources":["../../src/tools/wordpress-snapshot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAc,WAAW,EAAE,MAAM,WAAW,CAAC;AAoD5E,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,GAAG,CAAC;IAC9B,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,GAAG,CAAC;IACrC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACjE,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IACjF,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,8BAA8B,CAAC,MAAiB;IAC9D,MAA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package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daileyos/mcp-server",
3
- "version": "1.20.0",
3
+ "version": "1.20.2",
4
4
  "description": "Dailey OS MCP server for Claude Code and AI assistants",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,17 +9,20 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "tsc",
12
- "start": "node dist/index.js"
12
+ "start": "node dist/index.js",
13
+ "test": "tsx --test --experimental-test-module-mocks test/*.test.ts"
13
14
  },
14
15
  "publishConfig": {
15
16
  "access": "public"
16
17
  },
17
18
  "dependencies": {
19
+ "@daileyos/wp-bundle": "^0.1.0",
18
20
  "@modelcontextprotocol/sdk": "^1.12.1",
19
21
  "zod": "^3.24.4"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@types/node": "^22.15.3",
25
+ "tsx": "^4.23.0",
23
26
  "typescript": "^5.8.3"
24
27
  }
25
28
  }
package/src/index.ts CHANGED
@@ -26,12 +26,15 @@ import { registerAiTools } from './tools/ai.js';
26
26
  import { registerEmailTools } from './tools/email.js';
27
27
  import { registerCreditTools } from './tools/credits.js';
28
28
  import { registerAddonTools } from './tools/addons.js';
29
+ import { registerDaileyImagesTools } from './tools/dailey-images.js';
29
30
  import { registerImageTools } from './tools/images.js';
30
31
  import { registerProcessTools } from './tools/processes.js';
31
32
  import { registerLifecycleTools } from './tools/lifecycle.js';
32
33
  import { registerBackupTools } from './tools/backups.js';
33
34
  import { registerWordPressMigrateTools } from './tools/wordpress-migrate.js';
35
+ import { registerWordPressImportTools } from './tools/wordpress-import.js';
34
36
  import { registerWordPressSnapshotTools } from './tools/wordpress-snapshot.js';
37
+ import { registerEnvironmentTools } from './tools/environments.js';
35
38
  import { registerResourceConfigTools } from './tools/resource-config.js';
36
39
  import { registerLinkTools } from './tools/links.js';
37
40
  import { registerCredentialRevealTools } from './tools/credentials-reveal.js';
@@ -150,9 +153,12 @@ registerMigrateTools(server);
150
153
  registerStorageTools(server);
151
154
  registerAiTools(server);
152
155
  registerEmailTools(server);
156
+ registerDaileyImagesTools(server);
153
157
  registerBackupTools(server);
154
158
  registerWordPressMigrateTools(server);
159
+ registerWordPressImportTools(server);
155
160
  registerWordPressSnapshotTools(server);
161
+ registerEnvironmentTools(server);
156
162
 
157
163
  // Runtime operations — exec into a pod, run one-off jobs
158
164
  registerExecRunTools(server);
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Dailey Images — AI image generation MCP tools (mirror of tools/ai.ts).
3
+ *
4
+ * Backend gateway lives at customer-api routes/images.ts, mounted on
5
+ * /api/projects. OpenAI-Images-compatible. Metered per image from prepaid
6
+ * credits: Fast (dailey-fast, Flux-schnell) 2¢/image, Pro (dailey-pro,
7
+ * Flux 1.1-pro) 10¢/image.
8
+ *
9
+ * NOTE: this is a separate file from tools/images.ts (which holds the Docker
10
+ * container-image tools like dailey_run_image) to avoid clobbering it.
11
+ */
12
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
+ import { z } from 'zod';
14
+ import { apiRequest, formatError, textResult } from '../api.js';
15
+
16
+ interface ImagesInfoResponse {
17
+ project: { id: string; slug: string };
18
+ images: {
19
+ enabled: boolean;
20
+ env_injected: boolean;
21
+ tiers: string[];
22
+ default_tier: string;
23
+ base_url: string;
24
+ generations_url: string;
25
+ env_vars: string[];
26
+ enable_with: string | null;
27
+ };
28
+ integration: { images: string };
29
+ warnings: string[];
30
+ docs_url: string;
31
+ }
32
+
33
+ interface ImagesEnableResponse {
34
+ ok: boolean;
35
+ project_id: string;
36
+ images_enabled: boolean;
37
+ url: string;
38
+ key_masked: string;
39
+ restart_required: boolean;
40
+ default_tier: string;
41
+ docs_url: string;
42
+ }
43
+
44
+ interface GenerationsResponse {
45
+ created: number;
46
+ data: Array<{ url?: string; b64_json?: string }>;
47
+ _served_by: { provider: string; model: string; tier: string };
48
+ }
49
+
50
+ // Per-image price (cents) by tier, for the cost note.
51
+ const TIER_CENTS: Record<string, number> = {
52
+ 'dailey-fast': 2,
53
+ 'dailey-pro': 10,
54
+ };
55
+
56
+ export function registerDaileyImagesTools(server: McpServer) {
57
+ server.tool(
58
+ 'dailey_images_generate',
59
+ 'Generate images with Dailey Images (AI). METERED from prepaid credits: model="dailey-fast" (Flux-schnell) is 2¢/image, model="dailey-pro" (Flux 1.1-pro) is 10¢/image. Returns the image URL(s) and which tier/model served the request. Images must be enabled for the project first (dailey_images_enable).',
60
+ {
61
+ project: z.string().describe('The project ID or slug'),
62
+ prompt: z.string().describe('Text prompt describing the image to generate'),
63
+ model: z
64
+ .enum(['dailey-fast', 'dailey-pro'])
65
+ .optional()
66
+ .describe('Tier: dailey-fast (Flux-schnell, 2¢/image, default) or dailey-pro (Flux 1.1-pro, 10¢/image)'),
67
+ size: z.string().optional().describe('Image size/aspect, e.g. "landscape_16_9", "square_hd", "portrait_4_3"'),
68
+ n: z.number().int().min(1).max(4).optional().describe('Number of images to generate (1..4). Default 1.'),
69
+ },
70
+ async ({ project, prompt, model, size, n }) => {
71
+ const tier = model || 'dailey-fast';
72
+ const body: Record<string, unknown> = { prompt, model: tier };
73
+ if (size != null) body.size = size;
74
+ if (n != null) body.n = n;
75
+
76
+ const res = await apiRequest<GenerationsResponse>(
77
+ 'POST', `/projects/${project}/images/generations`, body);
78
+ if (!res.ok) return textResult(formatError(res));
79
+
80
+ const d = res.data;
81
+ const served = d._served_by;
82
+ const perImage = TIER_CENTS[served?.tier || tier] ?? TIER_CENTS[tier];
83
+ const count = d.data?.length ?? 0;
84
+ const urls = (d.data || []).map((im, i) =>
85
+ im.url ? ` ${i + 1}. ${im.url}` : ` ${i + 1}. (b64_json returned, ${(im.b64_json || '').length} chars)`);
86
+
87
+ const lines = [
88
+ `Generated ${count} image${count === 1 ? '' : 's'} — ${served?.tier || tier} (${served?.model || 'unknown model'}, via ${served?.provider || 'unknown'})`,
89
+ ...urls,
90
+ '',
91
+ `Cost: ${perImage}¢/image × ${count} = ${perImage * count}¢, drawn from prepaid credits.`,
92
+ ];
93
+ return textResult(lines.join('\n'));
94
+ },
95
+ );
96
+
97
+ server.tool(
98
+ 'dailey_images_enable',
99
+ 'Enable Dailey Images (AI image generation) for a project. Mints a capability-scoped key and injects DAILEY_IMAGE_BASE_URL/KEY/TIER into the project env (applies on next deploy). Usage is metered from prepaid credits (dailey-fast 2¢/image, dailey-pro 10¢/image).',
100
+ { project: z.string().describe('The project ID or slug') },
101
+ async ({ project }) => {
102
+ const res = await apiRequest<ImagesEnableResponse>(
103
+ 'POST', `/projects/${project}/images/enable`, {});
104
+ if (!res.ok) return textResult(formatError(res));
105
+ const d = res.data;
106
+ const lines = [
107
+ 'Dailey Images enabled.',
108
+ ` base url: ${d.url}`,
109
+ ` key: ${d.key_masked}`,
110
+ ` default tier: ${d.default_tier}`,
111
+ ' tiers: dailey-fast (2¢/image), dailey-pro (10¢/image)',
112
+ ...(d.restart_required ? ['', 'Redeploy the project (dailey_deploy) to pick up the DAILEY_IMAGE_* env vars.'] : []),
113
+ '',
114
+ `Docs: ${d.docs_url}`,
115
+ ];
116
+ return textResult(lines.join('\n'));
117
+ },
118
+ );
119
+
120
+ server.tool(
121
+ 'dailey_images_info',
122
+ 'Show whether Dailey Images (AI image generation) is enabled for a project, whether its DAILEY_IMAGE_* env vars are injected into the pod, the available tiers, and how to wire it up. Enable with dailey_images_enable.',
123
+ { project: z.string().describe('The project ID or slug') },
124
+ async ({ project }) => {
125
+ const res = await apiRequest<ImagesInfoResponse>('GET', `/projects/${project}/images/info`);
126
+ if (!res.ok) return textResult(formatError(res));
127
+ const d = res.data;
128
+ const lines = [
129
+ `Dailey Images: ${d.project.slug}`,
130
+ '',
131
+ ` enabled: ${d.images.enabled ? 'ON' : 'off'}`,
132
+ ` env injected: ${d.images.env_injected ? 'yes' : 'no'}`,
133
+ ` tiers: ${d.images.tiers.join(', ')} (dailey-fast 2¢/image, dailey-pro 10¢/image)`,
134
+ ` default tier: ${d.images.default_tier}`,
135
+ ` base url: ${d.images.base_url}`,
136
+ ` env vars: ${d.images.env_vars.join(', ')}`,
137
+ ...(d.images.enable_with ? [` enable: ${d.images.enable_with} (or dailey_images_enable)`] : []),
138
+ '',
139
+ 'Integration (OpenAI-compatible):',
140
+ ` ${d.integration.images}`,
141
+ ];
142
+ if (d.warnings && d.warnings.length) {
143
+ lines.push('');
144
+ for (const w of d.warnings) lines.push(`⚠ ${w}`);
145
+ }
146
+ lines.push('', `Docs: ${d.docs_url}`);
147
+ lines.push('Note: injected env applies on the NEXT deploy — redeploy after enabling.');
148
+ return textResult(lines.join('\n'));
149
+ },
150
+ );
151
+ }
@@ -0,0 +1,138 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod';
3
+ import { apiRequest, textResult, formatError } from '../api.js';
4
+
5
+ interface Environment {
6
+ id?: string;
7
+ environment: string;
8
+ deployment: string;
9
+ domain: string;
10
+ status: string;
11
+ db_name?: string;
12
+ storage_prefix?: string;
13
+ image?: string;
14
+ replicas?: number;
15
+ created_at?: string;
16
+ updated_at?: string;
17
+ }
18
+
19
+ interface EnvironmentsResponse {
20
+ environments: Environment[];
21
+ }
22
+
23
+ interface ClonePreviewPlan {
24
+ steps: string[];
25
+ sourceLabel?: string;
26
+ targetLabel?: string;
27
+ }
28
+
29
+ interface ClonePreviewResponse {
30
+ plan: ClonePreviewPlan;
31
+ confirm_token: string;
32
+ }
33
+
34
+ interface CloneExecuteResponse {
35
+ operation_id: string;
36
+ }
37
+
38
+ export function registerEnvironmentTools(server: McpServer) {
39
+ server.tool(
40
+ 'dailey_environments',
41
+ 'List prod and staging environments for a project',
42
+ {
43
+ project: z.string().describe('The project ID or slug'),
44
+ },
45
+ async ({ project }) => {
46
+ const res = await apiRequest<EnvironmentsResponse>('GET', `/projects/${project}/environments`);
47
+ if (!res.ok) return textResult(formatError(res));
48
+
49
+ const envs = res.data.environments;
50
+ if (!envs || envs.length === 0) {
51
+ return textResult(`No environments found for project ${project}.`);
52
+ }
53
+
54
+ const lines: string[] = [`Environments for project ${project}:`, ''];
55
+
56
+ for (const env of envs) {
57
+ const label = env.environment === 'prod' ? 'Production (prod)' : `${env.environment}`;
58
+ lines.push(`${label}`);
59
+ lines.push(` Status: ${env.status}`);
60
+ lines.push(` Domain: https://${env.domain}`);
61
+ lines.push(` Deployment: ${env.deployment}`);
62
+ if (env.db_name) lines.push(` Database: ${env.db_name}`);
63
+ if (env.image) lines.push(` Image: ${env.image}`);
64
+ if (env.replicas != null) lines.push(` Replicas: ${env.replicas}`);
65
+ if (env.created_at) lines.push(` Created: ${env.created_at}`);
66
+ lines.push('');
67
+ }
68
+
69
+ return textResult(lines.join('\n').trimEnd());
70
+ },
71
+ );
72
+
73
+ server.tool(
74
+ 'dailey_wp_clone',
75
+ 'Clone a WordPress project from prod to staging (DESTRUCTIVE — two-phase). Call WITHOUT confirm_token to get the plan; re-call WITH the returned confirm_token to execute.',
76
+ {
77
+ project: z.string().describe('The project ID or slug'),
78
+ confirm_token: z.string().optional().describe(
79
+ 'Token from the plan response. Omit to preview the plan; provide to execute. ~10min TTL.',
80
+ ),
81
+ },
82
+ async ({ project, confirm_token }) => {
83
+ if (!confirm_token) {
84
+ // Phase 1: preview
85
+ const res = await apiRequest<ClonePreviewResponse>(
86
+ 'POST',
87
+ `/projects/${project}/wp/clone/preview`,
88
+ );
89
+ if (!res.ok) return textResult(formatError(res));
90
+
91
+ const { plan, confirm_token: token } = res.data;
92
+ const lines: string[] = [];
93
+
94
+ if (plan.sourceLabel || plan.targetLabel) {
95
+ lines.push(`Clone plan: ${plan.sourceLabel ?? 'prod'} → ${plan.targetLabel ?? 'staging'}`);
96
+ } else {
97
+ lines.push(`Clone plan for project ${project} (prod → staging):`);
98
+ }
99
+
100
+ if (plan.steps && plan.steps.length > 0) {
101
+ lines.push('');
102
+ lines.push('Steps:');
103
+ plan.steps.forEach((step, i) => {
104
+ lines.push(` ${i + 1}. ${step}`);
105
+ });
106
+ }
107
+
108
+ lines.push('');
109
+ lines.push(`confirm_token: ${token}`);
110
+ lines.push('');
111
+ lines.push(
112
+ 'This will overwrite staging with prod data. To proceed, re-call dailey_wp_clone with the same project and this confirm_token.',
113
+ );
114
+
115
+ return textResult(lines.join('\n'));
116
+ }
117
+
118
+ // Phase 2: execute
119
+ const res = await apiRequest<CloneExecuteResponse>(
120
+ 'POST',
121
+ `/projects/${project}/wp/clone`,
122
+ { confirm_token, confirmation: 'CLONE' },
123
+ );
124
+
125
+ if (!res.ok) {
126
+ if (res.status === 409) {
127
+ return textResult('A clone or restore operation is already in progress for this project.');
128
+ }
129
+ return textResult(formatError(res));
130
+ }
131
+
132
+ const { operation_id } = res.data;
133
+ return textResult(
134
+ `Clone started. operation_id=${operation_id}. Poll with dailey_wp_operation_status (project, operation_id).`,
135
+ );
136
+ },
137
+ );
138
+ }
@@ -0,0 +1,174 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod';
3
+ import { existsSync, mkdtempSync, rmSync } from 'node:fs';
4
+ import { tmpdir } from 'node:os';
5
+ import { join, basename } from 'node:path';
6
+ import { analyze, stage, type BundleReport } from '@daileyos/wp-bundle';
7
+ import { apiRequest, formatError, textResult } from '../api.js';
8
+ import { putFileToPresignedUrl } from '../upload.js';
9
+
10
+ // Client-side preflight cap for `analyze`, before any project/plan is known.
11
+ // The server enforces the customer's real plan limit once a target project
12
+ // exists (customer-api upload-staging.ts: ABSOLUTE_MAX_UPLOAD_BYTES = 2 GiB) —
13
+ // this mirrors that ceiling so an oversized bundle is flagged early rather
14
+ // than only after staging + upload.
15
+ const PLAN_UPLOAD_CAP_BYTES = 2 * 1024 * 1024 * 1024; // 2 GiB
16
+
17
+ interface ProvisionResponse {
18
+ ok: boolean;
19
+ project_id: string;
20
+ slug: string;
21
+ new_url: string;
22
+ ready: boolean;
23
+ note: string;
24
+ }
25
+ interface StartResponse {
26
+ migration_id: string;
27
+ db_upload: { url: string; key: string; headers: Record<string, string>; max_bytes: number };
28
+ content_upload: { url: string; key: string; headers: Record<string, string>; max_bytes: number };
29
+ warning?: string;
30
+ }
31
+ interface ScanFinding { level: string; code: string; message: string }
32
+ interface ScanResponse { ok: boolean; verdict: 'clean' | 'warn' | 'blocked'; findings: ScanFinding[] }
33
+ interface RunResponse { ok: boolean; migration_id: string; new_url: string }
34
+ interface StatusResponse { status: string; step?: string; error?: string; log_tail?: string; finished_at?: string }
35
+
36
+ function formatReport(report: BundleReport): string {
37
+ const findings = report.findings.length
38
+ ? report.findings.map((f) => ` [${f.level}] ${f.code}: ${f.message}${f.detail ? ` (${f.detail})` : ''}`).join('\n')
39
+ : ' (none)';
40
+ return [
41
+ `Bundle format: ${report.format}`,
42
+ `Source URL: ${report.source.old_url}`,
43
+ `DB size: ${report.sizes.db_bytes} bytes, wp-content: ${report.sizes.wp_content_bytes} bytes (${report.sizes.file_count} files)`,
44
+ `Verdict: ${report.verdict}`,
45
+ 'Findings:',
46
+ findings,
47
+ ].join('\n');
48
+ }
49
+
50
+ export function registerWordPressImportTools(server: McpServer) {
51
+ server.tool(
52
+ 'dailey_wordpress_import',
53
+ 'Analyze and migrate a WordPress bundle export (Local by Flywheel .zip, All-in-One WP Migration .wpress, or Duplicator archive) onto Dailey OS. action=analyze reads the bundle locally (no upload) and returns a BundleReport — format, detected source config, sizes, findings, verdict. action=migrate auto-provisions a hardened+quarantined WordPress target when project_id is omitted, stages the bundle, uploads the DB + wp-content, runs the pre-migrate scan gate (refuses on a blocked verdict unless allow_unsafe=true — logged), then runs the import and polls to completion. WARNING: migrate replaces the target project\'s database and wp-content; requires confirm=true. action=status checks a previous migration.',
54
+ {
55
+ action: z.enum(['analyze', 'migrate', 'status']).describe('analyze = read-only bundle report | migrate = full flow (provision/stage/upload/scan/run/poll) | status = check a migration'),
56
+ bundle_file: z.string().optional().describe('Local path to the bundle (.zip/.wpress) — required for analyze and migrate'),
57
+ project_id: z.string().optional().describe('Existing WordPress project to migrate into — omit to auto-provision a new target; required for action=status'),
58
+ confirm: z.boolean().optional().describe('Must be true to run action=migrate (destructive: replaces DB + wp-content)'),
59
+ allow_unsafe: z.boolean().optional().describe('Proceed despite a blocked verdict, whether found client-side (analyze) or by the server-side scan gate — the override is logged'),
60
+ migration_id: z.string().optional().describe('Migration ID — required for action=status'),
61
+ },
62
+ async ({ action, bundle_file, project_id, confirm, allow_unsafe, migration_id }) => {
63
+ if (action === 'status') {
64
+ if (!project_id || !migration_id) return textResult('project_id and migration_id are required for action=status');
65
+ const res = await apiRequest<StatusResponse>('GET', `/projects/${project_id}/migrate/wordpress/${migration_id}`);
66
+ if (!res.ok) return textResult(formatError(res));
67
+ const s = res.data;
68
+ return textResult(`Migration ${migration_id}: ${s.status}${s.step ? ` (step: ${s.step})` : ''}${s.error ? `\nError: ${s.error}` : ''}${s.log_tail ? `\n--- log ---\n${s.log_tail}` : ''}`);
69
+ }
70
+
71
+ if (!bundle_file) return textResult(`bundle_file is required for action=${action}`);
72
+ if (!existsSync(bundle_file)) return textResult(`File not found: ${bundle_file}`);
73
+
74
+ let report: BundleReport;
75
+ try {
76
+ report = await analyze(bundle_file, { planUploadCapBytes: PLAN_UPLOAD_CAP_BYTES });
77
+ } catch (e: unknown) {
78
+ const message = e instanceof Error ? e.message : String(e);
79
+ return textResult(`Failed to analyze bundle: ${message}`);
80
+ }
81
+
82
+ if (action === 'analyze') {
83
+ return textResult(formatReport(report));
84
+ }
85
+
86
+ // action === 'migrate'
87
+ if (!confirm) {
88
+ return textResult(`Refusing to migrate without confirm=true (this replaces the target's database and wp-content).\n\n${formatReport(report)}`);
89
+ }
90
+ if (report.verdict === 'blocked' && !allow_unsafe) {
91
+ return textResult(`Refusing to migrate: bundle analysis verdict is BLOCKED. Pass allow_unsafe=true to override (logged) if you understand the risk.\n\n${formatReport(report)}`);
92
+ }
93
+ if (report.verdict === 'blocked' && allow_unsafe) {
94
+ console.error(`[dailey_wordpress_import] proceeding past a BLOCKED analyze() verdict for ${bundle_file} (allow_unsafe=true)`);
95
+ }
96
+
97
+ let targetProjectId = project_id;
98
+ if (!targetProjectId) {
99
+ const provision = await apiRequest<ProvisionResponse>('POST', '/projects/wordpress/provision-target', {
100
+ old_url: report.source.old_url,
101
+ });
102
+ if (!provision.ok) return textResult(formatError(provision));
103
+ targetProjectId = provision.data.project_id;
104
+ }
105
+
106
+ const tmpDir = mkdtempSync(join(tmpdir(), 'dailey-wp-import-'));
107
+ let staged: Awaited<ReturnType<typeof stage>> | undefined;
108
+ try {
109
+ try {
110
+ staged = await stage(bundle_file, tmpDir, { gzipDb: true });
111
+ } catch (e: unknown) {
112
+ const message = e instanceof Error ? e.message : String(e);
113
+ return textResult(`Failed to stage bundle: ${message}`);
114
+ }
115
+
116
+ const start = await apiRequest<StartResponse>('POST', `/projects/${targetProjectId}/migrate/wordpress`, {
117
+ db_filename: basename(staged.dbFile),
118
+ content_filename: basename(staged.contentFile),
119
+ });
120
+ if (!start.ok) return textResult(formatError(start));
121
+ const { migration_id: mid, db_upload, content_upload } = start.data;
122
+
123
+ try {
124
+ await putFileToPresignedUrl(db_upload.url, staged.dbFile, db_upload.headers);
125
+ await putFileToPresignedUrl(content_upload.url, staged.contentFile, content_upload.headers);
126
+ } catch (e: unknown) {
127
+ const message = e instanceof Error ? e.message : String(e);
128
+ return textResult(`Upload failed: ${message}\nMigration ${mid} is still pending on project ${targetProjectId} — fix the file and call migrate again (a new migration will be started).`);
129
+ }
130
+
131
+ const scan = await apiRequest<ScanResponse>('POST', `/projects/${targetProjectId}/migrate/wordpress/${mid}/scan`, {
132
+ allow_unsafe: Boolean(allow_unsafe),
133
+ });
134
+ if (scan.status === 409) {
135
+ const findings = (scan.data as ScanResponse | undefined)?.findings ?? [];
136
+ const list = findings.length ? findings.map((f) => ` [${f.level}] ${f.code}: ${f.message}`).join('\n') : ' (no findings detail returned)';
137
+ return textResult(`Refusing to run: server-side scan gate is BLOCKED.\n${list}\nMigration ${mid} is still pending on project ${targetProjectId} — pass allow_unsafe=true to override (logged) and call migrate again.`);
138
+ }
139
+ if (!scan.ok) return textResult(formatError(scan));
140
+
141
+ const run = await apiRequest<RunResponse>('POST', `/projects/${targetProjectId}/migrate/wordpress/${mid}/run`, {
142
+ old_url: report.source.old_url,
143
+ ...(report.source.table_prefix && report.source.table_prefix !== 'wp_' ? { table_prefix: report.source.table_prefix } : {}),
144
+ });
145
+ if (!run.ok) return textResult(formatError(run));
146
+
147
+ // Poll to terminal state (up to ~10 min; migrations are usually 1-3 min).
148
+ // Check immediately (a migration can finish before the first poll tick)
149
+ // and only sleep between checks, not before the first one.
150
+ const started = Date.now();
151
+ let last: StatusResponse | null = null;
152
+ while (Date.now() - started < 10 * 60 * 1000) {
153
+ const st = await apiRequest<StatusResponse>('GET', `/projects/${targetProjectId}/migrate/wordpress/${mid}`);
154
+ if (st.ok) {
155
+ last = st.data;
156
+ if (last.status === 'succeeded' || last.status === 'failed') break;
157
+ }
158
+ await new Promise((r) => setTimeout(r, 5000));
159
+ }
160
+ if (!last) return textResult(`Migration ${mid} launched but status could not be read. Check later with action=status project_id=${targetProjectId} migration_id=${mid}.`);
161
+ if (last.status === 'succeeded') {
162
+ return textResult(`Migration succeeded. Site is live at ${run.data.new_url} with the imported content.\nNote: hard-refresh and re-save permalinks (Settings > Permalinks) if pretty URLs 404.`);
163
+ }
164
+ if (last.status === 'failed') {
165
+ return textResult(`Migration FAILED at step: ${last.step ?? 'unknown'}\n${last.error ?? ''}\n--- log ---\n${last.log_tail ?? ''}\nYour staged files were kept — fix the issue and run migrate again.`);
166
+ }
167
+ return textResult(`Migration ${mid} still ${last.status} (step: ${last.step ?? '-'}) after 10 min — check again with action=status project_id=${targetProjectId} migration_id=${mid}.`);
168
+ } finally {
169
+ if (staged) await staged.cleanup().catch(() => {});
170
+ rmSync(tmpDir, { recursive: true, force: true });
171
+ }
172
+ },
173
+ );
174
+ }
@@ -8,8 +8,11 @@ interface Snapshot {
8
8
  kind: string;
9
9
  status: string;
10
10
  env?: string;
11
+ reason?: string;
12
+ label?: string | null;
11
13
  db_bytes?: number;
12
14
  uploads_bytes?: number;
15
+ content_bytes?: number;
13
16
  }
14
17
 
15
18
  interface SnapshotsResponse {
@@ -78,13 +81,13 @@ export function registerWordPressSnapshotTools(server: McpServer) {
78
81
 
79
82
  const lines = [
80
83
  `Snapshots for project ${project_id}`,
81
- `${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'Kind'.padEnd(12)} ${'Status'.padEnd(12)} ${'DB'.padEnd(10)} Uploads`,
84
+ `${'ID'.padEnd(38)} ${'Created'.padEnd(26)} ${'Reason'.padEnd(10)} ${'Label'.padEnd(24)} ${'Status'.padEnd(12)} ${'DB'.padEnd(10)} Content`,
82
85
  '─'.repeat(115),
83
86
  ];
84
87
 
85
88
  for (const s of snapshots) {
86
89
  lines.push(
87
- `${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.kind || '-').padEnd(12)} ${(s.status || '-').padEnd(12)} ${fmtBytes(s.db_bytes).padEnd(10)} ${fmtBytes(s.uploads_bytes)}`,
90
+ `${(s.id || '').padEnd(38)} ${(s.created_at || '-').padEnd(26)} ${(s.reason || 'manual').padEnd(10)} ${((s.label ?? '').slice(0, 24) || '—').padEnd(24)} ${(s.status || '-').padEnd(12)} ${fmtBytes(s.db_bytes).padEnd(10)} ${fmtBytes(s.content_bytes ?? s.uploads_bytes)}`,
88
91
  );
89
92
  }
90
93
 
@@ -97,9 +100,10 @@ export function registerWordPressSnapshotTools(server: McpServer) {
97
100
  'Create a snapshot (DB + uploads) of a WordPress project',
98
101
  {
99
102
  project_id: z.string().describe('The project ID'),
103
+ label: z.string().optional().describe('Optional human label; labeled points are kept until deleted (never auto-expire)'),
100
104
  },
101
- async ({ project_id }) => {
102
- const res = await apiRequest<SnapshotStartResponse>('POST', `/projects/${project_id}/wp/snapshot`);
105
+ async ({ project_id, label }) => {
106
+ const res = await apiRequest<SnapshotStartResponse>('POST', `/projects/${project_id}/wp/snapshot`, label ? { label } : undefined);
103
107
  if (!res.ok) return textResult(formatError(res));
104
108
 
105
109
  const { operation_id } = res.data;