@daileyos/mcp-server 1.21.1 → 1.21.4

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 (181) hide show
  1. package/dist/api.d.ts +7 -0
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +37 -3
  4. package/dist/api.js.map +1 -1
  5. package/dist/context.d.ts +8 -0
  6. package/dist/context.d.ts.map +1 -0
  7. package/dist/context.js +6 -0
  8. package/dist/context.js.map +1 -0
  9. package/dist/http.d.ts +5 -0
  10. package/dist/http.d.ts.map +1 -0
  11. package/dist/http.js +193 -0
  12. package/dist/http.js.map +1 -0
  13. package/dist/index.js +32 -163
  14. package/dist/index.js.map +1 -1
  15. package/dist/server.d.ts +9 -0
  16. package/dist/server.d.ts.map +1 -0
  17. package/dist/server.js +165 -0
  18. package/dist/server.js.map +1 -0
  19. package/dist/tools/accounts.d.ts +4 -1
  20. package/dist/tools/accounts.d.ts.map +1 -1
  21. package/dist/tools/accounts.js +57 -53
  22. package/dist/tools/accounts.js.map +1 -1
  23. package/dist/tools/ai.d.ts.map +1 -1
  24. package/dist/tools/ai.js +7 -1
  25. package/dist/tools/ai.js.map +1 -1
  26. package/dist/tools/auth.d.ts.map +1 -1
  27. package/dist/tools/auth.js +25 -6
  28. package/dist/tools/auth.js.map +1 -1
  29. package/dist/tools/backups.d.ts.map +1 -1
  30. package/dist/tools/backups.js +3 -1
  31. package/dist/tools/backups.js.map +1 -1
  32. package/dist/tools/build-logs.d.ts.map +1 -1
  33. package/dist/tools/build-logs.js +3 -1
  34. package/dist/tools/build-logs.js.map +1 -1
  35. package/dist/tools/credentials-reveal.d.ts.map +1 -1
  36. package/dist/tools/credentials-reveal.js +3 -1
  37. package/dist/tools/credentials-reveal.js.map +1 -1
  38. package/dist/tools/dailey-images.js +3 -3
  39. package/dist/tools/dailey-images.js.map +1 -1
  40. package/dist/tools/db-migrate.js +5 -5
  41. package/dist/tools/db-migrate.js.map +1 -1
  42. package/dist/tools/db.d.ts.map +1 -1
  43. package/dist/tools/db.js +17 -1
  44. package/dist/tools/db.js.map +1 -1
  45. package/dist/tools/deploy-status.d.ts.map +1 -1
  46. package/dist/tools/deploy-status.js +3 -1
  47. package/dist/tools/deploy-status.js.map +1 -1
  48. package/dist/tools/deploy.d.ts.map +1 -1
  49. package/dist/tools/deploy.js +9 -1
  50. package/dist/tools/deploy.js.map +1 -1
  51. package/dist/tools/domains.d.ts.map +1 -1
  52. package/dist/tools/domains.js +3 -1
  53. package/dist/tools/domains.js.map +1 -1
  54. package/dist/tools/email.d.ts.map +1 -1
  55. package/dist/tools/email.js +7 -1
  56. package/dist/tools/email.js.map +1 -1
  57. package/dist/tools/env.d.ts.map +1 -1
  58. package/dist/tools/env.js +5 -1
  59. package/dist/tools/env.js.map +1 -1
  60. package/dist/tools/environments.js +3 -3
  61. package/dist/tools/environments.js.map +1 -1
  62. package/dist/tools/exec-run.d.ts.map +1 -1
  63. package/dist/tools/exec-run.js +7 -1
  64. package/dist/tools/exec-run.js.map +1 -1
  65. package/dist/tools/images.d.ts.map +1 -1
  66. package/dist/tools/images.js +5 -1
  67. package/dist/tools/images.js.map +1 -1
  68. package/dist/tools/lifecycle.d.ts.map +1 -1
  69. package/dist/tools/lifecycle.js +5 -1
  70. package/dist/tools/lifecycle.js.map +1 -1
  71. package/dist/tools/links.d.ts.map +1 -1
  72. package/dist/tools/links.js +3 -1
  73. package/dist/tools/links.js.map +1 -1
  74. package/dist/tools/platform.d.ts.map +1 -1
  75. package/dist/tools/platform.js +3 -1
  76. package/dist/tools/platform.js.map +1 -1
  77. package/dist/tools/processes.d.ts.map +1 -1
  78. package/dist/tools/processes.js +11 -1
  79. package/dist/tools/processes.js.map +1 -1
  80. package/dist/tools/projects.d.ts.map +1 -1
  81. package/dist/tools/projects.js +36 -12
  82. package/dist/tools/projects.js.map +1 -1
  83. package/dist/tools/resource-config.d.ts.map +1 -1
  84. package/dist/tools/resource-config.js +3 -1
  85. package/dist/tools/resource-config.js.map +1 -1
  86. package/dist/tools/scale.d.ts.map +1 -1
  87. package/dist/tools/scale.js +3 -1
  88. package/dist/tools/scale.js.map +1 -1
  89. package/dist/tools/storage.d.ts.map +1 -1
  90. package/dist/tools/storage.js +11 -1
  91. package/dist/tools/storage.js.map +1 -1
  92. package/dist/tools/support.d.ts.map +1 -1
  93. package/dist/tools/support.js +3 -1
  94. package/dist/tools/support.js.map +1 -1
  95. package/dist/tools/usage.d.ts.map +1 -1
  96. package/dist/tools/usage.js +3 -1
  97. package/dist/tools/usage.js.map +1 -1
  98. package/dist/tools/wordpress-import.d.ts.map +1 -1
  99. package/dist/tools/wordpress-import.js +3 -1
  100. package/dist/tools/wordpress-import.js.map +1 -1
  101. package/dist/tools/wordpress-migrate.d.ts.map +1 -1
  102. package/dist/tools/wordpress-migrate.js +3 -1
  103. package/dist/tools/wordpress-migrate.js.map +1 -1
  104. package/dist/tools/wordpress-snapshot.d.ts.map +1 -1
  105. package/dist/tools/wordpress-snapshot.js +9 -1
  106. package/dist/tools/wordpress-snapshot.js.map +1 -1
  107. package/dist/tools/wordpress-targeting.d.ts.map +1 -1
  108. package/dist/tools/wordpress-targeting.js +22 -7
  109. package/dist/tools/wordpress-targeting.js.map +1 -1
  110. package/package.json +7 -3
  111. package/.github/workflows/publish.yml +0 -120
  112. package/claude-config.json +0 -13
  113. package/dist/tools/buddy.d.ts +0 -3
  114. package/dist/tools/buddy.d.ts.map +0 -1
  115. package/dist/tools/buddy.js +0 -765
  116. package/dist/tools/buddy.js.map +0 -1
  117. package/dist/tools/payments.d.ts +0 -3
  118. package/dist/tools/payments.d.ts.map +0 -1
  119. package/dist/tools/payments.js +0 -96
  120. package/dist/tools/payments.js.map +0 -1
  121. package/dist/tools/redis.d.ts +0 -3
  122. package/dist/tools/redis.d.ts.map +0 -1
  123. package/dist/tools/redis.js +0 -72
  124. package/dist/tools/redis.js.map +0 -1
  125. package/src/api.ts +0 -255
  126. package/src/index.ts +0 -247
  127. package/src/tools/accounts.ts +0 -111
  128. package/src/tools/addons.ts +0 -124
  129. package/src/tools/admin.ts +0 -42
  130. package/src/tools/ai.ts +0 -83
  131. package/src/tools/analyze.ts +0 -108
  132. package/src/tools/auth.ts +0 -177
  133. package/src/tools/backups.ts +0 -84
  134. package/src/tools/billing.ts +0 -34
  135. package/src/tools/build-logs.ts +0 -65
  136. package/src/tools/bundle.ts +0 -129
  137. package/src/tools/cli.ts +0 -76
  138. package/src/tools/credentials-reveal.ts +0 -64
  139. package/src/tools/credits.ts +0 -97
  140. package/src/tools/dailey-images.ts +0 -151
  141. package/src/tools/db-migrate.ts +0 -211
  142. package/src/tools/db.ts +0 -391
  143. package/src/tools/deploy-status.ts +0 -247
  144. package/src/tools/deploy.ts +0 -101
  145. package/src/tools/diagnose.ts +0 -567
  146. package/src/tools/domains.ts +0 -156
  147. package/src/tools/email.ts +0 -101
  148. package/src/tools/env.ts +0 -205
  149. package/src/tools/environments.ts +0 -138
  150. package/src/tools/exec-run.ts +0 -91
  151. package/src/tools/images.ts +0 -221
  152. package/src/tools/lifecycle.ts +0 -75
  153. package/src/tools/links.ts +0 -69
  154. package/src/tools/platform.ts +0 -209
  155. package/src/tools/processes.ts +0 -182
  156. package/src/tools/project-transfer.ts +0 -129
  157. package/src/tools/projects.ts +0 -287
  158. package/src/tools/resource-config.ts +0 -84
  159. package/src/tools/scale.ts +0 -33
  160. package/src/tools/storage.ts +0 -281
  161. package/src/tools/support.ts +0 -42
  162. package/src/tools/usage.ts +0 -128
  163. package/src/tools/wordpress-import.ts +0 -174
  164. package/src/tools/wordpress-live-edit.ts +0 -250
  165. package/src/tools/wordpress-migrate.ts +0 -104
  166. package/src/tools/wordpress-snapshot.ts +0 -225
  167. package/src/tools/wordpress-targeting.ts +0 -173
  168. package/src/upload.ts +0 -35
  169. package/src/version.ts +0 -70
  170. package/test/wordpress-import.test.ts +0 -223
  171. package/test/wordpress-live-edit.test.ts +0 -159
  172. package/test/wordpress-targeting.test.ts +0 -127
  173. package/tests/dailey-images.test.mjs +0 -156
  174. package/tests/environments.test.mjs +0 -230
  175. package/tests/mcp-protocol-smoke.mjs +0 -149
  176. package/tests/new-tools-smoke.mjs +0 -217
  177. package/tests/pack1-mcp-preflight.test.mjs +0 -184
  178. package/tests/pack6-smoke.mjs +0 -222
  179. package/tests/wp-snapshot-labels.test.mjs +0 -21
  180. package/tests/wp-snapshot.test.mjs +0 -261
  181. package/tsconfig.json +0 -19
@@ -1,64 +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
- /**
6
- * Mask a credential value for display. Keeps the last 3 characters so the
7
- * caller can sanity-check which credential they're looking at, hides the
8
- * rest. Returns just the length indicator for very short values.
9
- */
10
- function maskValue(v: string): string {
11
- if (!v) return '(empty)';
12
- if (v.length <= 4) return '•'.repeat(v.length) + ` (${v.length} chars)`;
13
- const tail = v.slice(-3);
14
- return '•'.repeat(Math.min(v.length - 3, 12)) + tail + ` (${v.length} chars)`;
15
- }
16
-
17
- export function registerCredentialRevealTools(server: McpServer) {
18
- server.tool(
19
- 'dailey_reveal_credential',
20
- 'Reveal a project credential after re-auth. Supports DB credentials (DB_PASSWORD, DB_USER, DB_HOST, DB_PORT, DB_NAME) and storage credentials (S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN, S3_ENDPOINT, S3_REGION, S3_BUCKET_NAME, S3_KEY_PREFIX). Every reveal is audited. BY DEFAULT returns a masked preview (last 3 chars + length) so the value never enters chat transcripts. Pass emit_plaintext=true to see the full value — only do this when you understand the chat-log exposure. Better workflow for S3 vars: use dailey_storage_enable to fix missing injection; use dailey_db_tunnel for DB creds.',
21
- {
22
- project_id: z.string().describe('The project ID'),
23
- key: z.string().describe('Credential key (e.g., DB_PASSWORD, WORDPRESS_ADMIN_PASSWORD)'),
24
- password: z.string().optional().describe('Account password for re-auth (falls back to DAILEY_PASSWORD env var)'),
25
- emit_plaintext: z.boolean().optional().describe('If true, emits the cleartext credential into the response. Default false. Only set true when you understand the chat-log exposure. Rotate immediately afterward if the transcript will be shared.'),
26
- },
27
- async ({ project_id, key, password, emit_plaintext }) => {
28
- const pw = password || process.env.DAILEY_PASSWORD;
29
- if (!pw) {
30
- return textResult(
31
- 'Error: re-auth password required. Set DAILEY_PASSWORD env var or pass password argument. Every reveal is audited.',
32
- );
33
- }
34
-
35
- const res = await apiRequest<{ key: string; value: string }>(
36
- 'POST',
37
- `/projects/${project_id}/credentials/reveal`,
38
- { key, password: pw },
39
- );
40
- if (!res.ok) return textResult(formatError(res));
41
-
42
- const { key: k, value } = res.data;
43
- const lines: string[] = [];
44
-
45
- if (emit_plaintext) {
46
- lines.push(`${k}: ${value}`);
47
- lines.push('');
48
- lines.push('⚠ EMITTED CLEARTEXT — this response is now in the chat log. Rotate');
49
- lines.push(' this credential now via dailey_env_vars set if the transcript is shared,');
50
- lines.push(' synced to cloud AI history, or anywhere outside a private terminal.');
51
- } else {
52
- lines.push(`${k}: ${maskValue(value)} [masked — pass emit_plaintext=true to see]`);
53
- lines.push('');
54
- lines.push('The full credential was NOT emitted. Reveal is audited server-side either way.');
55
- lines.push('If you need the cleartext:');
56
- lines.push(' • dailey_db_tunnel (for DB creds — opens a local port, no value in chat)');
57
- lines.push(' • dashboard "reveal" (browser-only modal — does not hit chat)');
58
- lines.push(' • dailey_reveal_credential(..., emit_plaintext=true) as last resort');
59
- }
60
-
61
- return textResult(lines.join('\n'));
62
- },
63
- );
64
- }
@@ -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
- }