@daileyos/mcp-server 1.21.2 → 1.21.9

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 (164) hide show
  1. package/dist/api.d.ts +7 -0
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +23 -2
  4. package/dist/api.js.map +1 -1
  5. package/dist/index.js +24 -17
  6. package/dist/index.js.map +1 -1
  7. package/dist/tools/accounts.d.ts.map +1 -1
  8. package/dist/tools/accounts.js +3 -2
  9. package/dist/tools/accounts.js.map +1 -1
  10. package/dist/tools/ai.d.ts.map +1 -1
  11. package/dist/tools/ai.js +7 -1
  12. package/dist/tools/ai.js.map +1 -1
  13. package/dist/tools/auth.d.ts.map +1 -1
  14. package/dist/tools/auth.js +25 -6
  15. package/dist/tools/auth.js.map +1 -1
  16. package/dist/tools/backups.d.ts.map +1 -1
  17. package/dist/tools/backups.js +3 -1
  18. package/dist/tools/backups.js.map +1 -1
  19. package/dist/tools/build-logs.d.ts.map +1 -1
  20. package/dist/tools/build-logs.js +3 -1
  21. package/dist/tools/build-logs.js.map +1 -1
  22. package/dist/tools/credentials-reveal.d.ts.map +1 -1
  23. package/dist/tools/credentials-reveal.js +3 -1
  24. package/dist/tools/credentials-reveal.js.map +1 -1
  25. package/dist/tools/dailey-images.js +3 -3
  26. package/dist/tools/dailey-images.js.map +1 -1
  27. package/dist/tools/db-migrate.js +5 -5
  28. package/dist/tools/db-migrate.js.map +1 -1
  29. package/dist/tools/db.d.ts.map +1 -1
  30. package/dist/tools/db.js +17 -1
  31. package/dist/tools/db.js.map +1 -1
  32. package/dist/tools/deploy-status.d.ts.map +1 -1
  33. package/dist/tools/deploy-status.js +3 -1
  34. package/dist/tools/deploy-status.js.map +1 -1
  35. package/dist/tools/deploy.d.ts.map +1 -1
  36. package/dist/tools/deploy.js +9 -1
  37. package/dist/tools/deploy.js.map +1 -1
  38. package/dist/tools/domains.d.ts.map +1 -1
  39. package/dist/tools/domains.js +3 -1
  40. package/dist/tools/domains.js.map +1 -1
  41. package/dist/tools/email.d.ts.map +1 -1
  42. package/dist/tools/email.js +8 -2
  43. package/dist/tools/email.js.map +1 -1
  44. package/dist/tools/env.d.ts.map +1 -1
  45. package/dist/tools/env.js +5 -1
  46. package/dist/tools/env.js.map +1 -1
  47. package/dist/tools/environments.js +3 -3
  48. package/dist/tools/environments.js.map +1 -1
  49. package/dist/tools/exec-run.d.ts.map +1 -1
  50. package/dist/tools/exec-run.js +7 -1
  51. package/dist/tools/exec-run.js.map +1 -1
  52. package/dist/tools/images.d.ts.map +1 -1
  53. package/dist/tools/images.js +5 -1
  54. package/dist/tools/images.js.map +1 -1
  55. package/dist/tools/lifecycle.d.ts.map +1 -1
  56. package/dist/tools/lifecycle.js +5 -1
  57. package/dist/tools/lifecycle.js.map +1 -1
  58. package/dist/tools/links.d.ts.map +1 -1
  59. package/dist/tools/links.js +3 -1
  60. package/dist/tools/links.js.map +1 -1
  61. package/dist/tools/platform.d.ts.map +1 -1
  62. package/dist/tools/platform.js +5 -3
  63. package/dist/tools/platform.js.map +1 -1
  64. package/dist/tools/processes.d.ts.map +1 -1
  65. package/dist/tools/processes.js +11 -1
  66. package/dist/tools/processes.js.map +1 -1
  67. package/dist/tools/projects.d.ts.map +1 -1
  68. package/dist/tools/projects.js +36 -12
  69. package/dist/tools/projects.js.map +1 -1
  70. package/dist/tools/resource-config.d.ts.map +1 -1
  71. package/dist/tools/resource-config.js +3 -1
  72. package/dist/tools/resource-config.js.map +1 -1
  73. package/dist/tools/scale.d.ts.map +1 -1
  74. package/dist/tools/scale.js +3 -1
  75. package/dist/tools/scale.js.map +1 -1
  76. package/dist/tools/storage.d.ts.map +1 -1
  77. package/dist/tools/storage.js +11 -1
  78. package/dist/tools/storage.js.map +1 -1
  79. package/dist/tools/support.d.ts.map +1 -1
  80. package/dist/tools/support.js +3 -1
  81. package/dist/tools/support.js.map +1 -1
  82. package/dist/tools/usage.d.ts.map +1 -1
  83. package/dist/tools/usage.js +3 -1
  84. package/dist/tools/usage.js.map +1 -1
  85. package/dist/tools/wordpress-import.d.ts.map +1 -1
  86. package/dist/tools/wordpress-import.js +3 -1
  87. package/dist/tools/wordpress-import.js.map +1 -1
  88. package/dist/tools/wordpress-migrate.d.ts.map +1 -1
  89. package/dist/tools/wordpress-migrate.js +3 -1
  90. package/dist/tools/wordpress-migrate.js.map +1 -1
  91. package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
  92. package/dist/tools/wordpress-snapshot.js +9 -1
  93. package/dist/tools/wordpress-snapshot.js.map +1 -1
  94. package/package.json +10 -2
  95. package/.dockerignore +0 -6
  96. package/.github/workflows/publish.yml +0 -120
  97. package/Dockerfile +0 -19
  98. package/claude-config.json +0 -13
  99. package/docs/superpowers/plans/2026-08-09-remote-mcp-endpoint.md +0 -663
  100. package/docs/superpowers/specs/2026-08-09-remote-mcp-endpoint-design.md +0 -66
  101. package/src/api.ts +0 -263
  102. package/src/context.ts +0 -12
  103. package/src/http.ts +0 -160
  104. package/src/index.ts +0 -94
  105. package/src/server.ts +0 -188
  106. package/src/tools/accounts.ts +0 -119
  107. package/src/tools/addons.ts +0 -124
  108. package/src/tools/admin.ts +0 -42
  109. package/src/tools/ai.ts +0 -83
  110. package/src/tools/analyze.ts +0 -108
  111. package/src/tools/auth.ts +0 -177
  112. package/src/tools/backups.ts +0 -84
  113. package/src/tools/billing.ts +0 -34
  114. package/src/tools/build-logs.ts +0 -65
  115. package/src/tools/bundle.ts +0 -129
  116. package/src/tools/cli.ts +0 -76
  117. package/src/tools/credentials-reveal.ts +0 -64
  118. package/src/tools/credits.ts +0 -97
  119. package/src/tools/dailey-images.ts +0 -151
  120. package/src/tools/db-migrate.ts +0 -211
  121. package/src/tools/db.ts +0 -391
  122. package/src/tools/deploy-status.ts +0 -247
  123. package/src/tools/deploy.ts +0 -101
  124. package/src/tools/diagnose.ts +0 -567
  125. package/src/tools/domains.ts +0 -156
  126. package/src/tools/email.ts +0 -101
  127. package/src/tools/env.ts +0 -205
  128. package/src/tools/environments.ts +0 -138
  129. package/src/tools/exec-run.ts +0 -91
  130. package/src/tools/images.ts +0 -221
  131. package/src/tools/lifecycle.ts +0 -75
  132. package/src/tools/links.ts +0 -69
  133. package/src/tools/platform.ts +0 -209
  134. package/src/tools/processes.ts +0 -182
  135. package/src/tools/project-transfer.ts +0 -129
  136. package/src/tools/projects.ts +0 -287
  137. package/src/tools/resource-config.ts +0 -84
  138. package/src/tools/scale.ts +0 -33
  139. package/src/tools/storage.ts +0 -281
  140. package/src/tools/support.ts +0 -42
  141. package/src/tools/usage.ts +0 -128
  142. package/src/tools/wordpress-import.ts +0 -174
  143. package/src/tools/wordpress-live-edit.ts +0 -250
  144. package/src/tools/wordpress-migrate.ts +0 -104
  145. package/src/tools/wordpress-snapshot.ts +0 -225
  146. package/src/tools/wordpress-targeting.ts +0 -188
  147. package/src/upload.ts +0 -35
  148. package/src/version.ts +0 -70
  149. package/test/context.test.ts +0 -36
  150. package/test/http.test.ts +0 -103
  151. package/test/server-surface.test.ts +0 -36
  152. package/test/use-account-sticky.test.ts +0 -28
  153. package/test/wordpress-import.test.ts +0 -223
  154. package/test/wordpress-live-edit.test.ts +0 -159
  155. package/test/wordpress-targeting.test.ts +0 -162
  156. package/tests/dailey-images.test.mjs +0 -156
  157. package/tests/environments.test.mjs +0 -230
  158. package/tests/mcp-protocol-smoke.mjs +0 -149
  159. package/tests/new-tools-smoke.mjs +0 -217
  160. package/tests/pack1-mcp-preflight.test.mjs +0 -184
  161. package/tests/pack6-smoke.mjs +0 -222
  162. package/tests/wp-snapshot-labels.test.mjs +0 -21
  163. package/tests/wp-snapshot.test.mjs +0 -261
  164. package/tsconfig.json +0 -19
@@ -1,97 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import { apiRequest, formatError, textResult } from '../api.js';
4
-
5
- // Prepaid credits (opt-in $ balance drawn down in real time by metered AI /
6
- // Compute / Email overage). GET returns balance + settings + recent ledger;
7
- // top-up runs a one-time Stripe Checkout (kind:credit_topup) whose URL the
8
- // user must open to pay.
9
- interface CreditAccountResponse {
10
- balance_cents?: number;
11
- prepaid_enabled?: boolean;
12
- auto_recharge_enabled?: boolean;
13
- auto_recharge_threshold_cents?: number;
14
- auto_recharge_amount_cents?: number;
15
- stripe_payment_method_id?: string | null;
16
- editable?: boolean;
17
- ledger?: Array<{
18
- created_at?: string;
19
- delta_cents?: number;
20
- reason?: string;
21
- ref?: string | null;
22
- }>;
23
- }
24
-
25
- interface TopupResponse {
26
- checkout_url?: string | null;
27
- session_id?: string;
28
- }
29
-
30
- const dollars = (cents: number | undefined) =>
31
- `$${(((cents ?? 0)) / 100).toFixed(2)}`;
32
-
33
- export function registerCreditTools(server: McpServer) {
34
- server.tool(
35
- 'dailey_credits',
36
- 'Show the account prepaid credit balance and settings: current balance, whether prepaid is enabled, auto-recharge config, and the recent credit ledger. Prepaid credits are drawn down in real time by metered AI / Compute / Email overage; a $0 balance hard-stops those. Top up with dailey_credits_topup.',
37
- {},
38
- async () => {
39
- const res = await apiRequest<CreditAccountResponse>('GET', '/account/credits');
40
- if (!res.ok) return textResult(formatError(res));
41
- const d = res.data;
42
- const lines = [
43
- 'Prepaid Credits',
44
- `Balance: ${dollars(d.balance_cents)}`,
45
- `Prepaid enabled: ${d.prepaid_enabled ? 'yes' : 'no'}`,
46
- `Auto-recharge: ${d.auto_recharge_enabled ? 'on' : 'off'}`,
47
- ];
48
- if (d.auto_recharge_enabled) {
49
- lines.push(` when below: ${dollars(d.auto_recharge_threshold_cents)}`);
50
- lines.push(` top up by: ${dollars(d.auto_recharge_amount_cents)}`);
51
- }
52
- const ledger = d.ledger || [];
53
- lines.push('');
54
- lines.push('Recent ledger:');
55
- if (ledger.length === 0) {
56
- lines.push(' (none)');
57
- } else {
58
- for (const e of ledger.slice(0, 20)) {
59
- const sign = (e.delta_cents ?? 0) >= 0 ? '+' : '-';
60
- lines.push(
61
- ` ${e.created_at || '?'} ${sign}${dollars(Math.abs(e.delta_cents ?? 0))} ${e.reason || ''}${e.ref ? ` (${e.ref})` : ''}`,
62
- );
63
- }
64
- }
65
- lines.push('');
66
- lines.push('Top up with dailey_credits_topup (opens a Stripe Checkout).');
67
- return textResult(lines.join('\n'));
68
- },
69
- );
70
-
71
- server.tool(
72
- 'dailey_credits_topup',
73
- 'Buy a one-time prepaid credit top-up. Returns a Stripe Checkout URL the user MUST open to pay — the balance is only credited after payment completes (do NOT treat credits as added until then). The card is saved for off_session auto-recharge. Amount is $5–$1,000.',
74
- {
75
- amount_usd: z.number().min(5).max(1000).describe('Top-up amount in US dollars (5 to 1000).'),
76
- },
77
- async ({ amount_usd }) => {
78
- const amount_cents = Math.round(amount_usd * 100);
79
- const res = await apiRequest<TopupResponse>('POST', '/account/credits/checkout', { amount_cents });
80
- if (!res.ok) return textResult(formatError(res));
81
- const d = res.data;
82
- if (!d.checkout_url) {
83
- return textResult('Top-up created but no checkout_url was returned. Retry, or top up from Billing → Credits.');
84
- }
85
- return textResult(
86
- [
87
- `Prepaid top-up of ${dollars(amount_cents)}.`,
88
- '',
89
- '➜ Open this URL to complete payment:',
90
- d.checkout_url,
91
- '',
92
- 'Your balance is credited automatically once the Stripe Checkout is paid. It is NOT added yet.',
93
- ].join('\n'),
94
- );
95
- },
96
- );
97
- }
@@ -1,151 +0,0 @@
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
- }
@@ -1,211 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import { apiRequest, formatError, textResult } from '../api.js';
4
-
5
- // MigrationRow as returned by the customer-api managed-migrations endpoints.
6
- // callback_token_hash is never returned by the server, and we never echo the
7
- // source password back in tool output (security hard rule).
8
- interface MigrationRow {
9
- id: string;
10
- project_id: string;
11
- engine: string;
12
- status: string;
13
- phase?: string;
14
- message?: string;
15
- rows_total?: number;
16
- rows_copied?: number;
17
- target_user?: string;
18
- target_db?: string;
19
- report_json?: unknown;
20
- error?: string;
21
- dispatch_count?: number;
22
- created_at?: string;
23
- updated_at?: string;
24
- }
25
-
26
- interface StartResponse {
27
- id: string;
28
- status: string;
29
- }
30
-
31
- interface ListResponse {
32
- migrations: MigrationRow[];
33
- }
34
-
35
- interface GetResponse {
36
- migration: MigrationRow;
37
- }
38
-
39
- interface ConfirmResponse {
40
- id: string;
41
- status: string;
42
- }
43
-
44
- interface CancelResponse {
45
- id: string;
46
- status: string;
47
- }
48
-
49
- const sshSchema = z
50
- .object({
51
- host: z.string().describe('SSH bastion/tunnel host'),
52
- port: z.number().int().optional().describe('SSH port (default 22)'),
53
- user: z.string().describe('SSH user'),
54
- password: z.string().optional().describe('SSH password (do not echo back)'),
55
- private_key: z.string().optional().describe('SSH private key (PEM)'),
56
- passphrase: z.string().optional().describe('Passphrase for the private key'),
57
- })
58
- .passthrough();
59
-
60
- const sourceSchema = z.object({
61
- host: z.string().describe('Source database host'),
62
- port: z.number().int().optional().describe('Source database port'),
63
- database: z.string().describe('Source database name'),
64
- user: z.string().describe('Source database user'),
65
- password: z.string().describe('Source database password — never echoed back in tool output'),
66
- ssh: sshSchema.optional().describe('Optional SSH tunnel config for reaching the source DB'),
67
- });
68
-
69
- function progressLines(m: MigrationRow): string[] {
70
- const lines = [
71
- `Migration ${m.id}`,
72
- '─'.repeat(40),
73
- `Status: ${m.status || 'unknown'}`,
74
- ];
75
- if (m.phase) lines.push(`Phase: ${m.phase}`);
76
- if (m.message) lines.push(`Message: ${m.message}`);
77
- if (m.rows_total !== undefined && m.rows_total !== null) {
78
- const copied = m.rows_copied ?? 0;
79
- lines.push(`Rows: ${copied}/${m.rows_total} copied`);
80
- } else if (m.rows_copied !== undefined && m.rows_copied !== null) {
81
- lines.push(`Rows: ${m.rows_copied} copied`);
82
- }
83
- if (m.target_user) lines.push(`Target user: ${m.target_user}`);
84
- if (m.target_db) lines.push(`Target db: ${m.target_db}`);
85
- if (m.error) lines.push(`Error: ${m.error}`);
86
- if (m.report_json) {
87
- try {
88
- const parsed = typeof m.report_json === 'string' ? JSON.parse(m.report_json) : m.report_json;
89
- if (parsed && typeof parsed === 'object') {
90
- lines.push(`Report: ${JSON.stringify(parsed)}`);
91
- }
92
- } catch {
93
- // report_json did not parse — skip the summary line.
94
- }
95
- }
96
- return lines;
97
- }
98
-
99
- export function registerMigrateTools(server: McpServer) {
100
- server.tool(
101
- 'dailey_db_migrate_start',
102
- 'Start a managed database migration from an external source DB into a project\'s managed database. Submits the source connection and kicks off an estimate (dry-run) — it does NOT copy data yet. The server derives the target engine from the project\'s managed DB (mysql | postgres); the source DB must be the SAME engine. Returns a migration id and status="estimating". Poll dailey_db_migrate_status until status="awaiting_confirm", review rows_total, then call dailey_db_migrate_confirm to run the real copy. The source password is used only to connect — it is never echoed back in any output.',
103
- {
104
- project_id: z.string().describe('The project ID (or name) to migrate INTO'),
105
- source: sourceSchema.describe('External source database connection details'),
106
- allow_non_empty: z.boolean().optional().describe('Allow migrating into a target DB that already has data'),
107
- row_ceiling: z.number().int().optional().describe('Optional safety cap on total rows to migrate'),
108
- },
109
- async ({ project_id, source, allow_non_empty, row_ceiling }) => {
110
- const body: Record<string, unknown> = {
111
- host: source.host,
112
- database: source.database,
113
- user: source.user,
114
- password: source.password,
115
- };
116
- if (source.port !== undefined) body.port = source.port;
117
- if (source.ssh !== undefined) body.ssh = source.ssh;
118
- if (allow_non_empty !== undefined) body.allow_non_empty = allow_non_empty;
119
- if (row_ceiling !== undefined) body.row_ceiling = row_ceiling;
120
-
121
- const res = await apiRequest<StartResponse>('POST', `/projects/${project_id}/migrations`, body);
122
- if (!res.ok) return textResult(formatError(res));
123
-
124
- const d = res.data;
125
- const lines = [
126
- `Migration started`,
127
- '─'.repeat(40),
128
- `ID: ${d.id}`,
129
- `Status: ${d.status}`,
130
- '',
131
- `Estimating now. Poll dailey_db_migrate_status project_id=${project_id} id=${d.id} until status=awaiting_confirm,`,
132
- `then dailey_db_migrate_confirm to run the real copy.`,
133
- ];
134
- return textResult(lines.join('\n'));
135
- },
136
- );
137
-
138
- server.tool(
139
- 'dailey_db_migrate_status',
140
- 'Check the status/progress of a managed migration. With an id, returns that migration\'s progress fields (status, phase, message, rows_total, rows_copied, target_user, target_db, error). Without an id, lists all migrations for the project. Live progress is rows_copied/rows_total. Terminal statuses are completed | failed | canceled.',
141
- {
142
- project_id: z.string().describe('The project ID (or name)'),
143
- id: z.string().optional().describe('Migration id. Omit to list all migrations for the project.'),
144
- },
145
- async ({ project_id, id }) => {
146
- if (!id) {
147
- const res = await apiRequest<ListResponse>('GET', `/projects/${project_id}/migrations`);
148
- if (!res.ok) return textResult(formatError(res));
149
- const migrations = res.data.migrations || [];
150
- if (migrations.length === 0) return textResult('No migrations for this project.');
151
- const lines = [`Migrations (${migrations.length})`, '─'.repeat(40)];
152
- for (const m of migrations) {
153
- const rows =
154
- m.rows_total !== undefined && m.rows_total !== null
155
- ? ` ${m.rows_copied ?? 0}/${m.rows_total} rows`
156
- : '';
157
- lines.push(`• ${m.id} status=${m.status}${m.phase ? ` phase=${m.phase}` : ''}${rows}`);
158
- }
159
- return textResult(lines.join('\n'));
160
- }
161
-
162
- const res = await apiRequest<GetResponse>('GET', `/projects/${project_id}/migrations/${id}`);
163
- if (!res.ok) return textResult(formatError(res));
164
- return textResult(progressLines(res.data.migration).join('\n'));
165
- },
166
- );
167
-
168
- server.tool(
169
- 'dailey_db_migrate_confirm',
170
- 'Confirm a managed migration that is awaiting confirmation. This triggers the REAL data copy and mints a temporary target user for the load — it is only valid from status=awaiting_confirm. Returns the id and status="queued". After confirming, poll dailey_db_migrate_status to watch rows_copied/rows_total until a terminal status (completed | failed | canceled).',
171
- {
172
- project_id: z.string().describe('The project ID (or name)'),
173
- id: z.string().describe('Migration id to confirm (must be awaiting_confirm)'),
174
- },
175
- async ({ project_id, id }) => {
176
- const res = await apiRequest<ConfirmResponse>('POST', `/projects/${project_id}/migrations/${id}/confirm`);
177
- if (!res.ok) return textResult(formatError(res));
178
- const d = res.data;
179
- const lines = [
180
- `Migration confirmed — real data copy queued`,
181
- '─'.repeat(40),
182
- `ID: ${d.id}`,
183
- `Status: ${d.status}`,
184
- '',
185
- `Poll dailey_db_migrate_status project_id=${project_id} id=${d.id} to watch progress to completion.`,
186
- ];
187
- return textResult(lines.join('\n'));
188
- },
189
- );
190
-
191
- server.tool(
192
- 'dailey_db_migrate_cancel',
193
- 'Cancel a managed migration. Valid from status pending | estimating | awaiting_confirm | queued (409 otherwise). Returns the id and status="canceled".',
194
- {
195
- project_id: z.string().describe('The project ID (or name)'),
196
- id: z.string().describe('Migration id to cancel'),
197
- },
198
- async ({ project_id, id }) => {
199
- const res = await apiRequest<CancelResponse>('POST', `/projects/${project_id}/migrations/${id}/cancel`);
200
- if (!res.ok) return textResult(formatError(res));
201
- const d = res.data;
202
- const lines = [
203
- `Migration canceled`,
204
- '─'.repeat(40),
205
- `ID: ${d.id}`,
206
- `Status: ${d.status}`,
207
- ];
208
- return textResult(lines.join('\n'));
209
- },
210
- );
211
- }