@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,33 +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
- interface ScaleResponse {
6
- scaled?: boolean;
7
- replicas?: number;
8
- warning?: string;
9
- }
10
-
11
- export function registerScaleTools(server: McpServer) {
12
- server.tool(
13
- 'dailey_scale',
14
- 'Scale project replicas up or down. Surfaces warnings if the DB updated but k8s did not apply (e.g., deployment missing).',
15
- {
16
- project_id: z.string().describe('The project ID'),
17
- replicas: z.number().describe('Number of replicas to scale to'),
18
- },
19
- async ({ project_id, replicas }) => {
20
- const res = await apiRequest<ScaleResponse>('POST', `/projects/${project_id}/scale`, { replicas });
21
- if (!res.ok) return textResult(formatError(res));
22
-
23
- const lines = [`Project ${project_id} scaled to ${replicas} replica(s).`];
24
- if (res.data?.warning) {
25
- lines.push('');
26
- lines.push(`⚠ Warning: ${res.data.warning}`);
27
- lines.push('');
28
- lines.push('Next steps: check dailey_project_resources to see if pods are actually running. If the deployment is missing, trigger a redeploy.');
29
- }
30
- return textResult(lines.join('\n'));
31
- },
32
- );
33
- }
@@ -1,281 +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
- interface StorageInfoResponse {
6
- project: {
7
- id: string;
8
- name: string;
9
- slug: string;
10
- };
11
- binding: {
12
- bucket: string;
13
- provider: string;
14
- endpoint: string;
15
- region: string;
16
- cdn_base_url: string;
17
- binding_model: string;
18
- upload_strategy: string;
19
- download_strategy: string;
20
- usage: {
21
- total_objects: number;
22
- total_size_mb: number;
23
- storage_limit_mb: number;
24
- };
25
- limits: {
26
- max_single_upload_mb: number;
27
- signed_url_ttl_seconds: number;
28
- };
29
- };
30
- next_step?: string;
31
- }
32
-
33
- interface StorageListResponse {
34
- bucket: string;
35
- prefix: string;
36
- continuation_token: string | null;
37
- objects: Array<{
38
- key: string;
39
- size_bytes: number;
40
- size_mb: number;
41
- last_modified: string | null;
42
- etag: string | null;
43
- }>;
44
- }
45
-
46
- interface PresignedUploadResponse {
47
- bucket: string;
48
- key: string;
49
- method: string;
50
- upload_url: string;
51
- expires_at: string;
52
- headers: Record<string, string>;
53
- }
54
-
55
- interface PresignedDownloadResponse {
56
- bucket: string;
57
- key: string;
58
- download_url: string;
59
- expires_at: string;
60
- content_type: string | null;
61
- size_bytes: number | null;
62
- }
63
-
64
- export function registerStorageTools(server: McpServer) {
65
- server.tool(
66
- 'dailey_storage_info',
67
- 'Returns the project\'s storage binding (bucket, prefix, region) AND the SDK env-var convention for server-side integration. For server-side apps in your Dailey-deployed pod: install an S3 SDK and use the auto-injected S3_* env vars (S3_ENDPOINT, S3_REGION, S3_BUCKET_NAME, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN, S3_KEY_PREFIX). For browser-side flows: use dailey_storage_presign_upload/download to mint URLs.',
68
- { project_id: z.string().describe('The project ID') },
69
- async ({ project_id }) => {
70
- const res = await apiRequest<StorageInfoResponse>('GET', `/projects/${project_id}/storage`);
71
- if (!res.ok) return textResult(formatError(res));
72
-
73
- const data = res.data;
74
- const lines = [
75
- `Storage: ${data.project.name}`,
76
- `Slug: ${data.project.slug}`,
77
- `Bucket: ${data.binding.bucket}`,
78
- `Provider: ${data.binding.provider}`,
79
- `Endpoint: ${data.binding.endpoint}`,
80
- `Region: ${data.binding.region}`,
81
- `CDN Base: ${data.binding.cdn_base_url}`,
82
- `Mode: ${data.binding.binding_model}`,
83
- `Upload: ${data.binding.upload_strategy}`,
84
- `Download: ${data.binding.download_strategy}`,
85
- `Objects: ${data.binding.usage.total_objects}`,
86
- `Usage: ${data.binding.usage.total_size_mb} MB / ${data.binding.usage.storage_limit_mb} MB`,
87
- `Max Upload: ${data.binding.limits.max_single_upload_mb} MB`,
88
- `URL TTL: ${data.binding.limits.signed_url_ttl_seconds}s`,
89
- ];
90
-
91
- // Surface credential-missing warning before anything else so the LLM
92
- // sees it immediately and can call dailey_storage_enable to fix it.
93
- if ((data as any).secret_warning) {
94
- lines.push('');
95
- lines.push(`⚠ WARNING: ${(data as any).secret_warning}`);
96
- }
97
-
98
- // Render the new integration_paths block when the API surfaces it.
99
- // Older customer-api responses still set next_step; fall back to that
100
- // verbatim so this tool keeps working during the rolling deploy.
101
- const ip = (data as any).integration_paths;
102
- if (ip) {
103
- lines.push('');
104
- lines.push('Integration paths:');
105
- if (ip.server_side) {
106
- lines.push(` Server-side (deployed app): ${ip.server_side.summary}`);
107
- if (Array.isArray(ip.server_side.env_vars)) {
108
- lines.push(` Auto-injected env vars: ${ip.server_side.env_vars.join(', ')}`);
109
- }
110
- if (ip.server_side.example) {
111
- lines.push(` Example: ${ip.server_side.example}`);
112
- }
113
- }
114
- if (ip.browser_side) {
115
- lines.push(` Browser-side (user's machine): ${ip.browser_side.summary}`);
116
- }
117
- const docsUrl = (data as any).docs_url;
118
- if (docsUrl) {
119
- lines.push(` Docs: ${docsUrl}`);
120
- }
121
- } else if (data.next_step) {
122
- lines.push('');
123
- lines.push(`Next Step: ${data.next_step}`);
124
- }
125
-
126
- return textResult(lines.join('\n'));
127
- },
128
- );
129
-
130
- server.tool(
131
- 'dailey_storage_list_objects',
132
- 'List objects in a project bucket',
133
- {
134
- project_id: z.string().describe('The project ID'),
135
- prefix: z.string().optional().describe('Optional object key prefix'),
136
- limit: z.number().int().min(1).max(500).optional().describe('Maximum objects to return'),
137
- continuation_token: z.string().optional().describe('Token for the next page of objects'),
138
- },
139
- async ({ project_id, prefix, limit, continuation_token }) => {
140
- const params = new URLSearchParams();
141
- if (prefix) params.set('prefix', prefix);
142
- if (typeof limit === 'number') params.set('limit', String(limit));
143
- if (continuation_token) params.set('continuation_token', continuation_token);
144
- const query = params.toString();
145
-
146
- const res = await apiRequest<StorageListResponse>(
147
- 'GET',
148
- `/projects/${project_id}/storage/objects${query ? `?${query}` : ''}`,
149
- );
150
- if (!res.ok) return textResult(formatError(res));
151
-
152
- const data = res.data;
153
- const lines = [
154
- `Bucket: ${data.bucket}`,
155
- `Prefix: ${data.prefix || '(root)'}`,
156
- '',
157
- ];
158
-
159
- if ((data.objects || []).length === 0) {
160
- lines.push('No objects found.');
161
- } else {
162
- for (const object of data.objects) {
163
- lines.push(`- ${object.key}`);
164
- lines.push(` size_mb: ${object.size_mb}`);
165
- lines.push(` size_bytes: ${object.size_bytes}`);
166
- lines.push(` last_modified: ${object.last_modified || '-'}`);
167
- }
168
- }
169
-
170
- if (data.continuation_token) {
171
- lines.push('');
172
- lines.push(`continuation_token: ${data.continuation_token}`);
173
- }
174
-
175
- return textResult(lines.join('\n'));
176
- },
177
- );
178
-
179
- server.tool(
180
- 'dailey_storage_presign_upload',
181
- 'For BROWSER-side flows. Server-side apps deployed on Dailey should instead use the S3 SDK with the auto-injected S3_* env vars (see dailey_storage_info). Creates a presigned upload URL for an object in a project bucket.',
182
- {
183
- project_id: z.string().describe('The project ID'),
184
- key: z.string().describe('The object key to upload'),
185
- content_type: z.string().optional().describe('Optional content type to bind into the signed request'),
186
- content_length_bytes: z.number().int().positive().optional().describe('Optional content length for plan-limit checks'),
187
- expires_in_seconds: z.number().int().min(60).max(3600).optional().describe('Optional URL TTL'),
188
- },
189
- async ({ project_id, key, content_type, content_length_bytes, expires_in_seconds }) => {
190
- const body: Record<string, unknown> = { key };
191
- if (content_type) body.content_type = content_type;
192
- if (typeof content_length_bytes === 'number') body.content_length_bytes = content_length_bytes;
193
- if (typeof expires_in_seconds === 'number') body.expires_in_seconds = expires_in_seconds;
194
-
195
- const res = await apiRequest<PresignedUploadResponse>('POST', `/projects/${project_id}/storage/presign-upload`, body);
196
- if (!res.ok) return textResult(formatError(res));
197
-
198
- const data = res.data;
199
- const lines = [
200
- `Presigned Upload`,
201
- `Bucket: ${data.bucket}`,
202
- `Key: ${data.key}`,
203
- `Method: ${data.method}`,
204
- `Expires: ${data.expires_at}`,
205
- ];
206
- for (const [header, value] of Object.entries(data.headers || {})) {
207
- lines.push(`${header}: ${value}`);
208
- }
209
- lines.push('');
210
- lines.push(data.upload_url);
211
- return textResult(lines.join('\n'));
212
- },
213
- );
214
-
215
- server.tool(
216
- 'dailey_storage_enable',
217
- 'Enable object storage on an existing project that was created without it, OR fix a project where storage was enabled but S3_* env vars are missing from the pod (secret_injected=false from dailey_storage_info). Provisions R2 credentials, creates the k8s secret, and patches the running deployment so pods pick up S3_* vars immediately. A redeploy is not required after calling this.',
218
- { project_id: z.string().describe('The project ID') },
219
- async ({ project_id }) => {
220
- const res = await apiRequest<{ ok: boolean; message: string; prefix: string }>(
221
- 'POST',
222
- `/projects/${project_id}/storage/enable`,
223
- );
224
- if (!res.ok) {
225
- // 409 means already enabled — check if the secret is actually present
226
- if (res.status === 409) {
227
- return textResult(
228
- `Storage is already enabled for this project.\n\nIf S3_* vars are still missing from your pod, the credentials secret may not have been created correctly.\nCheck: dailey_storage_info to see secret_injected status.\nFix: redeploy the project (dailey_deploy) to re-mount the secret.`,
229
- );
230
- }
231
- return textResult(formatError(res));
232
- }
233
- return textResult([
234
- `Storage enabled.`,
235
- ``,
236
- `Prefix: ${res.data.prefix}`,
237
- ``,
238
- res.data.message,
239
- ``,
240
- `S3_* env vars now available in your pod:`,
241
- ` S3_ENDPOINT, S3_REGION, S3_BUCKET_NAME`,
242
- ` S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_SESSION_TOKEN, S3_KEY_PREFIX`,
243
- ``,
244
- `Pods are restarting to pick up the new secret (~30s). No rebuild needed.`,
245
- `If vars are still missing after 60s, call dailey_deploy to trigger a fresh rollout.`,
246
- ].join('\n'));
247
- },
248
- );
249
-
250
- server.tool(
251
- 'dailey_storage_presign_download',
252
- 'For BROWSER-side flows. Server-side apps deployed on Dailey should instead use the S3 SDK with the auto-injected S3_* env vars (see dailey_storage_info). Creates a presigned download URL for an object in a project bucket.',
253
- {
254
- project_id: z.string().describe('The project ID'),
255
- key: z.string().describe('The object key to download'),
256
- download_name: z.string().optional().describe('Optional filename suggestion for the download'),
257
- expires_in_seconds: z.number().int().min(60).max(3600).optional().describe('Optional URL TTL'),
258
- },
259
- async ({ project_id, key, download_name, expires_in_seconds }) => {
260
- const body: Record<string, unknown> = { key };
261
- if (download_name) body.download_name = download_name;
262
- if (typeof expires_in_seconds === 'number') body.expires_in_seconds = expires_in_seconds;
263
-
264
- const res = await apiRequest<PresignedDownloadResponse>('POST', `/projects/${project_id}/storage/presign-download`, body);
265
- if (!res.ok) return textResult(formatError(res));
266
-
267
- const data = res.data;
268
- const lines = [
269
- `Presigned Download`,
270
- `Bucket: ${data.bucket}`,
271
- `Key: ${data.key}`,
272
- `Expires: ${data.expires_at}`,
273
- ];
274
- if (data.content_type) lines.push(`Type: ${data.content_type}`);
275
- if (data.size_bytes !== null) lines.push(`Size: ${data.size_bytes} bytes`);
276
- lines.push('');
277
- lines.push(data.download_url);
278
- return textResult(lines.join('\n'));
279
- },
280
- );
281
- }
@@ -1,42 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import { apiRequest, textResult, formatError } from '../api.js';
4
-
5
- export function registerSupportTools(server: McpServer) {
6
- server.tool(
7
- 'dailey_support',
8
- 'Send a bug report to the Dailey OS support team (jonny@dailey.llc). Use this when you have diagnosed an issue that requires platform-level investigation — a build failure you cannot explain, unexpected pod behavior, database connectivity, storage errors, or anything that looks like an infrastructure problem rather than a code problem. The tool automatically collects recent build logs, pod logs, and env var keys (no values) and includes them in the report. Returns a confirmation once the report is sent.',
9
- {
10
- project_id: z.string().describe('The project ID'),
11
- description: z.string().describe('What is going wrong — be specific. Include what the user was trying to do, what actually happened, and any error messages or unexpected behavior you observed.'),
12
- error_text: z.string().optional().describe('Full error text, stack trace, or log excerpt relevant to the issue'),
13
- steps_tried: z.string().optional().describe('What troubleshooting steps have already been attempted'),
14
- severity: z.enum(['low', 'medium', 'high', 'critical']).optional().describe('Impact level: low (minor inconvenience), medium (feature broken), high (app down), critical (data loss or security). Default: medium'),
15
- },
16
- async ({ project_id, description, error_text, steps_tried, severity }) => {
17
- const body: Record<string, unknown> = { description };
18
- if (error_text) body.error_text = error_text;
19
- if (steps_tried) body.steps_tried = steps_tried;
20
- if (severity) body.severity = severity;
21
-
22
- const res = await apiRequest<{ ok: boolean; message: string }>(
23
- 'POST',
24
- `/projects/${project_id}/support`,
25
- body,
26
- );
27
- if (!res.ok) return textResult(formatError(res));
28
-
29
- return textResult([
30
- `✓ ${res.data.message}`,
31
- '',
32
- 'The report includes:',
33
- ' • Your description and any error text provided',
34
- ' • Last 3 build logs (truncated)',
35
- ' • Recent pod logs',
36
- ' • Env var keys (no values)',
37
- '',
38
- 'You can expect a response at the email on your account.',
39
- ].join('\n'));
40
- },
41
- );
42
- }
@@ -1,128 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import { apiRequest, formatError, textResult, jsonResult } from '../api.js';
4
-
5
- interface AccountUsageResponse {
6
- month: string;
7
- plan: string;
8
- currency: string;
9
- ai: {
10
- input_tokens: number;
11
- output_tokens: number;
12
- requests: number;
13
- tiers: Array<{
14
- tier: string;
15
- used_tokens: number;
16
- requests: number;
17
- allowance_tokens: number;
18
- remaining_tokens: number;
19
- billable_tokens: number;
20
- est_overage_cents: number;
21
- }>;
22
- est_overage_cents: number;
23
- };
24
- compute: {
25
- gpu_minutes: number;
26
- jobs: number;
27
- rate_cents_per_minute: number;
28
- est_overage_cents: number;
29
- };
30
- email: {
31
- enabled: boolean;
32
- messages_sent: number;
33
- included: number;
34
- remaining: number;
35
- est_overage_cents: number;
36
- };
37
- est_total_overage_cents: number;
38
- credits: {
39
- prepaid_enabled: boolean;
40
- balance_cents: number;
41
- auto_recharge_enabled: boolean;
42
- };
43
- }
44
-
45
- const dollars = (cents: number | undefined) => `$${(((cents ?? 0)) / 100).toFixed(2)}`;
46
- const n = (x: number | undefined) => (x ?? 0).toLocaleString();
47
-
48
- export function registerUsageTools(server: McpServer) {
49
- server.tool(
50
- 'dailey_usage',
51
- 'Get resource usage stats for a project',
52
- {
53
- project_id: z.string().describe('The project ID'),
54
- period: z.string().optional().describe('Time period (e.g., 7d, 30d). Default: 7d'),
55
- },
56
- async ({ project_id, period }) => {
57
- const query = `?period=${period || '7d'}`;
58
- const res = await apiRequest<Record<string, unknown>>('GET', `/projects/${project_id}/usage${query}`);
59
- if (!res.ok) return textResult(formatError(res));
60
- return jsonResult(res.data);
61
- },
62
- );
63
-
64
- server.tool(
65
- 'dailey_usage_summary',
66
- 'Show this month\'s metered usage across the whole account: Dailey AI (tokens used, per-tier allowance remaining), Dailey Compute (GPU minutes), and Dailey Email (messages sent vs included) — each with the estimated overage cost — plus the prepaid credit balance that covers overage. Use this to answer "how much have I used?" and "how many credits do I have left?". Top up with dailey_credits_topup.',
67
- {
68
- month: z.string().optional().describe('Month as YYYY-MM (e.g., 2026-07). Defaults to the current month.'),
69
- },
70
- async ({ month }) => {
71
- const q = month ? `?month=${encodeURIComponent(month)}` : '';
72
- const res = await apiRequest<AccountUsageResponse>('GET', `/account/usage${q}`);
73
- if (!res.ok) return textResult(formatError(res));
74
- const d = res.data;
75
- const lines: string[] = [`Dailey usage — ${d.month} (${d.plan} plan)`, ''];
76
-
77
- // Dailey AI
78
- lines.push('Dailey AI');
79
- if (d.ai.tiers.length === 0) {
80
- lines.push(' No AI usage this month.');
81
- } else {
82
- lines.push(` ${n(d.ai.input_tokens + d.ai.output_tokens)} tokens across ${d.ai.tiers.length} tier(s), ${n(d.ai.requests)} requests`);
83
- for (const t of d.ai.tiers) {
84
- const base = t.allowance_tokens > 0
85
- ? `${n(t.used_tokens)} used / ${n(t.allowance_tokens)} allowance (${n(t.remaining_tokens)} left)`
86
- : `${n(t.used_tokens)} used (metered)`;
87
- const over = t.est_overage_cents > 0 ? ` ~${dollars(t.est_overage_cents)} overage` : '';
88
- lines.push(` • ${t.tier}: ${base}${over}`);
89
- }
90
- }
91
- lines.push(` Est. AI overage: ${dollars(d.ai.est_overage_cents)}`);
92
- lines.push('');
93
-
94
- // Dailey Compute
95
- lines.push('Dailey Compute (GPU)');
96
- if (d.compute.gpu_minutes === 0) {
97
- lines.push(' No GPU usage this month.');
98
- } else {
99
- lines.push(` ${n(d.compute.gpu_minutes)} GPU-min across ${n(d.compute.jobs)} job(s) @ ${dollars(d.compute.rate_cents_per_minute)}/min → ~${dollars(d.compute.est_overage_cents)}`);
100
- }
101
- lines.push('');
102
-
103
- // Dailey Email
104
- lines.push('Dailey Email');
105
- if (!d.email.enabled) {
106
- lines.push(' Not enabled (add the Email add-on to send).');
107
- } else {
108
- lines.push(` ${n(d.email.messages_sent)} / ${n(d.email.included)} sent (${n(d.email.remaining)} left)`);
109
- lines.push(` Est. email overage: ${dollars(d.email.est_overage_cents)}`);
110
- }
111
- lines.push('');
112
-
113
- // Totals + credits
114
- lines.push(`Estimated overage this month: ${dollars(d.est_total_overage_cents)}`);
115
- if (d.credits.prepaid_enabled) {
116
- lines.push(`Prepaid credits: ${dollars(d.credits.balance_cents)} balance${d.credits.auto_recharge_enabled ? ' (auto-recharge on)' : ''}`);
117
- lines.push(' Covers metered overage plus real-time Images/Voice usage.');
118
- if (d.credits.balance_cents < d.est_total_overage_cents) {
119
- lines.push(' ⚠ Balance is below the estimated overage — top up with dailey_credits_topup.');
120
- }
121
- } else {
122
- lines.push('Prepaid credits: not enabled (overage is invoiced monthly). Enable prepaid with dailey_credits.');
123
- }
124
-
125
- return textResult(lines.join('\n'));
126
- },
127
- );
128
- }
@@ -1,174 +0,0 @@
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
- }