@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
package/src/index.ts DELETED
@@ -1,247 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
- import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
-
6
- import { z } from 'zod';
7
- import { hasCredentials, getActiveAccount, setActiveAccount } from './api.js';
8
- import { OWN_VERSION, checkForNewerVersion, outdatedNotice } from './version.js';
9
- import { registerAuthTools } from './tools/auth.js';
10
- import { registerAccountTools } from './tools/accounts.js';
11
- import { registerProjectTools } from './tools/projects.js';
12
- import { registerDeployTools } from './tools/deploy.js';
13
- import { registerDeployStatusTools } from './tools/deploy-status.js';
14
- import { registerBuildLogsTools } from './tools/build-logs.js';
15
- import { registerScaleTools } from './tools/scale.js';
16
- import { registerEnvTools } from './tools/env.js';
17
- import { registerDomainTools } from './tools/domains.js';
18
- import { registerDbTools } from './tools/db.js';
19
- import { registerMigrateTools } from './tools/db-migrate.js';
20
- import { registerExecRunTools } from './tools/exec-run.js';
21
- import { registerProjectTransferTools } from './tools/project-transfer.js';
22
- import { registerAdminTools } from './tools/admin.js';
23
- import { registerUsageTools } from './tools/usage.js';
24
- import { registerBillingTools } from './tools/billing.js';
25
- import { registerPlatformTools } from './tools/platform.js';
26
- import { registerStorageTools } from './tools/storage.js';
27
- import { registerAiTools } from './tools/ai.js';
28
- import { registerEmailTools } from './tools/email.js';
29
- import { registerCreditTools } from './tools/credits.js';
30
- import { registerAddonTools } from './tools/addons.js';
31
- import { registerDaileyImagesTools } from './tools/dailey-images.js';
32
- import { registerImageTools } from './tools/images.js';
33
- import { registerProcessTools } from './tools/processes.js';
34
- import { registerLifecycleTools } from './tools/lifecycle.js';
35
- import { registerBackupTools } from './tools/backups.js';
36
- import { registerWordPressMigrateTools } from './tools/wordpress-migrate.js';
37
- import { registerWordPressImportTools } from './tools/wordpress-import.js';
38
- import { registerWordPressSnapshotTools } from './tools/wordpress-snapshot.js';
39
- import { registerWordPressLiveEditTools } from './tools/wordpress-live-edit.js';
40
- import { registerWordPressTargetingTools } from './tools/wordpress-targeting.js';
41
- import { registerEnvironmentTools } from './tools/environments.js';
42
- import { registerResourceConfigTools } from './tools/resource-config.js';
43
- import { registerLinkTools } from './tools/links.js';
44
- import { registerCredentialRevealTools } from './tools/credentials-reveal.js';
45
- import { registerAnalyzeTools } from './tools/analyze.js';
46
- import { registerCliTools } from './tools/cli.js';
47
- import { registerBundleTools } from './tools/bundle.js';
48
- import { registerDiagnoseTools } from './tools/diagnose.js';
49
- import { registerSupportTools } from './tools/support.js';
50
-
51
- function writeStream(stream: NodeJS.WriteStream, text: string): Promise<void> {
52
- return new Promise((resolve) => {
53
- stream.write(text, () => resolve());
54
- });
55
- }
56
-
57
- async function preflight(): Promise<void> {
58
- const isInteractive = Boolean(process.stdin.isTTY);
59
-
60
- if (!hasCredentials()) {
61
- const msg =
62
- 'Missing credentials. Set DAILEY_API_TOKEN, or DAILEY_EMAIL + DAILEY_PASSWORD.';
63
-
64
- if (isInteractive) {
65
- await writeStream(
66
- process.stderr,
67
- '\n' +
68
- 'dailey-mcp: ' + msg + '\n\n' +
69
- 'This is an MCP stdio server — it is meant to be spawned by an MCP client\n' +
70
- '(Claude Code, Cursor, etc.) which will send JSON-RPC messages on stdin.\n' +
71
- 'Running it directly in a shell is not how you use it.\n\n' +
72
- 'Add it to your client config like this:\n' +
73
- ' {\n' +
74
- ' "mcpServers": {\n' +
75
- ' "dailey-os": {\n' +
76
- ' "command": "npx",\n' +
77
- ' "args": ["-y", "@daileyos/mcp-server"],\n' +
78
- ' "env": { "DAILEY_API_TOKEN": "..." }\n' +
79
- ' }\n' +
80
- ' }\n' +
81
- ' }\n\n' +
82
- 'Docs: https://docs.dailey.cloud/mcp/getting-started\n\n'
83
- );
84
- } else {
85
- // Best-effort: some MCP clients surface unsolicited log notifications
86
- // that arrive before the initialize handshake. Emit a structured JSON-RPC
87
- // message so the client has something to render other than "process exited".
88
- const note = {
89
- jsonrpc: '2.0',
90
- method: 'notifications/message',
91
- params: {
92
- level: 'error',
93
- logger: 'dailey-mcp',
94
- data: msg + ' See https://docs.dailey.cloud/mcp/getting-started',
95
- },
96
- };
97
- await writeStream(process.stdout, JSON.stringify(note) + '\n');
98
- await writeStream(process.stderr, 'dailey-mcp: ' + msg + '\n');
99
- }
100
- process.exit(1);
101
- }
102
-
103
- if (isInteractive) {
104
- await writeStream(
105
- process.stderr,
106
- '\n' +
107
- 'dailey-mcp: MCP stdio server running.\n' +
108
- 'This server speaks JSON-RPC 2.0 on stdin/stdout — it is driven by an MCP\n' +
109
- 'client (Claude Code, Cursor, etc.), not typed into directly. If you were\n' +
110
- 'trying to update it, you do not need to — `npx @daileyos/mcp-server` in\n' +
111
- 'your client config pulls latest at each session start.\n' +
112
- 'Press Ctrl+C to exit.\n\n'
113
- );
114
- }
115
- }
116
-
117
- await preflight();
118
-
119
- // Staleness self-check (2026-07-13 incident: sessions silently ran a months-old
120
- // MCP and the agent concluded platform features didn't exist). Fail-open + hard
121
- // timeout; when outdated, the notice rides the server instructions so the AGENT
122
- // itself tells the user to update instead of silently missing tools.
123
- const newerVersion = await checkForNewerVersion();
124
- if (newerVersion) {
125
- process.stderr.write(`dailey-mcp: v${OWN_VERSION} is outdated (latest v${newerVersion})\n`);
126
- }
127
-
128
- const server = new McpServer(
129
- {
130
- name: 'dailey-os',
131
- version: OWN_VERSION,
132
- },
133
- newerVersion ? { instructions: outdatedNotice(newerVersion) } : undefined,
134
- );
135
-
136
- // ─── Account-context hardening (2026-07-13, Muenda's "which account am I in?") ───
137
- // Two invariants, applied uniformly to ALL tools via this registration wrapper:
138
- // 1. Every tool accepts an optional `account` param — a STATELESS, per-call
139
- // scope to a managed account (set → run → restore). Agents no longer have
140
- // to rely on dailey_use_account session state being what they remember.
141
- // 2. Every tool result is prefixed with `[account: <effective>]` so the model
142
- // (and the human reading the transcript) always sees which account the
143
- // call actually ran against. Wrong-account work becomes visible instantly.
144
- // Tools that declare their own `account` param (the WP tools) keep their schema;
145
- // the wrapper still enforces the per-call set/restore around them.
146
- {
147
- const originalTool = server.tool.bind(server);
148
- (server as any).tool = (name: string, description: string, schema: Record<string, unknown>, handler: (...a: any[]) => any) => {
149
- const augmented = 'account' in schema
150
- ? schema
151
- : {
152
- ...schema,
153
- account: z.string().optional().describe(
154
- 'Managed-account slug to run THIS call against (per-call scope; overrides the dailey_use_account session state for this call only). Omit to use the current session account.',
155
- ),
156
- };
157
- return originalTool(name, description, augmented as any, async (args: any, extra: any) => {
158
- const requested: string | undefined =
159
- typeof args?.account === 'string' && args.account.trim() ? args.account.trim() : undefined;
160
- const prev = getActiveAccount();
161
- if (requested) setActiveAccount(requested);
162
- try {
163
- const result = await handler(args, extra);
164
- const effective = requested ?? getActiveAccount() ?? 'self (your own account)';
165
- if (result?.content?.length && result.content[0]?.type === 'text') {
166
- result.content[0].text = `[account: ${effective}]\n${result.content[0].text}`;
167
- }
168
- return result;
169
- } finally {
170
- // Restore ONLY when this call temporarily overrode the session scope —
171
- // dailey_use_account itself must keep its session-setting behavior.
172
- if (requested) setActiveAccount(prev);
173
- }
174
- });
175
- };
176
- }
177
-
178
- // Core + identity
179
- registerAuthTools(server);
180
- registerAccountTools(server);
181
- registerPlatformTools(server);
182
- registerUsageTools(server);
183
- registerBillingTools(server);
184
- // À-la-carte billing surfaces — prepaid credits + capacity add-ons.
185
- registerCreditTools(server);
186
- registerAddonTools(server);
187
-
188
- // Projects + deploys
189
- registerProjectTools(server);
190
- registerAnalyzeTools(server);
191
- registerDeployTools(server);
192
- registerDeployStatusTools(server);
193
- registerBuildLogsTools(server);
194
- registerImageTools(server);
195
-
196
- // Lifecycle + scaling
197
- registerScaleTools(server);
198
- registerLifecycleTools(server);
199
- registerResourceConfigTools(server);
200
- registerProcessTools(server);
201
-
202
- // Config
203
- registerEnvTools(server);
204
- registerDomainTools(server);
205
- registerLinkTools(server);
206
- registerCredentialRevealTools(server);
207
-
208
- // Data
209
- registerDbTools(server);
210
- registerMigrateTools(server);
211
- registerStorageTools(server);
212
- registerAiTools(server);
213
- registerEmailTools(server);
214
- registerDaileyImagesTools(server);
215
- registerBackupTools(server);
216
- registerWordPressMigrateTools(server);
217
- registerWordPressImportTools(server);
218
- registerWordPressSnapshotTools(server);
219
- // WordPress live-edit tools (files/media/wp-cli) wrapping customer-api#18's
220
- // tenant-scoped live-edit routes. Mutating ops are two-phase (preview → confirm_token).
221
- registerWordPressLiveEditTools(server);
222
- // Scenario 1 create + WP targeting spine (list/target), paired with the
223
- // customer-api targeting-spine deploy.
224
- registerWordPressTargetingTools(server);
225
- registerEnvironmentTools(server);
226
-
227
- // Runtime operations — exec into a pod, run one-off jobs
228
- registerExecRunTools(server);
229
-
230
- // Admin-only — customer onboarding, project transfer
231
- registerAdminTools(server);
232
- registerProjectTransferTools(server);
233
-
234
- // CLI assist
235
- registerCliTools(server);
236
-
237
- // Atomic deploy bundle
238
- registerBundleTools(server);
239
-
240
- // One-stop health check — first tool to reach for when something is broken
241
- registerDiagnoseTools(server);
242
-
243
- // Support — escalate to Dailey OS team
244
- registerSupportTools(server);
245
-
246
- const transport = new StdioServerTransport();
247
- await server.connect(transport);
@@ -1,111 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { z } from 'zod';
3
- import {
4
- apiRequest,
5
- formatError,
6
- jsonResult,
7
- getActiveAccount,
8
- setActiveAccount,
9
- } from '../api.js';
10
-
11
- interface ManagedAccount {
12
- managed_customer_id: string;
13
- slug: string;
14
- name: string;
15
- }
16
-
17
- const AUTH_REQUIRED_ERROR = {
18
- error_code: 'DAILEY_AUTH_REQUIRED',
19
- message: 'Not authenticated',
20
- remediation: 'Run `dailey auth setup` in your terminal',
21
- help_url: 'https://docs.dailey.cloud/auth',
22
- };
23
-
24
- export function registerAccountTools(server: McpServer) {
25
- server.tool(
26
- 'dailey_accounts',
27
- 'List the managed accounts (the "fleet") this user manages — other Dailey accounts that have granted you a consent-based access grant. Returns each account\'s managed_customer_id, slug, and name, plus which account is currently active for this session. Empty fleet means you manage no other accounts. Use `dailey_use_account` to switch into one of these accounts; after switching, all other dailey tools operate inside that account until you clear or switch.',
28
- {},
29
- async () => {
30
- const res = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
31
- if (!res.ok) {
32
- if (res.status === 401 || res.status === 403) {
33
- return jsonResult(AUTH_REQUIRED_ERROR);
34
- }
35
- return jsonResult({ error: formatError(res) });
36
- }
37
- const fleet = Array.isArray(res.data) ? res.data : [];
38
- return jsonResult({
39
- active_account: getActiveAccount() ?? null,
40
- operating_as: getActiveAccount() ? 'managed_account' : 'self',
41
- count: fleet.length,
42
- accounts: fleet,
43
- });
44
- },
45
- );
46
-
47
- server.tool(
48
- 'dailey_use_account',
49
- 'Switch the active managed-account context for this MCP session. Pass `account` (a slug or id from `dailey_accounts`) to operate INSIDE that managed account; after calling this, ALL other dailey tools act inside that managed account until you clear or switch. Pass `clear: true` to stop and operate as yourself again. The target account must be in your fleet (`dailey_accounts`) — an invalid account is rejected. This context is session-scoped: it persists for the life of this MCP server.',
50
- {
51
- account: z
52
- .string()
53
- .optional()
54
- .describe('The slug or id of a managed account to operate within (must be in your fleet from dailey_accounts)'),
55
- clear: z
56
- .boolean()
57
- .optional()
58
- .describe('If true, clear the active managed account and operate as yourself again'),
59
- },
60
- async ({ account, clear }) => {
61
- if (clear) {
62
- setActiveAccount(undefined);
63
- return jsonResult({
64
- ok: true,
65
- active_account: null,
66
- operating_as: 'self',
67
- message: 'Cleared managed-account context — now operating as yourself.',
68
- });
69
- }
70
-
71
- if (!account || !account.trim()) {
72
- return jsonResult({
73
- ok: false,
74
- message: 'Provide `account` (a slug or id from dailey_accounts) to switch into, or `clear: true` to operate as yourself.',
75
- });
76
- }
77
-
78
- const res = await apiRequest<ManagedAccount[]>('GET', '/customers/me/managed-accounts');
79
- if (!res.ok) {
80
- if (res.status === 401 || res.status === 403) {
81
- return jsonResult(AUTH_REQUIRED_ERROR);
82
- }
83
- return jsonResult({ ok: false, error: formatError(res) });
84
- }
85
- const fleet = Array.isArray(res.data) ? res.data : [];
86
- const target = account.trim();
87
- const match = fleet.find(
88
- (a) => a.slug === target || a.managed_customer_id === target,
89
- );
90
- if (!match) {
91
- return jsonResult({
92
- ok: false,
93
- message: `Account "${target}" is not in your managed-accounts fleet. Call dailey_accounts to list the accounts you manage.`,
94
- available: fleet.map((a) => ({ slug: a.slug, name: a.name })),
95
- });
96
- }
97
-
98
- // Use the slug as the header value when available (matches the dashboard/CLI
99
- // convention); the server accepts either slug or id.
100
- const activeValue = match.slug || match.managed_customer_id;
101
- setActiveAccount(activeValue);
102
- return jsonResult({
103
- ok: true,
104
- active_account: activeValue,
105
- operating_as: 'managed_account',
106
- account: match,
107
- message: `Now operating within "${match.name}" (${match.slug}). All subsequent dailey tool calls run inside this account until you clear or switch.`,
108
- });
109
- },
110
- );
111
- }
@@ -1,124 +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
- // À-la-carte capacity add-ons (pay-at-purchase Stripe subscriptions):
6
- // extra_vcpu, extra_ram, extra_db_storage, extra_object_storage,
7
- // db_replica, app_ha, email_pro (+ managed_ops / extra_core_users_*).
8
- // GET /billing/addons = active add-ons; GET /billing/addons/catalog = available
9
- // types + pricing. POST /billing/addons returns { checkout_url } (pay first) or,
10
- // when no Stripe price is configured, provisions immediately ({ addon, message }).
11
- interface ActiveAddon {
12
- id: string;
13
- addon_type: string;
14
- quantity: number;
15
- status: string;
16
- created_at?: string;
17
- unit_price?: number;
18
- unit_label?: string;
19
- monthly_cost?: number;
20
- }
21
- interface AddonsListResponse {
22
- addons: ActiveAddon[];
23
- total_monthly: number;
24
- }
25
- interface CatalogItem {
26
- type: string;
27
- name: string;
28
- unit_price: number;
29
- unit_label: string;
30
- description: string;
31
- }
32
- interface CatalogResponse {
33
- addons: CatalogItem[];
34
- }
35
- interface AddonPurchaseResponse {
36
- checkout_url?: string | null;
37
- session_id?: string;
38
- addon?: { id: string; addon_type: string; quantity: number; unit_price: number; monthly_cost: number };
39
- message?: string;
40
- note?: string;
41
- }
42
-
43
- export function registerAddonTools(server: McpServer) {
44
- server.tool(
45
- 'dailey_addons',
46
- 'List à-la-carte capacity add-ons: the account\'s ACTIVE add-ons (with monthly cost) plus the AVAILABLE catalog (extra_vcpu, extra_ram, extra_db_storage, extra_object_storage, db_replica, app_ha, email_pro, ...) and per-unit pricing. Purchase with dailey_addon_purchase; cancel with dailey_addon_cancel.',
47
- {},
48
- async () => {
49
- const [activeRes, catalogRes] = await Promise.all([
50
- apiRequest<AddonsListResponse>('GET', '/billing/addons'),
51
- apiRequest<CatalogResponse>('GET', '/billing/addons/catalog'),
52
- ]);
53
- if (!activeRes.ok) return textResult(formatError(activeRes));
54
-
55
- const lines: string[] = ['Active add-ons:'];
56
- const active = activeRes.data.addons || [];
57
- if (active.length === 0) {
58
- lines.push(' (none)');
59
- } else {
60
- for (const a of active) {
61
- lines.push(
62
- ` ${a.id} ${a.addon_type} x${a.quantity} $${a.monthly_cost ?? 0}/mo [${a.status}]`,
63
- );
64
- }
65
- lines.push(` Total: $${activeRes.data.total_monthly ?? 0}/mo`);
66
- }
67
-
68
- if (catalogRes.ok) {
69
- lines.push('');
70
- lines.push('Available add-ons (catalog):');
71
- for (const c of catalogRes.data.addons || []) {
72
- lines.push(` ${c.type} $${c.unit_price}/${c.unit_label} — ${c.description || c.name}`);
73
- }
74
- }
75
- lines.push('');
76
- lines.push('Purchase: dailey_addon_purchase (type[, quantity]) → returns a Stripe Checkout URL to pay.');
77
- return textResult(lines.join('\n'));
78
- },
79
- );
80
-
81
- server.tool(
82
- 'dailey_addon_purchase',
83
- 'Purchase an à-la-carte capacity add-on (extra_vcpu, extra_ram, extra_db_storage, extra_object_storage, db_replica, app_ha, email_pro, ...). PAY-AT-PURCHASE and billing-owner-only: the normal response is a Stripe Checkout URL the user MUST open to pay the monthly subscription before the capacity is granted — do NOT treat the add-on as active until payment completes. (Some early-stage types with no Stripe price provision immediately.) See dailey_addons for valid types + pricing.',
84
- {
85
- addon_type: z.string().describe('Add-on type, e.g. extra_vcpu, extra_ram, extra_db_storage, extra_object_storage, db_replica, app_ha, email_pro'),
86
- quantity: z.number().int().min(1).optional().describe('Number of units (default 1)'),
87
- },
88
- async ({ addon_type, quantity }) => {
89
- const body: Record<string, unknown> = { addon_type };
90
- if (typeof quantity === 'number') body.quantity = quantity;
91
- const res = await apiRequest<AddonPurchaseResponse>('POST', '/billing/addons', body);
92
- if (!res.ok) return textResult(formatError(res));
93
- const d = res.data;
94
- if (d.checkout_url) {
95
- return textResult(
96
- [
97
- `Add-on "${addon_type}" x${quantity ?? 1} — pay-at-purchase.`,
98
- '',
99
- '➜ Open this URL to complete the subscription payment:',
100
- d.checkout_url,
101
- '',
102
- 'The capacity is granted automatically once the Stripe Checkout is paid. It is NOT active yet.',
103
- ].join('\n'),
104
- );
105
- }
106
- // No Stripe price configured — provisioned immediately.
107
- const lines = [d.message || `Add-on "${addon_type}" added.`];
108
- if (d.addon) lines.push(`id: ${d.addon.id} $${d.addon.monthly_cost}/mo`);
109
- if (d.note) lines.push(d.note);
110
- return textResult(lines.join('\n'));
111
- },
112
- );
113
-
114
- server.tool(
115
- 'dailey_addon_cancel',
116
- 'Cancel an active à-la-carte add-on by its add-on id (from dailey_addons). Cancels the Stripe subscription item and removes the capacity from the account quota. Billing-owner-only.',
117
- { addon_id: z.string().describe('The add-on id to cancel (from dailey_addons)') },
118
- async ({ addon_id }) => {
119
- const res = await apiRequest<{ message: string; addon_id: string }>('DELETE', `/billing/addons/${addon_id}`);
120
- if (!res.ok) return textResult(formatError(res));
121
- return textResult(`${res.data.message || 'Add-on cancelled'} (${res.data.addon_id || addon_id}).`);
122
- },
123
- );
124
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Admin-only tools. Gated server-side by requireAdmin (email allowlist).
3
- */
4
-
5
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
- import { z } from 'zod';
7
- import { apiRequest, textResult, formatError } from '../api.js';
8
-
9
- export function registerAdminTools(server: McpServer) {
10
- server.tool(
11
- 'dailey_admin_onboard',
12
- 'Admin-only. One-shot customer provisioning: registers a new customer through the same flow as public signup (Core user + customer record + namespace + NetworkPolicies), sends the welcome email, and optionally verifies login works. Bypasses the weekly self-serve signup cap. Use this for manual handoffs (acquiring a new customer, onboarding a friend, migrating from another platform). Returns the generated password in the response — save it; the response is the only place it appears in plaintext.',
13
- {
14
- email: z.string().describe('Customer email address'),
15
- name: z.string().describe('Customer display name'),
16
- plan: z.enum(['free', 'builder', 'pro', 'scale']).optional().describe('Plan tier (default: free). Can be upgraded later.'),
17
- password: z.string().optional().describe('Optional specific password. If omitted, a strong random one (16 base64url chars) is generated and returned.'),
18
- },
19
- async ({ email, name, plan, password }) => {
20
- const body: any = { email, name };
21
- if (plan) body.plan = plan;
22
- if (password) body.password = password;
23
-
24
- const res = await apiRequest<any>('POST', `/admin/onboard`, body);
25
- if (!res.ok) return textResult(formatError(res));
26
- const d = res.data;
27
- if (!d.success) return textResult(`Onboard failed: ${d.error || 'unknown'}`);
28
-
29
- const lines = [
30
- `✓ ${d.name || name} onboarded`,
31
- `Email: ${d.email || email}`,
32
- `Password: ${d.password || '(not returned)'}`,
33
- `Plan: ${d.plan || plan || 'free'}`,
34
- `Customer ID: ${d.customer_id || '-'}`,
35
- `Slug: ${d.slug || '-'}`,
36
- ];
37
- if (d.already_existed) lines.push('', '(Account already existed — reactivated or plan updated)');
38
- if (d.login_verified === false) lines.push('', '⚠ Login verification failed — investigate before sharing credentials');
39
- return textResult(lines.join('\n'));
40
- },
41
- );
42
- }
package/src/tools/ai.ts DELETED
@@ -1,83 +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 AiInfoResponse {
6
- project: { id: string; slug: string };
7
- ai: {
8
- enabled: boolean; account_allowed: boolean; env_injected: boolean;
9
- tiers: string[]; base_url: string; env_vars: string[]; enable_with: string | null;
10
- };
11
- compute: {
12
- enabled: boolean; account_allowed: boolean; env_injected: boolean;
13
- base_url: string; transcribe_url: string; env_vars: string[]; enable_with: string | null;
14
- };
15
- integration: { ai: string; compute: string };
16
- warnings: string[];
17
- docs_url: string;
18
- }
19
-
20
- export function registerAiTools(server: McpServer) {
21
- server.tool(
22
- 'dailey_ai_info',
23
- 'Show whether Dailey AI and Dailey Compute (GPU) are enabled for a project, whether their env vars are injected into the pod, and how to wire them up (the DAILEY_AI_*/DAILEY_COMPUTE_* env contract + integration snippets). Use this to see if Compute/AI is on or off for an app and how to implement the patterns. Enable with dailey_ai_enable / dailey_compute_enable.',
24
- { project_id: z.string().describe('The project ID') },
25
- async ({ project_id }) => {
26
- const res = await apiRequest<AiInfoResponse>('GET', `/projects/${project_id}/ai/info`);
27
- if (!res.ok) return textResult(formatError(res));
28
- const d = res.data;
29
- const onoff = (b: boolean) => (b ? 'ON' : 'off');
30
- const gateNote = (enabled: boolean, allowed: boolean) =>
31
- enabled ? '' : (allowed ? ' (account allows it — enable per-project)' : ' (NOT allowed on this account/plan)');
32
- const lines = [
33
- `AI + Compute wiring: ${d.project.slug}`,
34
- '',
35
- `Dailey AI: ${onoff(d.ai.enabled)}${gateNote(d.ai.enabled, d.ai.account_allowed)}`,
36
- ` env injected: ${d.ai.env_injected ? 'yes' : 'no'}`,
37
- ` tiers: ${d.ai.tiers.join(', ')}`,
38
- ` base url: ${d.ai.base_url}`,
39
- ` env vars: ${d.ai.env_vars.join(', ')}`,
40
- ...(d.ai.enable_with ? [` enable: ${d.ai.enable_with} (or dailey_ai_enable)`] : []),
41
- '',
42
- `Dailey Compute: ${onoff(d.compute.enabled)}${gateNote(d.compute.enabled, d.compute.account_allowed)}`,
43
- ` env injected: ${d.compute.env_injected ? 'yes' : 'no'}`,
44
- ` transcribe: ${d.compute.transcribe_url}`,
45
- ` env vars: ${d.compute.env_vars.join(', ')}`,
46
- ...(d.compute.enable_with ? [` enable: ${d.compute.enable_with} (or dailey_compute_enable)`] : []),
47
- '',
48
- 'Integration patterns:',
49
- ` AI (OpenAI-compatible): ${d.integration.ai}`,
50
- ` Compute (transcribe): ${d.integration.compute}`,
51
- ];
52
- if (d.warnings && d.warnings.length) {
53
- lines.push('');
54
- for (const w of d.warnings) lines.push(`⚠ ${w}`);
55
- }
56
- lines.push('', `Docs: ${d.docs_url}`);
57
- lines.push('Note: injected env applies on the NEXT deploy — redeploy after enabling.');
58
- return textResult(lines.join('\n'));
59
- },
60
- );
61
-
62
- server.tool(
63
- 'dailey_ai_enable',
64
- 'Enable Dailey AI for a project. Mints a capability-scoped key and injects DAILEY_AI_BASE_URL/KEY/MODEL into the project env (applies on next deploy). The account-level AI feature must be on first; check dailey_ai_info.',
65
- { project_id: z.string().describe('The project ID') },
66
- async ({ project_id }) => {
67
- const res = await apiRequest('POST', `/projects/${project_id}/ai/enable`, {});
68
- if (!res.ok) return textResult(formatError(res));
69
- return textResult(`Dailey AI enabled.\n${JSON.stringify(res.data, null, 2)}\n\nRedeploy the project (dailey_deploy) to pick up the DAILEY_AI_* env vars.`);
70
- },
71
- );
72
-
73
- server.tool(
74
- 'dailey_compute_enable',
75
- 'Enable Dailey Compute (GPU) for a project. Mints a capability-scoped key and injects DAILEY_COMPUTE_URL/KEY into the project env (applies on next deploy). The account-level Compute feature must be on first; check dailey_ai_info.',
76
- { project_id: z.string().describe('The project ID') },
77
- async ({ project_id }) => {
78
- const res = await apiRequest('POST', `/projects/${project_id}/compute/enable`, {});
79
- if (!res.ok) return textResult(formatError(res));
80
- return textResult(`Dailey Compute enabled.\n${JSON.stringify(res.data, null, 2)}\n\nRedeploy the project (dailey_deploy) to pick up the DAILEY_COMPUTE_* env vars.`);
81
- },
82
- );
83
- }