@daileyos/mcp-server 1.0.1 → 1.1.0

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 (74) hide show
  1. package/.github/workflows/publish.yml +93 -0
  2. package/LICENSE +21 -0
  3. package/README.md +130 -0
  4. package/dist/index.js +28 -7
  5. package/dist/index.js.map +1 -1
  6. package/dist/tools/analyze.d.ts +3 -0
  7. package/dist/tools/analyze.d.ts.map +1 -0
  8. package/dist/tools/analyze.js +67 -0
  9. package/dist/tools/analyze.js.map +1 -0
  10. package/dist/tools/backups.d.ts +3 -0
  11. package/dist/tools/backups.d.ts.map +1 -0
  12. package/dist/tools/backups.js +55 -0
  13. package/dist/tools/backups.js.map +1 -0
  14. package/dist/tools/build-logs.d.ts +3 -0
  15. package/dist/tools/build-logs.d.ts.map +1 -0
  16. package/dist/tools/build-logs.js +39 -0
  17. package/dist/tools/build-logs.js.map +1 -0
  18. package/dist/tools/credentials-reveal.d.ts +3 -0
  19. package/dist/tools/credentials-reveal.d.ts.map +1 -0
  20. package/dist/tools/credentials-reveal.js +19 -0
  21. package/dist/tools/credentials-reveal.js.map +1 -0
  22. package/dist/tools/db.d.ts.map +1 -1
  23. package/dist/tools/db.js +92 -0
  24. package/dist/tools/db.js.map +1 -1
  25. package/dist/tools/deploy-status.d.ts +3 -0
  26. package/dist/tools/deploy-status.d.ts.map +1 -0
  27. package/dist/tools/deploy-status.js +109 -0
  28. package/dist/tools/deploy-status.js.map +1 -0
  29. package/dist/tools/domains.d.ts.map +1 -1
  30. package/dist/tools/domains.js +81 -17
  31. package/dist/tools/domains.js.map +1 -1
  32. package/dist/tools/images.d.ts.map +1 -1
  33. package/dist/tools/images.js +5 -2
  34. package/dist/tools/images.js.map +1 -1
  35. package/dist/tools/lifecycle.d.ts +3 -0
  36. package/dist/tools/lifecycle.d.ts.map +1 -0
  37. package/dist/tools/lifecycle.js +53 -0
  38. package/dist/tools/lifecycle.js.map +1 -0
  39. package/dist/tools/links.d.ts +3 -0
  40. package/dist/tools/links.d.ts.map +1 -0
  41. package/dist/tools/links.js +55 -0
  42. package/dist/tools/links.js.map +1 -0
  43. package/dist/tools/processes.d.ts +3 -0
  44. package/dist/tools/processes.d.ts.map +1 -0
  45. package/dist/tools/processes.js +98 -0
  46. package/dist/tools/processes.js.map +1 -0
  47. package/dist/tools/projects.d.ts.map +1 -1
  48. package/dist/tools/projects.js +13 -0
  49. package/dist/tools/projects.js.map +1 -1
  50. package/dist/tools/resource-config.d.ts +3 -0
  51. package/dist/tools/resource-config.d.ts.map +1 -0
  52. package/dist/tools/resource-config.js +56 -0
  53. package/dist/tools/resource-config.js.map +1 -0
  54. package/dist/tools/scale.d.ts.map +1 -1
  55. package/dist/tools/scale.js +9 -2
  56. package/dist/tools/scale.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/index.ts +32 -7
  59. package/src/tools/analyze.ts +98 -0
  60. package/src/tools/backups.ts +84 -0
  61. package/src/tools/build-logs.ts +65 -0
  62. package/src/tools/credentials-reveal.ts +31 -0
  63. package/src/tools/db.ts +104 -0
  64. package/src/tools/deploy-status.ts +149 -0
  65. package/src/tools/domains.ts +116 -21
  66. package/src/tools/images.ts +5 -2
  67. package/src/tools/lifecycle.ts +75 -0
  68. package/src/tools/links.ts +69 -0
  69. package/src/tools/processes.ts +172 -0
  70. package/src/tools/projects.ts +14 -0
  71. package/src/tools/resource-config.ts +84 -0
  72. package/src/tools/scale.ts +17 -3
  73. package/tests/mcp-protocol-smoke.mjs +149 -0
  74. package/tests/new-tools-smoke.mjs +211 -0
@@ -0,0 +1,172 @@
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 Process {
6
+ name: string;
7
+ type?: string;
8
+ command?: string;
9
+ port?: number;
10
+ replicas?: number;
11
+ cpu_millicores?: number;
12
+ memory_mb?: number;
13
+ timeout_seconds?: number;
14
+ namespace?: string;
15
+ domain?: string;
16
+ status?: string;
17
+ }
18
+
19
+ interface ProcessLogsResponse {
20
+ pods?: Array<{ pod: string; status: string; node: string; restarts: number; log: string }>;
21
+ logs?: string[];
22
+ }
23
+
24
+ interface ProcessMetricsResponse {
25
+ usage?: {
26
+ cpu_millicores?: number;
27
+ memory_mb?: number;
28
+ pods_ready?: number;
29
+ pods_total?: number;
30
+ restarts?: number;
31
+ };
32
+ resources?: {
33
+ cpu_limit_millicores?: number;
34
+ memory_limit_mb?: number;
35
+ replicas?: number;
36
+ };
37
+ pods?: Array<{ name: string; node: string }>;
38
+ }
39
+
40
+ export function registerProcessTools(server: McpServer) {
41
+ server.tool(
42
+ 'dailey_processes',
43
+ 'List processes defined in a project (from dailey.yaml). Shows web/worker/release processes with resource limits and status.',
44
+ { project_id: z.string().describe('The project ID') },
45
+ async ({ project_id }) => {
46
+ const res = await apiRequest<{ processes: Process[] }>('GET', `/projects/${project_id}/processes`);
47
+ if (!res.ok) return textResult(formatError(res));
48
+
49
+ const procs = res.data.processes || [];
50
+ if (procs.length === 0) {
51
+ return textResult('No processes defined. This project runs as a single process.');
52
+ }
53
+
54
+ const lines = [
55
+ `Processes (${procs.length})`,
56
+ `${'Name'.padEnd(20)} ${'Type'.padEnd(10)} ${'Replicas'.padEnd(9)} ${'CPU'.padEnd(8)} ${'Memory'.padEnd(10)} Status`,
57
+ '─'.repeat(80),
58
+ ];
59
+ for (const p of procs) {
60
+ lines.push(
61
+ `${(p.name || '').padEnd(20)} ${(p.type || '-').padEnd(10)} ${String(p.replicas ?? '-').padEnd(9)} ${String(p.cpu_millicores ?? '-').padEnd(8)} ${String(p.memory_mb ?? '-').padEnd(10)} ${p.status || '-'}`,
62
+ );
63
+ if (p.command) lines.push(` cmd: ${p.command}`);
64
+ }
65
+ return textResult(lines.join('\n'));
66
+ },
67
+ );
68
+
69
+ server.tool(
70
+ 'dailey_process_logs',
71
+ 'Fetch logs for a specific process in a multi-process project.',
72
+ {
73
+ project_id: z.string().describe('The project ID'),
74
+ process_name: z.string().describe('The process name (from dailey_processes)'),
75
+ tail: z.number().int().min(1).max(2000).optional().describe('Number of log lines to fetch (default: 100)'),
76
+ },
77
+ async ({ project_id, process_name, tail }) => {
78
+ const query = tail ? `?tail=${tail}` : '?tail=100';
79
+ const res = await apiRequest<ProcessLogsResponse>(
80
+ 'GET',
81
+ `/projects/${project_id}/processes/${encodeURIComponent(process_name)}/logs${query}`,
82
+ );
83
+ if (!res.ok) return textResult(formatError(res));
84
+
85
+ const logs = res.data.logs || [];
86
+ if (logs.length === 0) return textResult(`No logs for process ${process_name}.`);
87
+ return textResult([`Logs for ${process_name} (last ${tail || 100} lines):`, '', ...logs].join('\n'));
88
+ },
89
+ );
90
+
91
+ server.tool(
92
+ 'dailey_process_restart',
93
+ 'Restart a single process (rolling restart). Only affects the named process — other processes keep running.',
94
+ {
95
+ project_id: z.string().describe('The project ID'),
96
+ process_name: z.string().describe('The process name to restart'),
97
+ },
98
+ async ({ project_id, process_name }) => {
99
+ const res = await apiRequest(
100
+ 'POST',
101
+ `/projects/${project_id}/processes/${encodeURIComponent(process_name)}/restart`,
102
+ );
103
+ if (!res.ok) return textResult(formatError(res));
104
+ return textResult(`Restart initiated for process ${process_name}. Pods will roll one-by-one.`);
105
+ },
106
+ );
107
+
108
+ server.tool(
109
+ 'dailey_process_metrics',
110
+ 'Get live resource usage and pod health for a process: pods ready, restarts, CPU/memory limits.',
111
+ {
112
+ project_id: z.string().describe('The project ID'),
113
+ process_name: z.string().describe('The process name'),
114
+ },
115
+ async ({ project_id, process_name }) => {
116
+ const res = await apiRequest<ProcessMetricsResponse>(
117
+ 'GET',
118
+ `/projects/${project_id}/processes/${encodeURIComponent(process_name)}/metrics`,
119
+ );
120
+ if (!res.ok) return textResult(formatError(res));
121
+
122
+ const usage = res.data.usage || {};
123
+ const resources = res.data.resources || {};
124
+ const pods = res.data.pods || [];
125
+
126
+ const lines = [
127
+ `Process: ${process_name}`,
128
+ '─'.repeat(40),
129
+ `Pods ready: ${usage.pods_ready ?? 0} / ${usage.pods_total ?? 0}`,
130
+ `Restarts: ${usage.restarts ?? 0}`,
131
+ `CPU limit: ${resources.cpu_limit_millicores ?? '-'}m`,
132
+ `Mem limit: ${resources.memory_limit_mb ?? '-'} MB`,
133
+ `Replicas: ${resources.replicas ?? '-'}`,
134
+ ];
135
+ if (pods.length > 0) {
136
+ lines.push('');
137
+ lines.push('Pods:');
138
+ for (const pod of pods) lines.push(` ${pod.name} on ${pod.node}`);
139
+ }
140
+ return textResult(lines.join('\n'));
141
+ },
142
+ );
143
+
144
+ server.tool(
145
+ 'dailey_process_resources',
146
+ 'Update replicas, CPU, or memory limits for a specific process. Omit fields you do not want to change.',
147
+ {
148
+ project_id: z.string().describe('The project ID'),
149
+ process_name: z.string().describe('The process name'),
150
+ replicas: z.number().int().min(0).max(20).optional().describe('Replicas (0-20)'),
151
+ cpu_millicores: z.number().int().min(10).max(8000).optional().describe('CPU limit in millicores (10-8000)'),
152
+ memory_mb: z.number().int().min(64).max(32768).optional().describe('Memory limit in MB (64-32768)'),
153
+ },
154
+ async ({ project_id, process_name, replicas, cpu_millicores, memory_mb }) => {
155
+ const body: Record<string, number> = {};
156
+ if (replicas !== undefined) body.replicas = replicas;
157
+ if (cpu_millicores !== undefined) body.cpu_millicores = cpu_millicores;
158
+ if (memory_mb !== undefined) body.memory_mb = memory_mb;
159
+ if (Object.keys(body).length === 0) {
160
+ return textResult('Error: specify at least one of replicas, cpu_millicores, or memory_mb.');
161
+ }
162
+ const res = await apiRequest(
163
+ 'POST',
164
+ `/projects/${project_id}/processes/${encodeURIComponent(process_name)}/resources`,
165
+ body,
166
+ );
167
+ if (!res.ok) return textResult(formatError(res));
168
+ const changed = Object.entries(body).map(([k, v]) => `${k}=${v}`).join(', ');
169
+ return textResult(`Updated process ${process_name}: ${changed}`);
170
+ },
171
+ );
172
+ }
@@ -142,17 +142,31 @@ export function registerProjectTools(server: McpServer) {
142
142
  services = manifest.entries.filter((e: any) => e.type === 'managed' || e.type === 'app_service');
143
143
  }
144
144
 
145
+ // Safety: ensure at least one service is marked 'app_service' so the
146
+ // deployer knows which one gets the public ingress. Without this, all
147
+ // services deploy as "internal only" and the project is unreachable
148
+ // with no warning. (Scott hit this on 2026-04-20.)
149
+ const hasAppService = services?.some((s: any) => s.type === 'app_service');
150
+ if (services?.length && !hasAppService) {
151
+ services[0].type = 'app_service';
152
+ }
153
+
145
154
  const res = await apiRequest<any>('POST', `/projects/${project_id}/deploy-multi`, {
146
155
  selected_services: services,
147
156
  });
148
157
  if (!res.ok) return textResult(formatError(res));
149
158
 
159
+ const primary = services?.find((s: any) => s.type === 'app_service')?.name;
150
160
  return textResult([
151
161
  `Multi-container deploy triggered!`,
152
162
  ``,
153
163
  `Build ID: ${res.data.build_id}`,
154
164
  `Deploy Group: ${res.data.deploy_group_id}`,
155
165
  `Services: ${services?.length || 0}`,
166
+ `Primary (web): ${primary || 'none — check deploy log'}`,
167
+ ``,
168
+ `Next: call dailey_deploy_status with project_id=${project_id} to watch progress.`,
169
+ ` If it fails, call dailey_build_logs with project_id=${project_id} for full output.`,
156
170
  ].join('\n'));
157
171
  },
158
172
  );
@@ -0,0 +1,84 @@
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 ResourceConfigResponse {
6
+ cpu?: number;
7
+ memory_mb?: number;
8
+ storage_gb?: number;
9
+ replicas?: number;
10
+ project?: {
11
+ cpu_request?: string;
12
+ cpu_limit?: string;
13
+ memory_request?: string;
14
+ memory_limit?: string;
15
+ storage_limit?: string;
16
+ replicas?: number;
17
+ };
18
+ pool?: {
19
+ plan?: string;
20
+ cpu_total?: number;
21
+ cpu_used?: number;
22
+ memory_total_mb?: number;
23
+ memory_used_mb?: number;
24
+ storage_total_gb?: number;
25
+ storage_used_gb?: number;
26
+ };
27
+ }
28
+
29
+ export function registerResourceConfigTools(server: McpServer) {
30
+ server.tool(
31
+ 'dailey_resource_config',
32
+ 'Get or set CPU/memory/storage limits for a project. Pool shows remaining plan capacity.',
33
+ {
34
+ project_id: z.string().describe('The project ID'),
35
+ action: z.enum(['get', 'set']).describe('get | set'),
36
+ cpu: z.number().optional().describe('CPU cores (e.g., 0.5, 1, 2). Used by set.'),
37
+ memory_mb: z.number().int().optional().describe('Memory in MB. Used by set.'),
38
+ storage_gb: z.number().optional().describe('Storage in GB. Used by set.'),
39
+ replicas: z.number().int().min(0).max(20).optional().describe('Replicas. Used by set.'),
40
+ },
41
+ async ({ project_id, action, cpu, memory_mb, storage_gb, replicas }) => {
42
+ if (action === 'get') {
43
+ const res = await apiRequest<ResourceConfigResponse>('GET', `/projects/${project_id}/resource-config`);
44
+ if (!res.ok) return textResult(formatError(res));
45
+
46
+ const d = res.data;
47
+ const proj = d.project || {};
48
+ const pool = d.pool || {};
49
+
50
+ const lines = [
51
+ `Resource config for project ${project_id}`,
52
+ '─'.repeat(50),
53
+ `CPU: ${d.cpu ?? 0} cores (limit: ${proj.cpu_limit || '-'}, request: ${proj.cpu_request || '-'})`,
54
+ `Memory: ${d.memory_mb ?? 0} MB (limit: ${proj.memory_limit || '-'}, request: ${proj.memory_request || '-'})`,
55
+ `Storage: ${d.storage_gb ?? 0} GB (limit: ${proj.storage_limit || '-'})`,
56
+ `Replicas: ${d.replicas ?? 1}`,
57
+ '',
58
+ `Plan: ${pool.plan || 'unknown'}`,
59
+ `CPU pool: ${pool.cpu_used ?? 0}/${pool.cpu_total ?? 0} cores used`,
60
+ `Memory pool: ${pool.memory_used_mb ?? 0}/${pool.memory_total_mb ?? 0} MB used`,
61
+ `Storage pool: ${pool.storage_used_gb ?? 0}/${pool.storage_total_gb ?? 0} GB used`,
62
+ ];
63
+ return textResult(lines.join('\n'));
64
+ }
65
+
66
+ if (action === 'set') {
67
+ const body: Record<string, number> = {};
68
+ if (cpu !== undefined) body.cpu = cpu;
69
+ if (memory_mb !== undefined) body.memory_mb = memory_mb;
70
+ if (storage_gb !== undefined) body.storage_gb = storage_gb;
71
+ if (replicas !== undefined) body.replicas = replicas;
72
+ if (Object.keys(body).length === 0) {
73
+ return textResult('Error: specify at least one of cpu, memory_mb, storage_gb, replicas.');
74
+ }
75
+ const res = await apiRequest('PUT', `/projects/${project_id}/resource-config`, body);
76
+ if (!res.ok) return textResult(formatError(res));
77
+ const changed = Object.entries(body).map(([k, v]) => `${k}=${v}`).join(', ');
78
+ return textResult(`Resource config updated: ${changed}.\n\nChanges take effect on the next deploy (or use dailey_process_restart).`);
79
+ }
80
+
81
+ return textResult('Invalid action. Use get or set.');
82
+ },
83
+ );
84
+ }
@@ -2,18 +2,32 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { z } from 'zod';
3
3
  import { apiRequest, formatError, textResult } from '../api.js';
4
4
 
5
+ interface ScaleResponse {
6
+ scaled?: boolean;
7
+ replicas?: number;
8
+ warning?: string;
9
+ }
10
+
5
11
  export function registerScaleTools(server: McpServer) {
6
12
  server.tool(
7
13
  'dailey_scale',
8
- 'Scale project replicas up or down',
14
+ 'Scale project replicas up or down. Surfaces warnings if the DB updated but k8s did not apply (e.g., deployment missing).',
9
15
  {
10
16
  project_id: z.string().describe('The project ID'),
11
17
  replicas: z.number().describe('Number of replicas to scale to'),
12
18
  },
13
19
  async ({ project_id, replicas }) => {
14
- const res = await apiRequest('POST', `/projects/${project_id}/scale`, { replicas });
20
+ const res = await apiRequest<ScaleResponse>('POST', `/projects/${project_id}/scale`, { replicas });
15
21
  if (!res.ok) return textResult(formatError(res));
16
- return textResult(`Project ${project_id} scaled to ${replicas} replica(s).`);
22
+
23
+ const lines = [`Project ${project_id} scaled to ${replicas} replica(s).`];
24
+ if (res.data?.warning) {
25
+ lines.push('');
26
+ lines.push(`⚠ Warning: ${res.data.warning}`);
27
+ lines.push('');
28
+ lines.push('Next steps: check dailey_project_resources to see if pods are actually running. If the deployment is missing, trigger a redeploy.');
29
+ }
30
+ return textResult(lines.join('\n'));
17
31
  },
18
32
  );
19
33
  }
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * End-to-end MCP-protocol smoke test.
4
+ *
5
+ * Spawns the compiled MCP server, speaks the JSON-RPC stdio protocol, lists
6
+ * all tools, and calls a representative read-only tool. This exercises the
7
+ * actual MCP surface LLMs see.
8
+ */
9
+ import { spawn } from 'node:child_process';
10
+ import path from 'node:path';
11
+
12
+ const binary = path.resolve(new URL('.', import.meta.url).pathname, '..', 'dist/index.js');
13
+
14
+ const env = {
15
+ ...process.env,
16
+ DAILEY_API_URL: process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api',
17
+ DAILEY_EMAIL: process.env.DAILEY_EMAIL,
18
+ DAILEY_PASSWORD: process.env.DAILEY_PASSWORD,
19
+ };
20
+
21
+ if (!env.DAILEY_EMAIL || !env.DAILEY_PASSWORD) {
22
+ console.error('DAILEY_EMAIL and DAILEY_PASSWORD must be set');
23
+ process.exit(1);
24
+ }
25
+
26
+ const child = spawn('node', [binary], { env, stdio: ['pipe', 'pipe', 'pipe'] });
27
+
28
+ let nextId = 1;
29
+ const pending = new Map();
30
+ let buffer = '';
31
+
32
+ child.stdout.on('data', (chunk) => {
33
+ buffer += chunk.toString();
34
+ const lines = buffer.split('\n');
35
+ buffer = lines.pop();
36
+ for (const line of lines) {
37
+ if (!line.trim()) continue;
38
+ try {
39
+ const msg = JSON.parse(line);
40
+ if (msg.id && pending.has(msg.id)) {
41
+ const { resolve } = pending.get(msg.id);
42
+ pending.delete(msg.id);
43
+ resolve(msg);
44
+ }
45
+ } catch { /* ignore */ }
46
+ }
47
+ });
48
+
49
+ child.stderr.on('data', (chunk) => {
50
+ process.stderr.write(`[mcp-server] ${chunk}`);
51
+ });
52
+
53
+ function send(method, params) {
54
+ return new Promise((resolve, reject) => {
55
+ const id = nextId++;
56
+ pending.set(id, { resolve, reject });
57
+ child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
58
+ setTimeout(() => {
59
+ if (pending.has(id)) {
60
+ pending.delete(id);
61
+ reject(new Error(`Timeout waiting for ${method}`));
62
+ }
63
+ }, 15000);
64
+ });
65
+ }
66
+
67
+ async function main() {
68
+ console.log('Spawning MCP server...');
69
+
70
+ // MCP handshake
71
+ const init = await send('initialize', {
72
+ protocolVersion: '2024-11-05',
73
+ capabilities: {},
74
+ clientInfo: { name: 'smoke-test', version: '1.0.0' },
75
+ });
76
+ console.log(`✓ initialized (server: ${init.result?.serverInfo?.name} v${init.result?.serverInfo?.version})`);
77
+
78
+ // Notify initialized (required by some clients)
79
+ child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
80
+
81
+ // List tools
82
+ const toolsMsg = await send('tools/list', {});
83
+ const tools = toolsMsg.result?.tools || [];
84
+ console.log(`✓ tools/list returned ${tools.length} tools`);
85
+
86
+ const expected = [
87
+ 'dailey_whoami',
88
+ 'dailey_list_projects',
89
+ 'dailey_project_info',
90
+ 'dailey_deploy_status',
91
+ 'dailey_build_logs',
92
+ 'dailey_processes',
93
+ 'dailey_process_logs',
94
+ 'dailey_process_restart',
95
+ 'dailey_process_metrics',
96
+ 'dailey_process_resources',
97
+ 'dailey_pause',
98
+ 'dailey_resume',
99
+ 'dailey_backups',
100
+ 'dailey_resource_config',
101
+ 'dailey_service_links',
102
+ 'dailey_reveal_credential',
103
+ 'dailey_analyze_repo',
104
+ 'dailey_db_validate',
105
+ 'dailey_db_tunnel',
106
+ 'dailey_scale',
107
+ 'dailey_domains',
108
+ ];
109
+
110
+ const names = new Set(tools.map((t) => t.name));
111
+ const missing = expected.filter((n) => !names.has(n));
112
+ if (missing.length) {
113
+ console.log(`✗ missing tools: ${missing.join(', ')}`);
114
+ process.exit(1);
115
+ }
116
+ console.log(`✓ all expected new tools registered`);
117
+
118
+ // Call a real tool — dailey_whoami — to verify end-to-end flow.
119
+ const whoamiMsg = await send('tools/call', { name: 'dailey_whoami', arguments: {} });
120
+ const text = whoamiMsg.result?.content?.[0]?.text || '';
121
+ if (!text.includes('@') && !text.toLowerCase().includes('email')) {
122
+ console.log(`✗ dailey_whoami returned unexpected output: ${text.slice(0, 100)}`);
123
+ process.exit(1);
124
+ }
125
+ console.log(`✓ dailey_whoami call succeeded (${text.split('\n')[0]})`);
126
+
127
+ // Call a new tool — dailey_analyze_repo on nginx:alpine.
128
+ const analyzeMsg = await send('tools/call', {
129
+ name: 'dailey_analyze_repo',
130
+ arguments: { repo_url: 'nginx:alpine' },
131
+ });
132
+ const analyzeText = analyzeMsg.result?.content?.[0]?.text || '';
133
+ if (!analyzeText.includes('Analysis') || !analyzeText.includes('nginx:alpine')) {
134
+ console.log(`✗ dailey_analyze_repo returned unexpected output: ${analyzeText.slice(0, 200)}`);
135
+ process.exit(1);
136
+ }
137
+ console.log(`✓ dailey_analyze_repo call succeeded`);
138
+
139
+ child.kill();
140
+ console.log('');
141
+ console.log(`All checks passed. ${tools.length} tools registered, new tools callable.`);
142
+ process.exit(0);
143
+ }
144
+
145
+ main().catch((err) => {
146
+ console.error('TEST CRASH:', err);
147
+ child.kill();
148
+ process.exit(2);
149
+ });
@@ -0,0 +1,211 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Smoke test for the v1.1.0 MCP tools.
4
+ *
5
+ * Exercises every new tool against a real Dailey OS account, reports
6
+ * pass/fail per tool. Does NOT mutate (no deploys, no deletes, no creates).
7
+ * Looks for a project to test against — if none exists, skips project-
8
+ * scoped tests.
9
+ *
10
+ * Usage:
11
+ * DAILEY_EMAIL=... DAILEY_PASSWORD=... node tests/new-tools-smoke.mjs
12
+ */
13
+
14
+ const API_URL = process.env.DAILEY_API_URL || 'https://os.dailey.cloud/api';
15
+ const EMAIL = process.env.DAILEY_EMAIL;
16
+ const PASSWORD = process.env.DAILEY_PASSWORD;
17
+
18
+ if (!EMAIL || !PASSWORD) {
19
+ console.error('DAILEY_EMAIL and DAILEY_PASSWORD must be set');
20
+ process.exit(1);
21
+ }
22
+
23
+ let token = '';
24
+
25
+ async function login() {
26
+ const res = await fetch(`${API_URL}/customers/login`, {
27
+ method: 'POST',
28
+ headers: { 'Content-Type': 'application/json' },
29
+ body: JSON.stringify({ email: EMAIL, password: PASSWORD }),
30
+ });
31
+ if (!res.ok) throw new Error(`login failed: ${res.status}`);
32
+ const data = await res.json();
33
+ token = data.access_token;
34
+ return data;
35
+ }
36
+
37
+ async function call(method, path, body) {
38
+ const opts = {
39
+ method,
40
+ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
41
+ };
42
+ if (body) opts.body = JSON.stringify(body);
43
+ const res = await fetch(`${API_URL}${path}`, opts);
44
+ const text = await res.text();
45
+ let data;
46
+ try { data = JSON.parse(text); } catch { data = text; }
47
+ return { status: res.status, ok: res.ok, data };
48
+ }
49
+
50
+ const results = [];
51
+ function report(name, passed, detail) {
52
+ const icon = passed ? '✓' : '✗';
53
+ const line = `${icon} ${name}${detail ? ` — ${detail}` : ''}`;
54
+ console.log(line);
55
+ results.push({ name, passed, detail });
56
+ }
57
+
58
+ async function test(name, fn) {
59
+ try {
60
+ const detail = await fn();
61
+ report(name, true, detail);
62
+ } catch (err) {
63
+ report(name, false, err.message);
64
+ }
65
+ }
66
+
67
+ async function main() {
68
+ console.log(`Dailey MCP smoke test against ${API_URL}`);
69
+ console.log('─'.repeat(60));
70
+
71
+ const login_data = await login();
72
+ console.log(`Authed as ${login_data.customer?.email || EMAIL}`);
73
+ console.log('');
74
+
75
+ // Find a project to test against
76
+ const projects = await call('GET', '/projects');
77
+ if (!projects.ok || !projects.data.projects?.length) {
78
+ console.log('No projects found — skipping project-scoped tests');
79
+ process.exit(0);
80
+ }
81
+ const project = projects.data.projects[0];
82
+ console.log(`Testing against project: ${project.name} (${project.id})`);
83
+ console.log('');
84
+
85
+ // Endpoints backing the new MCP tools
86
+ await test('dailey_deploy_status', async () => {
87
+ const r = await call('GET', `/projects/${project.id}/deploy-status`);
88
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
89
+ return `mode=${r.data.mode}, can_deploy=${r.data.can_deploy}`;
90
+ });
91
+
92
+ await test('dailey_build_logs (builds list)', async () => {
93
+ const r = await call('GET', `/projects/${project.id}/deploys`);
94
+ if (!r.ok) throw new Error(`HTTP ${r.status}`);
95
+ return `${r.data.builds?.length ?? 0} builds`;
96
+ });
97
+
98
+ await test('dailey_build_logs (fetch log)', async () => {
99
+ const list = await call('GET', `/projects/${project.id}/deploys`);
100
+ if (!list.ok) throw new Error(`list HTTP ${list.status}`);
101
+ const latest = list.data.builds?.[0];
102
+ if (!latest) return 'no builds — skipped';
103
+ const r = await call('GET', `/builds/${latest.id}`);
104
+ if (!r.ok) throw new Error(`HTTP ${r.status}`);
105
+ const logLen = (r.data.log || '').length;
106
+ return `build ${latest.id} status=${r.data.status} log=${logLen} bytes`;
107
+ });
108
+
109
+ await test('dailey_processes', async () => {
110
+ const r = await call('GET', `/projects/${project.id}/processes`);
111
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
112
+ return `${r.data.processes?.length ?? 0} processes`;
113
+ });
114
+
115
+ await test('dailey_pause/resume (dry — read state)', async () => {
116
+ // Don't actually pause a prod project. Just verify route exists and
117
+ // project is valid by hitting deploy-status (which we already did).
118
+ return `skipped mutation — route /pause,/resume exist per code audit`;
119
+ });
120
+
121
+ await test('dailey_backups (list)', async () => {
122
+ const r = await call('GET', `/projects/${project.id}/backups`);
123
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
124
+ return `${r.data.backups?.length ?? 0} backups`;
125
+ });
126
+
127
+ await test('dailey_resource_config (get)', async () => {
128
+ const r = await call('GET', `/projects/${project.id}/resource-config`);
129
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
130
+ return `cpu=${r.data.cpu}, mem=${r.data.memory_mb}MB`;
131
+ });
132
+
133
+ await test('dailey_service_links (list)', async () => {
134
+ const r = await call('GET', `/projects/${project.id}/links`);
135
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
136
+ return `${r.data.links?.length ?? 0} links`;
137
+ });
138
+
139
+ await test('dailey_domains (list)', async () => {
140
+ const r = await call('GET', `/projects/${project.id}/domains`);
141
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
142
+ return `${r.data.domains?.length ?? 0} domains`;
143
+ });
144
+
145
+ // DNS check requires a real domain — try one if any exists
146
+ const domainList = await call('GET', `/projects/${project.id}/domains`);
147
+ // Skip the default *.dailey.cloud domain — dns_check rejects those.
148
+ const customDomain = domainList.ok
149
+ ? domainList.data.domains?.find((x) => !x.is_default)
150
+ : null;
151
+ if (customDomain) {
152
+ const d = customDomain.hostname;
153
+ await test(`dailey_domains dns_check (${d})`, async () => {
154
+ const r = await call('GET', `/projects/${project.id}/domains/dns-check?domain=${encodeURIComponent(d)}`);
155
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
156
+ return `matched=${r.data.matched}, type=${r.data.match_type}`;
157
+ });
158
+
159
+ await test(`dailey_domains cert_status (${d})`, async () => {
160
+ const r = await call('GET', `/projects/${project.id}/domains/cert-status?domain=${encodeURIComponent(d)}`);
161
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
162
+ return `status=${r.data.status}`;
163
+ });
164
+ } else {
165
+ console.log('⊘ dailey_domains dns_check / cert_status — no custom domains on test project (default only)');
166
+ }
167
+
168
+ await test('dailey_analyze_repo (docker image)', async () => {
169
+ const r = await call('POST', '/projects/analyze', { repo_url: 'nginx:alpine' });
170
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
171
+ return `_isDockerImage=${r.data._isDockerImage}, issues=${r.data.issues?.length || 0}`;
172
+ });
173
+
174
+ await test('dailey_db_validate (dry)', async () => {
175
+ // Does project have a DB? check db info first.
176
+ const info = await call('GET', `/projects/${project.id}/database`);
177
+ if (!info.ok) return `no DB provisioned — skipped`;
178
+ const r = await call('POST', `/projects/${project.id}/database/validate`, {
179
+ sql: 'CREATE TABLE IF NOT EXISTS _mcp_smoke_test (id INT);',
180
+ });
181
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
182
+ return `valid=${r.data.valid}, warnings=${r.data.has_warnings}`;
183
+ });
184
+
185
+ await test('dailey_db_tunnel (list)', async () => {
186
+ const r = await call('GET', `/projects/${project.id}/database/tunnel`);
187
+ if (!r.ok) throw new Error(`HTTP ${r.status}: ${JSON.stringify(r.data)}`);
188
+ return `${r.data.sessions?.length ?? 0} active sessions`;
189
+ });
190
+
191
+ // Summary
192
+ console.log('');
193
+ console.log('─'.repeat(60));
194
+ const passed = results.filter((r) => r.passed).length;
195
+ const failed = results.filter((r) => !r.passed).length;
196
+ console.log(`Passed: ${passed} Failed: ${failed} Total: ${results.length}`);
197
+ if (failed > 0) {
198
+ console.log('');
199
+ console.log('Failures:');
200
+ for (const r of results.filter((x) => !x.passed)) {
201
+ console.log(` ✗ ${r.name}: ${r.detail}`);
202
+ }
203
+ process.exit(1);
204
+ }
205
+ process.exit(0);
206
+ }
207
+
208
+ main().catch((err) => {
209
+ console.error('TEST CRASH:', err);
210
+ process.exit(2);
211
+ });