@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,156 +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 Domain {
6
- hostname: string;
7
- is_default?: boolean;
8
- verified?: boolean;
9
- cert_status?: string;
10
- cert_issuer?: string;
11
- removable?: boolean;
12
- created_at?: string;
13
- }
14
-
15
- interface DnsCheckResponse {
16
- domain: string;
17
- expected_cname: string;
18
- expected_a_records: string[];
19
- actual_cname: string[];
20
- actual_a_records: string[];
21
- matched: boolean;
22
- match_type: string | null;
23
- cloudflare_proxied: boolean;
24
- hint: string;
25
- }
26
-
27
- interface CertStatusResponse {
28
- domain: string;
29
- cert: {
30
- subject_cn?: string;
31
- subject_alt_names?: string[];
32
- issuer?: string;
33
- valid_from?: string;
34
- valid_to?: string;
35
- days_remaining?: number | null;
36
- } | null;
37
- status: string;
38
- hint: string;
39
- }
40
-
41
- export function registerDomainTools(server: McpServer) {
42
- server.tool(
43
- 'dailey_domains',
44
- 'Manage custom domains: list, add, remove, check DNS, or check TLS cert status for a custom domain.',
45
- {
46
- project_id: z.string().describe('The project ID'),
47
- action: z.enum(['list', 'add', 'remove', 'dns_check', 'cert_status']).describe('list | add | remove | dns_check | cert_status'),
48
- domain: z.string().optional().describe('Domain name (required for add/remove/dns_check/cert_status)'),
49
- },
50
- async ({ project_id, action, domain }) => {
51
- if (action === 'list') {
52
- const res = await apiRequest<{ domains: Domain[] }>('GET', `/projects/${project_id}/domains`);
53
- if (!res.ok) return textResult(formatError(res));
54
-
55
- const domains = res.data.domains;
56
- if (!domains || domains.length === 0) {
57
- return textResult('No custom domains configured.');
58
- }
59
-
60
- const lines = [`Domains (${domains.length})`, '─'.repeat(60)];
61
- for (const d of domains) {
62
- const flags: string[] = [];
63
- if (d.is_default) flags.push('default');
64
- if (d.verified) flags.push('verified');
65
- if (d.cert_status) flags.push(`cert=${d.cert_status}`);
66
- lines.push(`${d.hostname}${flags.length ? ` [${flags.join(', ')}]` : ''}`);
67
- }
68
- return textResult(lines.join('\n'));
69
- }
70
-
71
- if (action === 'add') {
72
- if (!domain) return textResult('Error: domain is required for add action.');
73
- const res = await apiRequest<any>('POST', `/projects/${project_id}/domains`, { hostname: domain });
74
- if (!res.ok) return textResult(formatError(res));
75
- const d = res.data;
76
- const lines = [`Domain ${d.hostname || domain} added.`, ''];
77
- if (d.instructions) {
78
- lines.push(d.instructions);
79
- lines.push('');
80
- }
81
- lines.push(`After DNS propagates (~1-60 min):`);
82
- lines.push(` 1. dailey_domains action=dns_check domain=${domain} — verify DNS`);
83
- lines.push(` 2. Let's Encrypt issues a cert automatically (~30s)`);
84
- lines.push(` 3. dailey_domains action=cert_status domain=${domain} — confirm cert`);
85
- return textResult(lines.join('\n'));
86
- }
87
-
88
- if (action === 'remove') {
89
- if (!domain) return textResult('Error: domain is required for remove action.');
90
- const res = await apiRequest('DELETE', `/projects/${project_id}/domains`, { hostname: domain });
91
- if (!res.ok) return textResult(formatError(res));
92
- return textResult(`Domain ${domain} removed.`);
93
- }
94
-
95
- if (action === 'dns_check') {
96
- if (!domain) return textResult('Error: domain is required for dns_check.');
97
- const res = await apiRequest<DnsCheckResponse>(
98
- 'GET',
99
- `/projects/${project_id}/domains/dns-check?domain=${encodeURIComponent(domain)}`,
100
- );
101
- if (!res.ok) return textResult(formatError(res));
102
-
103
- const d = res.data;
104
- const lines = [
105
- `DNS check for ${d.domain}`,
106
- '─'.repeat(50),
107
- `Expected CNAME: ${d.expected_cname}`,
108
- `Expected A: ${d.expected_a_records?.join(', ') || '-'}`,
109
- `Actual CNAME: ${d.actual_cname?.join(', ') || '(none)'}`,
110
- `Actual A: ${d.actual_a_records?.join(', ') || '(none)'}`,
111
- `Match: ${d.matched ? '✅ yes' : '❌ no'} ${d.match_type ? `(${d.match_type})` : ''}`,
112
- `Cloudflare proxy: ${d.cloudflare_proxied ? 'yes' : 'no'}`,
113
- '',
114
- `Hint: ${d.hint}`,
115
- ];
116
- return textResult(lines.join('\n'));
117
- }
118
-
119
- if (action === 'cert_status') {
120
- if (!domain) return textResult('Error: domain is required for cert_status.');
121
- const res = await apiRequest<CertStatusResponse>(
122
- 'GET',
123
- `/projects/${project_id}/domains/cert-status?domain=${encodeURIComponent(domain)}`,
124
- );
125
- if (!res.ok) return textResult(formatError(res));
126
-
127
- const d = res.data;
128
- if (!d.cert) {
129
- return textResult([
130
- `Cert status for ${d.domain}`,
131
- '─'.repeat(50),
132
- `Status: ${d.status}`,
133
- '',
134
- `Hint: ${d.hint}`,
135
- ].join('\n'));
136
- }
137
- const lines = [
138
- `Cert status for ${d.domain}`,
139
- '─'.repeat(50),
140
- `Status: ${d.status}`,
141
- `Subject: ${d.cert.subject_cn || '-'}`,
142
- `SANs: ${d.cert.subject_alt_names?.join(', ') || '-'}`,
143
- `Issuer: ${d.cert.issuer || '-'}`,
144
- `Valid from: ${d.cert.valid_from || '-'}`,
145
- `Valid to: ${d.cert.valid_to || '-'}`,
146
- `Days left: ${d.cert.days_remaining ?? '-'}`,
147
- '',
148
- `Hint: ${d.hint}`,
149
- ];
150
- return textResult(lines.join('\n'));
151
- }
152
-
153
- return textResult('Error: Invalid action. Use list, add, remove, dns_check, or cert_status.');
154
- },
155
- );
156
- }
@@ -1,101 +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
- // Dailey Email (pay-at-purchase, per project). Enable runs a $10/mo Stripe
6
- // Checkout — the customer-api returns { ok, pending:true, checkout_url } that the
7
- // user MUST open to pay before email turns on. The operator/no-Stripe path
8
- // returns { ok, email_enabled:true, from } and provisions immediately.
9
- interface EmailEnableResponse {
10
- ok?: boolean;
11
- pending?: boolean;
12
- checkout_url?: string | null;
13
- email_enabled?: boolean;
14
- from?: string;
15
- project_id?: string;
16
- key_masked?: string;
17
- restart_required?: boolean;
18
- docs_url?: string;
19
- }
20
-
21
- interface EmailStatusResponse {
22
- project_id: string;
23
- month: string;
24
- email_enabled: boolean;
25
- suspended: boolean;
26
- suspend_reason: string | null;
27
- from_address: string | null;
28
- usage: { messages_sent: number; bounced: number; complained: number };
29
- }
30
-
31
- export function registerEmailTools(server: McpServer) {
32
- server.tool(
33
- 'dailey_email_enable',
34
- 'Enable Dailey Email ($10/mo, per project) so the app can send from <slug>@send.dailey.cloud. This is PAY-AT-PURCHASE and billing-owner-only: the normal response is a Stripe Checkout URL the user MUST open to pay $10/mo before email turns on — do NOT treat email as enabled until payment completes. The operator/internal path enables immediately (email_enabled:true). After it turns on, redeploy so DAILEY_EMAIL_* env is injected.',
35
- { project_id: z.string().describe('The project ID') },
36
- async ({ project_id }) => {
37
- const res = await apiRequest<EmailEnableResponse>('POST', `/projects/${project_id}/email/enable`, {});
38
- if (!res.ok) return textResult(formatError(res));
39
- const d = res.data;
40
- // Pay-at-purchase: a checkout_url means email is NOT on yet.
41
- if (d.pending && d.checkout_url) {
42
- return textResult(
43
- [
44
- 'Dailey Email is $10/mo and requires payment to enable.',
45
- '',
46
- '➜ Open this URL to finish enabling email (pay $10/mo):',
47
- d.checkout_url,
48
- '',
49
- 'Email turns on automatically once the Stripe Checkout is paid. It is NOT active yet.',
50
- 'After it turns on, redeploy the project (dailey_deploy) to pick up DAILEY_EMAIL_* env.',
51
- ].join('\n'),
52
- );
53
- }
54
- // Operator / already-on path — provisioned immediately.
55
- const lines = ['Dailey Email enabled.'];
56
- if (d.from) lines.push(`From: ${d.from}`);
57
- if (d.key_masked) lines.push(`Key: ${d.key_masked}`);
58
- lines.push('');
59
- lines.push('Redeploy the project (dailey_deploy) to pick up the DAILEY_EMAIL_* env vars.');
60
- return textResult(lines.join('\n'));
61
- },
62
- );
63
-
64
- server.tool(
65
- 'dailey_email_disable',
66
- 'Disable Dailey Email for a project: cancels the $10/mo email_pro subscription, revokes the email key, and removes the DAILEY_EMAIL_* env vars. Billing-owner-only (a manager acting-as a managed account is denied).',
67
- { project_id: z.string().describe('The project ID') },
68
- async ({ project_id }) => {
69
- const res = await apiRequest<{ ok: boolean; email_enabled: boolean }>('DELETE', `/projects/${project_id}/email/enable`);
70
- if (!res.ok) return textResult(formatError(res));
71
- return textResult('Dailey Email disabled. The $10/mo subscription was cancelled and the DAILEY_EMAIL_* env vars removed.');
72
- },
73
- );
74
-
75
- server.tool(
76
- 'dailey_email_status',
77
- 'Show Dailey Email status for a project: whether email is enabled, the From address (<slug>@send.dailey.cloud), any suspension, and current-month usage (messages sent, bounced, complained).',
78
- { project_id: z.string().describe('The project ID') },
79
- async ({ project_id }) => {
80
- const res = await apiRequest<EmailStatusResponse>('GET', `/projects/${project_id}/email`);
81
- if (!res.ok) return textResult(formatError(res));
82
- const d = res.data;
83
- const lines = [
84
- `Dailey Email — ${d.project_id}`,
85
- `Enabled: ${d.email_enabled ? 'yes' : 'no'}`,
86
- `From: ${d.from_address || '(not set)'}`,
87
- ];
88
- if (d.suspended) lines.push(`Suspended: yes${d.suspend_reason ? ` (${d.suspend_reason})` : ''}`);
89
- lines.push('');
90
- lines.push(`Usage (${d.month}):`);
91
- lines.push(` messages_sent: ${d.usage?.messages_sent ?? 0}`);
92
- lines.push(` bounced: ${d.usage?.bounced ?? 0}`);
93
- lines.push(` complained: ${d.usage?.complained ?? 0}`);
94
- if (!d.email_enabled) {
95
- lines.push('');
96
- lines.push('Email is off. Enable with dailey_email_enable (opens a $10/mo Stripe Checkout).');
97
- }
98
- return textResult(lines.join('\n'));
99
- },
100
- );
101
- }
package/src/tools/env.ts DELETED
@@ -1,205 +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 EnvVar {
6
- key: string;
7
- updated_at?: string;
8
- }
9
-
10
- interface RuntimeEnvVar {
11
- key: string;
12
- source: string;
13
- source_name: string | null;
14
- length: number;
15
- preview: string;
16
- }
17
-
18
- interface RuntimeEnvListing {
19
- project_id: string;
20
- project_slug: string;
21
- namespace: string;
22
- no_deployment: boolean;
23
- env_vars: RuntimeEnvVar[];
24
- counts: Record<string, number>;
25
- }
26
-
27
- interface ValidationWarning {
28
- key: string;
29
- expected_length: number;
30
- actual_length: number | null;
31
- reason: string;
32
- }
33
-
34
- /** Append validate-on-set warnings to a tool's text response. Returns an
35
- * empty string when there are none, so call sites can interpolate
36
- * unconditionally. Customer-feedback Scott Waters wishlist #5. */
37
- function formatValidationWarnings(warnings: ValidationWarning[] | undefined): string {
38
- if (!Array.isArray(warnings) || warnings.length === 0) return '';
39
- const lines = ['', 'Validation warnings (value still saved, but couldn\'t confirm in pod secret):'];
40
- for (const w of warnings) {
41
- const lengths = w.actual_length === null
42
- ? `expected ${w.expected_length} bytes`
43
- : `expected ${w.expected_length}, got ${w.actual_length}`;
44
- lines.push(` · ${w.key}: ${w.reason} (${lengths})`);
45
- }
46
- return '\n' + lines.join('\n');
47
- }
48
-
49
- export function registerEnvTools(server: McpServer) {
50
- server.tool(
51
- 'dailey_env_vars',
52
- 'List, set, set_many, or delete environment variables for a project. Use set_many to write multiple vars in a single call (one permission prompt, one Secret sync) — especially useful when an app needs 3+ build-time vars like Supabase/Vite/Next.',
53
- {
54
- project_id: z.string().describe('The project ID'),
55
- action: z.enum(['list', 'set', 'set_many', 'delete']).describe('Action: list, set (single), set_many (bulk), or delete'),
56
- key: z.string().optional().describe('Environment variable key (required for set/delete)'),
57
- value: z.string().optional().describe('Environment variable value (required for set)'),
58
- env_vars: z.record(z.string()).optional().describe('Flat object of env vars for set_many, e.g. { FOO: "bar", BAZ: "qux" }'),
59
- },
60
- async ({ project_id, action, key, value, env_vars }) => {
61
- if (action === 'list') {
62
- const res = await apiRequest<{ env_vars: EnvVar[] }>('GET', `/projects/${project_id}/env`);
63
- if (!res.ok) return textResult(formatError(res));
64
-
65
- const vars = res.data.env_vars;
66
- if (!vars || vars.length === 0) {
67
- return textResult('No environment variables set.');
68
- }
69
-
70
- const lines = [
71
- `Environment Variables (${vars.length})`,
72
- '─'.repeat(60),
73
- ];
74
- for (const v of vars) {
75
- lines.push(`${v.key}${v.updated_at ? ` updated=${v.updated_at}` : ''}`);
76
- }
77
- lines.push('');
78
- lines.push('Values stay hidden here by design. Use the env set/delete actions to manage them safely.');
79
- return textResult(lines.join('\n'));
80
- }
81
-
82
- if (action === 'set') {
83
- if (!key || value === undefined) {
84
- return textResult('Error: key and value are required for set action.');
85
- }
86
- // Try PUT first (update), fall back to POST (create)
87
- const putRes = await apiRequest<{ updated: boolean; key?: string; validation_warnings?: ValidationWarning[] }>(
88
- 'PUT',
89
- `/projects/${project_id}/env/${encodeURIComponent(key)}`,
90
- { value },
91
- );
92
- if (putRes.ok) {
93
- return textResult(`Environment variable ${key} updated.${formatValidationWarnings(putRes.data?.validation_warnings)}`);
94
- }
95
- // If PUT fails (var doesn't exist yet), try POST
96
- const postRes = await apiRequest<{ set: boolean; key?: string; validation_warnings?: ValidationWarning[] }>(
97
- 'POST',
98
- `/projects/${project_id}/env`,
99
- { key, value },
100
- );
101
- if (!postRes.ok) return textResult(formatError(postRes));
102
- return textResult(`Environment variable ${key} set.${formatValidationWarnings(postRes.data?.validation_warnings)}`);
103
- }
104
-
105
- if (action === 'set_many') {
106
- if (!env_vars || Object.keys(env_vars).length === 0) {
107
- return textResult('Error: env_vars object is required for set_many action.');
108
- }
109
- const res = await apiRequest<{ set: boolean; count: number; keys: string[]; validation_warnings?: ValidationWarning[] }>(
110
- 'POST',
111
- `/projects/${project_id}/env`,
112
- { env_vars },
113
- );
114
- if (!res.ok) return textResult(formatError(res));
115
- const d = res.data || {} as any;
116
- return textResult(
117
- `Set ${d.count ?? Object.keys(env_vars).length} environment variables: ${(d.keys || Object.keys(env_vars)).join(', ')}${formatValidationWarnings(d.validation_warnings)}`,
118
- );
119
- }
120
-
121
- if (action === 'delete') {
122
- if (!key) {
123
- return textResult('Error: key is required for delete action.');
124
- }
125
- const res = await apiRequest('DELETE', `/projects/${project_id}/env/${encodeURIComponent(key)}`);
126
- if (!res.ok) return textResult(formatError(res));
127
- return textResult(`Environment variable ${key} deleted.`);
128
- }
129
-
130
- return textResult('Error: Invalid action. Use list, set, or delete.');
131
- },
132
- );
133
-
134
- /**
135
- * dailey_env_runtime_list — what the pod will actually see.
136
- *
137
- * Customer-feedback Scott Waters platform-wishlist 2026-04-25. The
138
- * existing dailey_env_vars list action only shows customer-set vars;
139
- * this tool walks the project's k8s Deployment spec and returns every
140
- * key the pod will receive at runtime, including platform-injected
141
- * ones (S3_*, DATABASE_URL, AUTH_*) tagged by source. Values are
142
- * redacted server-side; the response includes length + first-4 +
143
- * last-4 preview so debugging "is FOO actually set?" doesn't leak
144
- * raw bytes.
145
- */
146
- server.tool(
147
- 'dailey_env_runtime_list',
148
- "Returns every env var the project's pod will see at runtime, including platform-injected ones (S3_*, DATABASE_URL, etc.) — values redacted but lengths shown. Use this when debugging 'is the env var I expect actually present in the pod?'.",
149
- { project_id: z.string().describe('The project ID') },
150
- async ({ project_id }) => {
151
- const res = await apiRequest<RuntimeEnvListing>('GET', `/projects/${project_id}/env/runtime`);
152
- if (!res.ok) return textResult(formatError(res));
153
-
154
- const data = res.data;
155
- if (data.no_deployment) {
156
- return textResult('No deployment found for this project. Run `dailey deploy` (or call dailey_deploy) first — env vars only exist on the deployed pod.');
157
- }
158
-
159
- const sourceLabel: Record<string, string> = {
160
- 'customer': 'customer',
161
- 'platform-storage': 'storage',
162
- 'platform-db': 'db',
163
- 'platform-auth': 'auth',
164
- 'platform-other': 'platform',
165
- 'inline': 'inline',
166
- 'field-ref': 'downward',
167
- 'config-map': 'configmap',
168
- 'unknown': '?',
169
- };
170
-
171
- const lines = [
172
- `Runtime env: ${data.project_slug}`,
173
- `Namespace: ${data.namespace}`,
174
- `Total keys: ${data.env_vars.length}`,
175
- '',
176
- ];
177
-
178
- // Group by source for readability — AI agents pattern-match a lot
179
- // better when "all the platform-storage stuff" is contiguous than
180
- // when keys are alphabetic across all sources.
181
- const grouped = new Map<string, RuntimeEnvVar[]>();
182
- for (const v of data.env_vars) {
183
- const arr = grouped.get(v.source) || [];
184
- arr.push(v);
185
- grouped.set(v.source, arr);
186
- }
187
- const sourceOrder = ['customer', 'platform-storage', 'platform-db', 'platform-auth', 'platform-other', 'inline', 'field-ref', 'config-map', 'unknown'];
188
- for (const source of sourceOrder) {
189
- const vars = grouped.get(source);
190
- if (!vars || vars.length === 0) continue;
191
- lines.push(`[${sourceLabel[source] || source}] (${vars.length})`);
192
- for (const v of vars) {
193
- const lengthStr = v.length === -1 ? '-' : String(v.length);
194
- const sourceName = v.source_name ? ` ← ${v.source_name}` : '';
195
- lines.push(` ${v.key.padEnd(30)} ${lengthStr.padStart(5)}B ${v.preview}${sourceName}`);
196
- }
197
- lines.push('');
198
- }
199
-
200
- lines.push('Values redacted server-side. Customer-set keys can be rotated via dailey_env_vars(action: set).');
201
-
202
- return textResult(lines.join('\n'));
203
- },
204
- );
205
- }
@@ -1,138 +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
- interface Environment {
6
- id?: string;
7
- environment: string;
8
- deployment: string;
9
- domain: string;
10
- status: string;
11
- db_name?: string;
12
- storage_prefix?: string;
13
- image?: string;
14
- replicas?: number;
15
- created_at?: string;
16
- updated_at?: string;
17
- }
18
-
19
- interface EnvironmentsResponse {
20
- environments: Environment[];
21
- }
22
-
23
- interface ClonePreviewPlan {
24
- steps: string[];
25
- sourceLabel?: string;
26
- targetLabel?: string;
27
- }
28
-
29
- interface ClonePreviewResponse {
30
- plan: ClonePreviewPlan;
31
- confirm_token: string;
32
- }
33
-
34
- interface CloneExecuteResponse {
35
- operation_id: string;
36
- }
37
-
38
- export function registerEnvironmentTools(server: McpServer) {
39
- server.tool(
40
- 'dailey_environments',
41
- 'List prod and staging environments for a project',
42
- {
43
- project: z.string().describe('The project ID or slug'),
44
- },
45
- async ({ project }) => {
46
- const res = await apiRequest<EnvironmentsResponse>('GET', `/projects/${project}/environments`);
47
- if (!res.ok) return textResult(formatError(res));
48
-
49
- const envs = res.data.environments;
50
- if (!envs || envs.length === 0) {
51
- return textResult(`No environments found for project ${project}.`);
52
- }
53
-
54
- const lines: string[] = [`Environments for project ${project}:`, ''];
55
-
56
- for (const env of envs) {
57
- const label = env.environment === 'prod' ? 'Production (prod)' : `${env.environment}`;
58
- lines.push(`${label}`);
59
- lines.push(` Status: ${env.status}`);
60
- lines.push(` Domain: https://${env.domain}`);
61
- lines.push(` Deployment: ${env.deployment}`);
62
- if (env.db_name) lines.push(` Database: ${env.db_name}`);
63
- if (env.image) lines.push(` Image: ${env.image}`);
64
- if (env.replicas != null) lines.push(` Replicas: ${env.replicas}`);
65
- if (env.created_at) lines.push(` Created: ${env.created_at}`);
66
- lines.push('');
67
- }
68
-
69
- return textResult(lines.join('\n').trimEnd());
70
- },
71
- );
72
-
73
- server.tool(
74
- 'dailey_wp_clone',
75
- 'Clone a WordPress project from prod to staging (DESTRUCTIVE — two-phase). Call WITHOUT confirm_token to get the plan; re-call WITH the returned confirm_token to execute.',
76
- {
77
- project: z.string().describe('The project ID or slug'),
78
- confirm_token: z.string().optional().describe(
79
- 'Token from the plan response. Omit to preview the plan; provide to execute. ~10min TTL.',
80
- ),
81
- },
82
- async ({ project, confirm_token }) => {
83
- if (!confirm_token) {
84
- // Phase 1: preview
85
- const res = await apiRequest<ClonePreviewResponse>(
86
- 'POST',
87
- `/projects/${project}/wp/clone/preview`,
88
- );
89
- if (!res.ok) return textResult(formatError(res));
90
-
91
- const { plan, confirm_token: token } = res.data;
92
- const lines: string[] = [];
93
-
94
- if (plan.sourceLabel || plan.targetLabel) {
95
- lines.push(`Clone plan: ${plan.sourceLabel ?? 'prod'} → ${plan.targetLabel ?? 'staging'}`);
96
- } else {
97
- lines.push(`Clone plan for project ${project} (prod → staging):`);
98
- }
99
-
100
- if (plan.steps && plan.steps.length > 0) {
101
- lines.push('');
102
- lines.push('Steps:');
103
- plan.steps.forEach((step, i) => {
104
- lines.push(` ${i + 1}. ${step}`);
105
- });
106
- }
107
-
108
- lines.push('');
109
- lines.push(`confirm_token: ${token}`);
110
- lines.push('');
111
- lines.push(
112
- 'This will overwrite staging with prod data. To proceed, re-call dailey_wp_clone with the same project and this confirm_token.',
113
- );
114
-
115
- return textResult(lines.join('\n'));
116
- }
117
-
118
- // Phase 2: execute
119
- const res = await apiRequest<CloneExecuteResponse>(
120
- 'POST',
121
- `/projects/${project}/wp/clone`,
122
- { confirm_token, confirmation: 'CLONE' },
123
- );
124
-
125
- if (!res.ok) {
126
- if (res.status === 409) {
127
- return textResult('A clone or restore operation is already in progress for this project.');
128
- }
129
- return textResult(formatError(res));
130
- }
131
-
132
- const { operation_id } = res.data;
133
- return textResult(
134
- `Clone started. operation_id=${operation_id}. Poll with dailey_wp_operation_status (project, operation_id).`,
135
- );
136
- },
137
- );
138
- }