@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,108 +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 AnalyzeResponse {
6
- _isDockerImage?: boolean;
7
- image?: {
8
- registry?: string;
9
- size_mb?: number;
10
- port?: number;
11
- catalog_match?: string;
12
- description?: string;
13
- };
14
- database?: { needed?: boolean };
15
- estimates?: { pull_time_seconds?: number; deploy_time_seconds?: number };
16
- issues?: string[];
17
- stack?: { name?: string; version?: string };
18
- services_manifest?: {
19
- entries?: Array<{
20
- name: string;
21
- type: string;
22
- provider?: string;
23
- dockerfile?: string;
24
- buildContext?: string;
25
- }>;
26
- };
27
- recommendations?: string[];
28
- }
29
-
30
- export function registerAnalyzeTools(server: McpServer) {
31
- server.tool(
32
- 'dailey_analyze_repo',
33
- 'Analyze a Git repo or Docker image BEFORE creating a project — detects stack, Dockerfile, database needs, and multi-service manifest (dailey.yaml). Use this to preview what a deploy would do.',
34
- {
35
- repo_url: z.string().describe('Git repo URL or Docker image (e.g., github.com/user/repo, wordpress:6-apache)'),
36
- branch: z.string().optional().describe('Branch to analyze (default: main)'),
37
- },
38
- async ({ repo_url, branch }) => {
39
- const res = await apiRequest<AnalyzeResponse>('POST', '/projects/analyze', {
40
- repo_url,
41
- branch: branch || 'main',
42
- });
43
- if (!res.ok) return textResult(formatError(res));
44
-
45
- const d = res.data;
46
- const lines: string[] = [`Analysis: ${repo_url}`, '─'.repeat(50)];
47
-
48
- if (d._isDockerImage) {
49
- lines.push(`Type: Docker image`);
50
- lines.push(`Registry: ${d.image?.registry || 'Docker Hub'}`);
51
- lines.push(`Size: ${d.image?.size_mb ?? '?'} MB`);
52
- lines.push(`Port: ${d.image?.port ?? 3000}`);
53
- lines.push(`DB needed: ${d.database?.needed ? 'yes' : 'no'}`);
54
- if (d.image?.catalog_match) lines.push(`Catalog: ✓ ${d.image.catalog_match}`);
55
- if (d.image?.description) lines.push(`Description: ${d.image.description}`);
56
- } else {
57
- lines.push(`Type: Git repo`);
58
- lines.push(`Branch: ${branch || 'main'}`);
59
- if (d.stack?.name) {
60
- lines.push(`Stack: ${d.stack.name}${d.stack.version ? ` ${d.stack.version}` : ''}`);
61
- }
62
- lines.push(`DB needed: ${d.database?.needed ? 'yes' : 'no'}`);
63
- }
64
-
65
- if (d.services_manifest?.entries?.length) {
66
- lines.push('');
67
- lines.push(`Multi-service manifest found (${d.services_manifest.entries.length} services):`);
68
- for (const e of d.services_manifest.entries) {
69
- lines.push(` • ${e.name} [${e.type}]${e.provider ? ` provider=${e.provider}` : ''}${e.dockerfile ? ` dockerfile=${e.dockerfile}` : ''}`);
70
- }
71
- lines.push('');
72
- lines.push('Tip: this project will be deployed via dailey_deploy_multi.');
73
- }
74
-
75
- if (d.estimates && (d.estimates.pull_time_seconds != null || d.estimates.deploy_time_seconds != null)) {
76
- const parts: string[] = [];
77
- if (d.estimates.pull_time_seconds != null) parts.push(`pull ~${d.estimates.pull_time_seconds}s`);
78
- if (d.estimates.deploy_time_seconds != null) parts.push(`deploy ~${d.estimates.deploy_time_seconds}s`);
79
- lines.push('');
80
- lines.push(`Estimates: ${parts.join(', ')}`);
81
- }
82
-
83
- if (d.recommendations?.length) {
84
- lines.push('');
85
- lines.push('Recommendations:');
86
- for (const r of d.recommendations) lines.push(` • ${r}`);
87
- }
88
-
89
- if (d.issues?.length) {
90
- lines.push('');
91
- lines.push('❌ Blocking issues:');
92
- for (const issue of d.issues) lines.push(` ✗ ${issue}`);
93
- } else {
94
- lines.push('');
95
- const isMulti = (d.services_manifest?.entries?.length || 0) > 0;
96
- if (isMulti) {
97
- lines.push('✓ Ready to deploy — use dailey_deploy_bundle (one call, atomic) for this repo.');
98
- } else if (d._isDockerImage) {
99
- lines.push('✓ Ready to deploy — use dailey_run_image for this Docker image.');
100
- } else {
101
- lines.push('✓ Ready to deploy — use dailey_deploy_bundle (one call: create + env + deploy).');
102
- }
103
- }
104
-
105
- return textResult(lines.join('\n'));
106
- },
107
- );
108
- }
package/src/tools/auth.ts DELETED
@@ -1,177 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import { apiRequest, formatError, textResult, jsonResult, getActiveAccount } from '../api.js';
4
-
5
- interface ManagedAccount {
6
- managed_customer_id: string;
7
- slug: string;
8
- name: string;
9
- }
10
-
11
- interface AuthEnableResponse {
12
- ok: boolean;
13
- project_id: string;
14
- auth_enabled: boolean;
15
- created: boolean;
16
- app_slug: string;
17
- client_id: string;
18
- client_secret?: string;
19
- enrolled: boolean;
20
- x_client_id: string;
21
- origin: string;
22
- extra_origins: string[];
23
- core_base_url: string;
24
- note?: string;
25
- docs_url: string;
26
- }
27
-
28
- interface UserInfo {
29
- id: string;
30
- name: string;
31
- email: string;
32
- plan?: string;
33
- created_at?: string;
34
- }
35
-
36
- const AUTH_REQUIRED_ERROR = {
37
- error_code: 'DAILEY_AUTH_REQUIRED',
38
- message: 'Not authenticated',
39
- remediation: 'Run `dailey auth setup` in your terminal',
40
- help_url: 'https://docs.dailey.cloud/auth',
41
- };
42
-
43
- export function registerAuthTools(server: McpServer) {
44
- server.tool(
45
- 'dailey_whoami',
46
- 'Show current user info (name, email, plan)',
47
- {},
48
- async () => {
49
- const res = await apiRequest<UserInfo>('GET', '/customers/me');
50
- if (!res.ok) {
51
- if (res.status === 401 || res.status === 403) {
52
- return jsonResult(AUTH_REQUIRED_ERROR);
53
- }
54
- return textResult(formatError(res));
55
- }
56
-
57
- const u = res.data;
58
- const lines = [
59
- `User Info`,
60
- `─────────────────────`,
61
- `ID: ${u.id}`,
62
- `Name: ${u.name}`,
63
- `Email: ${u.email}`,
64
- ];
65
- if (u.plan) lines.push(`Plan: ${u.plan}`);
66
- if (u.created_at) lines.push(`Created: ${u.created_at}`);
67
- return textResult(lines.join('\n'));
68
- },
69
- );
70
-
71
- server.tool(
72
- 'dailey_auth_status',
73
- 'Check authentication status — returns whether the MCP server is authenticated and the account details if so',
74
- {},
75
- async () => {
76
- const res = await apiRequest<UserInfo>('GET', '/customers/me');
77
-
78
- if (!res.ok) {
79
- if (res.status === 401 || res.status === 403) {
80
- return jsonResult({
81
- authenticated: false,
82
- source: null,
83
- recommended_action: 'Run `dailey auth setup` in your terminal',
84
- });
85
- }
86
- // Non-auth error — surface it but don't claim unauthenticated
87
- return jsonResult({
88
- authenticated: false,
89
- source: null,
90
- recommended_action: `API error (${res.status}) — run \`dailey auth setup\` if your token is missing or expired`,
91
- });
92
- }
93
-
94
- const u = res.data;
95
-
96
- // Infer the token source from the environment the MCP server was started with.
97
- // DAILEY_API_TOKEN wins; email+password means a refreshed session JWT; otherwise
98
- // it must be a dk_ API key set some other way.
99
- let source: 'api_key' | 'env_token' | 'session' = 'session';
100
- const envToken = process.env.DAILEY_API_TOKEN || '';
101
- if (envToken.startsWith('dk_')) {
102
- source = 'api_key';
103
- } else if (envToken) {
104
- source = 'env_token';
105
- } else if (process.env.DAILEY_EMAIL) {
106
- source = 'session';
107
- }
108
-
109
- // Manager / managed-accounts: report whether this user manages any other
110
- // accounts (the fleet) and which one — if any — is the active context for
111
- // this session. A non-empty fleet means they can `dailey_use_account` to
112
- // operate inside one of these accounts. Best-effort: a failure here must
113
- // not break auth-status, so we swallow errors and report manager: null.
114
- let fleet: ManagedAccount[] = [];
115
- try {
116
- const mres = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
117
- if (mres.ok && Array.isArray(mres.data)) fleet = mres.data;
118
- } catch {
119
- // ignore — leave fleet empty
120
- }
121
- const active = getActiveAccount() ?? null;
122
-
123
- return jsonResult({
124
- authenticated: true,
125
- source,
126
- account: u.name,
127
- email: u.email,
128
- recommended_action: null,
129
- manager: {
130
- is_manager: fleet.length > 0,
131
- managed_accounts: fleet,
132
- active_account: active,
133
- operating_as: active ? 'managed_account' : 'self',
134
- },
135
- });
136
- },
137
- );
138
-
139
- server.tool(
140
- 'dailey_auth_enable',
141
- 'Enable Dailey Core authentication for a project in one call. Registers the app in Core, installs it in your Core tenant, and enrolls you — wrapping Core self-serve provisioning. The origin is derived from the project (https://<slug>.dailey.cloud, plus any *.dailey.cloud custom domains). After enabling, the app calls Core /auth/* with header X-Client-Id: <app_slug>; the JWT tenant claim is `tenant`. client_secret is returned ONLY the first time. enforce_enrolled_factors defaults to false so password login still works alongside passkeys.',
142
- {
143
- project_id: z.string().describe('The project ID'),
144
- enforce_enrolled_factors: z
145
- .boolean()
146
- .optional()
147
- .describe('Require enrolled factors (e.g. passkey) at login. Defaults to false so password login still works.'),
148
- },
149
- async ({ project_id, enforce_enrolled_factors }) => {
150
- const res = await apiRequest<AuthEnableResponse>('POST', `/projects/${project_id}/auth/enable`, {
151
- enforce_enrolled_factors: enforce_enrolled_factors === true,
152
- });
153
- if (!res.ok) return textResult(formatError(res));
154
- const d = res.data;
155
- const lines = [
156
- `Dailey Core authentication enabled for project ${d.project_id}.`,
157
- '',
158
- `App / X-Client-Id: ${d.app_slug}`,
159
- `Origin: ${d.origin}`,
160
- ...(d.extra_origins && d.extra_origins.length ? [`Also allowed: ${d.extra_origins.join(', ')}`] : []),
161
- `Core base URL: ${d.core_base_url}`,
162
- `Enrolled: ${d.enrolled ? 'yes' : 'no'}`,
163
- ];
164
- if (d.client_secret) {
165
- lines.push('', `⚠ Save this client_secret — it is shown only once:`, ` ${d.client_secret}`);
166
- } else if (d.note) {
167
- lines.push('', d.note);
168
- }
169
- lines.push(
170
- '',
171
- `Call Core /auth/* with header X-Client-Id: ${d.x_client_id}. The token tenant claim is \`tenant\`.`,
172
- `Docs: ${d.docs_url}`,
173
- );
174
- return textResult(lines.join('\n'));
175
- },
176
- );
177
- }
@@ -1,84 +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 Backup {
6
- key: string;
7
- timestamp?: string;
8
- size_mb?: number;
9
- last_modified?: string;
10
- }
11
-
12
- interface BackupsResponse {
13
- backups?: Backup[];
14
- total?: number;
15
- error?: string;
16
- }
17
-
18
- export function registerBackupTools(server: McpServer) {
19
- server.tool(
20
- 'dailey_backups',
21
- 'List, create, or restore backups for a project. Use before risky changes (schema migrations, major redeploys).',
22
- {
23
- project_id: z.string().describe('The project ID'),
24
- action: z.enum(['list', 'create', 'restore', 'download']).describe('list | create | restore | download'),
25
- backup_key: z.string().optional().describe('Backup key (required for restore/download)'),
26
- },
27
- async ({ project_id, action, backup_key }) => {
28
- if (action === 'list') {
29
- const res = await apiRequest<BackupsResponse>('GET', `/projects/${project_id}/backups`);
30
- if (!res.ok) return textResult(formatError(res));
31
-
32
- const backups = res.data.backups || [];
33
- if (backups.length === 0) {
34
- const err = res.data.error ? `\n\nNote: ${res.data.error}` : '';
35
- return textResult(`No backups found for this project.${err}`);
36
- }
37
-
38
- const lines = [
39
- `Backups (${backups.length})`,
40
- `${'Timestamp'.padEnd(24)} ${'Size'.padEnd(10)} Key`,
41
- '─'.repeat(90),
42
- ];
43
- for (const b of backups) {
44
- lines.push(`${(b.timestamp || '-').padEnd(24)} ${String((b.size_mb ?? 0) + ' MB').padEnd(10)} ${b.key}`);
45
- }
46
- lines.push('');
47
- lines.push('Restore with: dailey_backups action=restore backup_key=<key>');
48
- return textResult(lines.join('\n'));
49
- }
50
-
51
- if (action === 'create') {
52
- const res = await apiRequest<{ triggered?: boolean; message?: string }>(
53
- 'POST',
54
- `/projects/${project_id}/backups`,
55
- );
56
- if (!res.ok) return textResult(formatError(res));
57
- return textResult(res.data.message || 'Backup triggered.');
58
- }
59
-
60
- if (action === 'restore') {
61
- if (!backup_key) return textResult('Error: backup_key is required for restore.');
62
- const res = await apiRequest<{ restored?: boolean; message?: string }>(
63
- 'POST',
64
- `/projects/${project_id}/backups/restore`,
65
- { backup_key },
66
- );
67
- if (!res.ok) return textResult(formatError(res));
68
- return textResult(res.data.message || `Restored from ${backup_key}.`);
69
- }
70
-
71
- if (action === 'download') {
72
- if (!backup_key) return textResult('Error: backup_key is required for download.');
73
- const res = await apiRequest<{ url?: string; expires_in?: number }>(
74
- 'GET',
75
- `/projects/${project_id}/backups/download?key=${encodeURIComponent(backup_key)}`,
76
- );
77
- if (!res.ok) return textResult(formatError(res));
78
- return textResult(`Download URL (expires in ${res.data.expires_in || 3600}s):\n${res.data.url}`);
79
- }
80
-
81
- return textResult('Invalid action. Use list, create, restore, or download.');
82
- },
83
- );
84
- }
@@ -1,34 +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
- export function registerBillingTools(server: McpServer) {
6
- server.tool(
7
- 'dailey_billing',
8
- 'Get current billing info and resource usage',
9
- {},
10
- async () => {
11
- const res = await apiRequest<Record<string, unknown>>('GET', '/billing');
12
- if (!res.ok) return textResult(formatError(res));
13
- return jsonResult(res.data);
14
- },
15
- );
16
-
17
- server.tool(
18
- 'dailey_billing_estimate',
19
- 'Estimate cost impact of scaling a project to N additional replicas. Only the "scale" action is supported today — the action argument is reserved for future cost estimators (e.g., adding storage, adding a DB) and will be removed when we have one canonical estimator.',
20
- {
21
- replicas: z.number().describe('Total additional replicas to add across all projects when estimating the scale delta.'),
22
- action: z.enum(['scale']).optional().describe('Action to estimate. Only "scale" is implemented; omit for the default.'),
23
- },
24
- async ({ replicas, action }) => {
25
- const effectiveAction = action || 'scale';
26
- const res = await apiRequest<Record<string, unknown>>(
27
- 'GET',
28
- `/billing/estimate?action=${encodeURIComponent(effectiveAction)}&replicas=${replicas}`,
29
- );
30
- if (!res.ok) return textResult(formatError(res));
31
- return jsonResult(res.data);
32
- },
33
- );
34
- }
@@ -1,65 +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 Build {
6
- id: string;
7
- status?: string;
8
- started_at?: string;
9
- finished_at?: string;
10
- commit_sha?: string;
11
- }
12
-
13
- interface BuildRow {
14
- id: string;
15
- status: string;
16
- log?: string;
17
- started_at?: string;
18
- finished_at?: string;
19
- commit_sha?: string;
20
- }
21
-
22
- export function registerBuildLogsTools(server: McpServer) {
23
- server.tool(
24
- 'dailey_build_logs',
25
- 'Fetch the full build log for a specific build (or the most recent build if build_id is omitted). Use this after a deploy fails to see the actual compiler/Docker output.',
26
- {
27
- project_id: z.string().describe('The project ID'),
28
- build_id: z.string().optional().describe('Specific build ID (defaults to the most recent build for the project)'),
29
- tail: z.number().int().min(1).max(5000).optional().describe('Return only the last N lines (default: full log)'),
30
- },
31
- async ({ project_id, build_id, tail }) => {
32
- let targetBuildId = build_id;
33
-
34
- if (!targetBuildId) {
35
- const historyRes = await apiRequest<{ builds: Build[] }>('GET', `/projects/${project_id}/deploys`);
36
- if (!historyRes.ok) return textResult(formatError(historyRes));
37
- const builds = historyRes.data.builds || [];
38
- if (builds.length === 0) {
39
- return textResult('No builds found for this project.');
40
- }
41
- targetBuildId = builds[0].id;
42
- }
43
-
44
- const buildRes = await apiRequest<BuildRow>('GET', `/builds/${targetBuildId}`);
45
- if (!buildRes.ok) return textResult(formatError(buildRes));
46
-
47
- const build = buildRes.data;
48
- const log = build.log || '';
49
- const allLines = log.split('\n');
50
- const shown = tail ? allLines.slice(-tail) : allLines;
51
-
52
- const header = [
53
- `Build ${build.id}`,
54
- `Status: ${build.status || 'unknown'}`,
55
- `Commit: ${build.commit_sha || '-'}`,
56
- `Started: ${build.started_at || '-'}`,
57
- `Finished: ${build.finished_at || '-'}`,
58
- `Lines: ${allLines.length}${tail ? ` (showing last ${Math.min(tail, allLines.length)})` : ''}`,
59
- '─'.repeat(60),
60
- ];
61
-
62
- return textResult([...header, ...shown].join('\n'));
63
- },
64
- );
65
- }
@@ -1,129 +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
- * dailey_deploy_bundle — atomic create + configure + deploy in one call.
7
- *
8
- * Replaces what used to be 4–30 separate MCP calls (create_project +
9
- * set_env_var × N + service_links × M + deploy + ...). Each of those
10
- * required its own Claude Code permission prompt, which was Scott's
11
- * friction #8. One call, one prompt, whole-bundle rollback on failure.
12
- *
13
- * EOS #53.
14
- */
15
-
16
- export function registerBundleTools(server: McpServer) {
17
- server.tool(
18
- 'dailey_deploy_bundle',
19
- [
20
- 'Create a project, inject env vars, link to other projects, bind a domain, and trigger the deploy — all in one atomic call.',
21
- 'If any step fails, the project is rolled back (deleted) so you do not end up with a partial "failed" project.',
22
- 'Prefer this over dailey_create_project + dailey_env_vars + dailey_service_links + dailey_deploy for any fresh deploy — it burns one permission prompt instead of many, and guarantees all-or-nothing.',
23
- ].join(' '),
24
- {
25
- name: z.string().describe('Project name (also used as the requested slug).'),
26
- repo_url: z.string().describe('GitHub repo URL (https://github.com/owner/repo) or Docker image (e.g., nginx:alpine).'),
27
- branch: z.string().optional().describe('Git branch to deploy. Defaults to main. Ignored for Docker images.'),
28
- env_vars: z
29
- .record(z.string())
30
- .optional()
31
- .describe('Environment variables as a flat object, e.g. { DATABASE_URL: "postgresql://...", REDIS_URL: "..." }.'),
32
- database: z
33
- .union([z.enum(['mysql', 'postgres']), z.boolean()])
34
- .optional()
35
- .describe('Provision a managed DB: "mysql" | "postgres" | true (= mysql) | false. For Prisma/pg apps, use "postgres".'),
36
- needs_auth: z.boolean().optional().describe('Provision Dailey Auth (SSO) for this project.'),
37
- needs_storage: z.boolean().optional().describe('Provision object storage (R2) for this project.'),
38
- links: z
39
- .array(
40
- z.object({
41
- target_project_id: z.string().describe('ID of the project to link to (e.g., a Postgres project).'),
42
- env_key: z.string().optional().describe('Env key to inject on the source project. Defaults to an uppercased version of the target name.'),
43
- }),
44
- )
45
- .optional()
46
- .describe('Service links to inject into the new project. For DB targets, the injected env var is a real connection string (postgresql://, mysql://, etc.).'),
47
- domain: z.string().optional().describe('Optional custom domain to bind (e.g., my-app.example.com). Must pass DNS-check after deploy.'),
48
- deploy: z.boolean().optional().describe('Trigger a deploy after configuration. Defaults to true.'),
49
- },
50
- async (input) => {
51
- // Translate to server shape: the bundle endpoint takes needs_database
52
- // + database_type separately, same shape as POST /projects.
53
- let needs_database = false;
54
- let database_type: 'mysql' | 'postgres' | undefined;
55
- if (input.database === true) { needs_database = true; database_type = 'mysql'; }
56
- else if (input.database === 'mysql' || input.database === 'postgres') {
57
- needs_database = true;
58
- database_type = input.database;
59
- }
60
-
61
- const res = await apiRequest<any>('POST', '/projects/bundle', {
62
- name: input.name,
63
- repo_url: input.repo_url,
64
- branch: input.branch,
65
- env_vars: input.env_vars,
66
- needs_database,
67
- database_type,
68
- needs_auth: input.needs_auth,
69
- needs_storage: input.needs_storage,
70
- links: input.links,
71
- domain: input.domain,
72
- deploy: input.deploy,
73
- });
74
-
75
- if (!res.ok) {
76
- // Bundle endpoint returns structured failure with a rolled_back flag
77
- // and a steps array showing which stage died.
78
- const body: any = res.data;
79
- const lines: string[] = [];
80
- lines.push(`Bundle failed: ${body?.error || formatError(res)}`);
81
- if (body?.rolled_back) {
82
- lines.push('Rolled back cleanly — no partial project left behind.');
83
- } else {
84
- lines.push('⚠ NOT rolled back — a partial project may exist. Inspect dailey_list_projects.');
85
- }
86
- if (Array.isArray(body?.steps)) {
87
- lines.push('');
88
- lines.push('Steps:');
89
- for (const s of body.steps) {
90
- const mark = s.status === 'ok' ? '✓' : '✗';
91
- lines.push(` ${mark} ${s.step} (${s.ms}ms)${s.status === 'failed' && s.detail ? ` — ${JSON.stringify(s.detail)}` : ''}`);
92
- }
93
- }
94
- return textResult(lines.join('\n'));
95
- }
96
-
97
- const data: any = res.data;
98
- const project = data.project || {};
99
- const lines: string[] = [];
100
- lines.push(`✓ Bundled deploy for ${project.name || input.name}`);
101
- lines.push('');
102
- lines.push(`Project ID: ${project.id}`);
103
- lines.push(`Slug: ${project.slug}`);
104
- lines.push(`URL: ${project.url || `https://${project.slug}.dailey.cloud`}`);
105
- if (project.database) lines.push(`Database: ${project.database.database} (${project.database.type || database_type || 'mysql'})`);
106
- if (Array.isArray(data.links) && data.links.length > 0) {
107
- lines.push('');
108
- lines.push('Service links:');
109
- for (const l of data.links) {
110
- lines.push(` ${l.env_key} → ${l.target_slug} (${l.kind})`);
111
- }
112
- }
113
- if (data.domain) lines.push(`Domain: ${data.domain.hostname || input.domain}`);
114
- if (data.build_id) {
115
- lines.push('');
116
- lines.push(`Build ID: ${data.build_id}`);
117
- lines.push(`Track progress: dailey_deploy_status with project_id=${project.id}`);
118
- }
119
- if (Array.isArray(data.steps)) {
120
- const ok = data.steps.filter((s: any) => s.status === 'ok').length;
121
- const total = data.steps.length;
122
- const totalMs = data.steps.reduce((sum: number, s: any) => sum + (s.ms || 0), 0);
123
- lines.push('');
124
- lines.push(`(${ok}/${total} steps succeeded in ${totalMs}ms)`);
125
- }
126
- return textResult(lines.join('\n'));
127
- },
128
- );
129
- }
package/src/tools/cli.ts DELETED
@@ -1,76 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import { textResult } from '../api.js';
4
-
5
- function shellQuote(s: string): string {
6
- if (/^[A-Za-z0-9_.\-\/]+$/.test(s)) return s;
7
- return `'${s.replace(/'/g, `'\\''`)}'`;
8
- }
9
-
10
- export function registerCliTools(server: McpServer): void {
11
- server.tool(
12
- 'dailey_cli_suggest_import',
13
- "DEPRECATED — prefer `dailey_db_import` which executes end-to-end without dropping to the host shell. This tool remains for environments where the MCP client can't upload inline data (payload > ~256 KB) and the agent would rather suggest a local `dailey db import` command the user runs themselves. Pure string construction, no I/O. Defaults to --dry-run.",
14
- {
15
- project: z.string().describe('Project slug or id (e.g. "wordgym")'),
16
- table: z.string().describe('Target table name'),
17
- file: z
18
- .string()
19
- .describe(
20
- 'Local file path to JSON array or CSV file (must exist on the user machine when the command runs)',
21
- ),
22
- mode: z.enum(['insert', 'upsert']).describe('Write mode'),
23
- conflict_keys: z
24
- .array(z.string())
25
- .optional()
26
- .describe('Conflict keys; required if mode=upsert'),
27
- dry_run: z
28
- .boolean()
29
- .optional()
30
- .default(true)
31
- .describe(
32
- 'Default true — constructs a command with --dry-run. Set false to construct a --confirm variant (the caller supplies the token from a prior dry-run output).',
33
- ),
34
- },
35
- async ({ project, table, file, mode, conflict_keys, dry_run }) => {
36
- if (mode === 'upsert' && (!conflict_keys || conflict_keys.length === 0)) {
37
- return textResult('error: mode=upsert requires conflict_keys');
38
- }
39
-
40
- const parts = [
41
- 'dailey db import',
42
- shellQuote(project),
43
- shellQuote(file),
44
- `--table ${shellQuote(table)}`,
45
- `--mode ${mode}`,
46
- ];
47
- if (mode === 'upsert' && conflict_keys) {
48
- for (const k of conflict_keys) parts.push(`--key ${shellQuote(k)}`);
49
- }
50
- if (dry_run) parts.push('--dry-run');
51
- parts.push('--json');
52
-
53
- const command = parts.join(' ');
54
- const explanation =
55
- mode === 'upsert'
56
- ? `Upserts rows from ${file} into ${table}; conflicts resolve on ${(conflict_keys ?? []).join(', ')}. ${dry_run ? 'Dry-run only — server returns a confirmation token for a follow-up commit.' : 'Commit phase — expects --confirm <token> from a prior dry-run.'}`
57
- : `Inserts rows from ${file} into ${table}. ${dry_run ? 'Dry-run only — server returns a confirmation token for a follow-up commit.' : 'Commit phase — expects --confirm <token> from a prior dry-run.'}`;
58
-
59
- const preflight = [
60
- { check: 'file_exists', path: file },
61
- { check: 'schema_compatible', table },
62
- ];
63
-
64
- const output = {
65
- command,
66
- explanation,
67
- preflight,
68
- expected_output: 'json',
69
- on_dry_run_success:
70
- 're-run with --confirm <token_from_dry_run_output> (remove --dry-run)',
71
- };
72
-
73
- return textResult(JSON.stringify(output, null, 2));
74
- },
75
- );
76
- }