@daileyos/mcp-server 1.11.3 → 1.12.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.
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/tools/buddy.d.ts +3 -0
- package/dist/tools/buddy.d.ts.map +1 -0
- package/dist/tools/buddy.js +359 -0
- package/dist/tools/buddy.js.map +1 -0
- package/dist/tools/diagnose.d.ts.map +1 -1
- package/dist/tools/diagnose.js +152 -0
- package/dist/tools/diagnose.js.map +1 -1
- package/dist/tools/projects.d.ts.map +1 -1
- package/dist/tools/projects.js +1 -1
- package/dist/tools/projects.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/tools/buddy.ts +386 -0
- package/src/tools/diagnose.ts +183 -0
- package/src/tools/projects.ts +3 -1
package/src/tools/diagnose.ts
CHANGED
|
@@ -32,6 +32,144 @@ interface ProjectListEntry {
|
|
|
32
32
|
|
|
33
33
|
const ERROR_LINE_PATTERN = /(error|fatal|panic|exception|uncaught|unhandled)/i;
|
|
34
34
|
|
|
35
|
+
interface KnownIssue {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
plain_english: string;
|
|
39
|
+
fix: string;
|
|
40
|
+
severity: 'fail' | 'warn';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface PatternRule {
|
|
44
|
+
pattern: RegExp;
|
|
45
|
+
issue: KnownIssue;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const KNOWN_PATTERNS: PatternRule[] = [
|
|
49
|
+
{
|
|
50
|
+
pattern: /P3009|migrate found failed migrations|applied migration.*is not recorded/i,
|
|
51
|
+
issue: {
|
|
52
|
+
id: 'prisma_failed_migration',
|
|
53
|
+
name: 'Prisma: failed migration in history',
|
|
54
|
+
plain_english:
|
|
55
|
+
'Your database has a migration that started but never finished — usually because the app crashed mid-deploy or you restored a dump on top of an existing schema. Prisma refuses to start until it is resolved.',
|
|
56
|
+
fix: 'Run: dailey db exec <project> "UPDATE _prisma_migrations SET finished_at = started_at, logs = NULL WHERE finished_at IS NULL AND rolled_back_at IS NULL;" --confirm\nThen redeploy: dailey deploy <project>',
|
|
57
|
+
severity: 'fail',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
pattern: /PrismaClientInitializationError|prisma\.generate|@prisma\/client did not initialize/i,
|
|
62
|
+
issue: {
|
|
63
|
+
id: 'prisma_client_not_generated',
|
|
64
|
+
name: 'Prisma: client not generated',
|
|
65
|
+
plain_english:
|
|
66
|
+
'The Prisma client was not generated during the build step. Your Dockerfile or build command is missing "prisma generate" before "node" starts.',
|
|
67
|
+
fix: 'Add "npx prisma generate" to your build step. In package.json: "build": "prisma generate && tsc" (or whatever your build command is). Then redeploy: dailey deploy <project>',
|
|
68
|
+
severity: 'fail',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
pattern: /exit code 137|OOMKilled|out of memory kill|memory limit exceeded/i,
|
|
73
|
+
issue: {
|
|
74
|
+
id: 'oom_killed',
|
|
75
|
+
name: 'Pod killed: out of memory (OOM)',
|
|
76
|
+
plain_english:
|
|
77
|
+
'Your app used more memory than its limit and the platform killed it. The default limit is 512 MB per replica.',
|
|
78
|
+
fix: 'Check memory usage: dailey usage <project>\nIncrease the limit: dailey resource-config <project> --memory-limit 1024\nOr reduce memory use (Node.js tip: set NODE_OPTIONS="--max-old-space-size=900" in your env vars).',
|
|
79
|
+
severity: 'fail',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
pattern: /FATAL ERROR:.*JavaScript heap out of memory|heap out of memory/i,
|
|
84
|
+
issue: {
|
|
85
|
+
id: 'node_heap_oom',
|
|
86
|
+
name: 'Node.js heap out of memory',
|
|
87
|
+
plain_english:
|
|
88
|
+
"Your Node.js process ran out of heap space. It didn't hit the container memory limit — the V8 heap limit (default ~512 MB) was hit first.",
|
|
89
|
+
fix: 'Set NODE_OPTIONS env var: dailey env set <project> NODE_OPTIONS "--max-old-space-size=1024"\nThen redeploy: dailey deploy <project>',
|
|
90
|
+
severity: 'fail',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
pattern: /ECONNREFUSED.*(?:3306|5432|27017)|connect ECONNREFUSED.*database|database connection refused/i,
|
|
95
|
+
issue: {
|
|
96
|
+
id: 'db_connection_refused',
|
|
97
|
+
name: 'Database connection refused',
|
|
98
|
+
plain_english:
|
|
99
|
+
'Your app tried to connect to the database but got "connection refused." Either the database is not provisioned, or the connection URL is wrong.',
|
|
100
|
+
fix: 'Check if a database is provisioned: dailey db info <project>\nIf not provisioned: dailey db provision <project> --type mysql (or postgres)\nIf provisioned, verify DATABASE_URL is correct: dailey env list <project>',
|
|
101
|
+
severity: 'fail',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
pattern: /EADDRINUSE|address already in use|port.*already in use/i,
|
|
106
|
+
issue: {
|
|
107
|
+
id: 'port_in_use',
|
|
108
|
+
name: 'Port already in use',
|
|
109
|
+
plain_english:
|
|
110
|
+
"Your app tried to listen on a port that's already occupied. On Dailey OS you must listen on the PORT env var (always 3000) — never hardcode a port number.",
|
|
111
|
+
fix: 'Update your app to bind to process.env.PORT (not a hardcoded number). Example: app.listen(process.env.PORT || 3000)\nThen redeploy: dailey deploy <project>',
|
|
112
|
+
severity: 'fail',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
pattern: /Cannot find module|MODULE_NOT_FOUND|Error: Cannot find|module not found/i,
|
|
117
|
+
issue: {
|
|
118
|
+
id: 'module_not_found',
|
|
119
|
+
name: 'Module not found',
|
|
120
|
+
plain_english:
|
|
121
|
+
'A package your app depends on is missing from the build. This usually means a dependency was not installed during the build, or was accidentally added to devDependencies instead of dependencies.',
|
|
122
|
+
fix: 'Check your package.json: make sure the missing package is in "dependencies" (not "devDependencies").\nThen redeploy: dailey deploy <project>\nIf the build is failing: dailey build-logs <project>',
|
|
123
|
+
severity: 'fail',
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
pattern:
|
|
128
|
+
/TypeError: Cannot read propert(?:y|ies) of undefined|TypeError: Cannot read propert(?:y|ies) of null|ReferenceError: process is not defined/i,
|
|
129
|
+
issue: {
|
|
130
|
+
id: 'missing_env_var',
|
|
131
|
+
name: 'Missing environment variable (likely)',
|
|
132
|
+
plain_english:
|
|
133
|
+
'Your app crashed trying to read a value that was undefined or null. This is often a missing environment variable — your code references process.env.SOMETHING that was never set.',
|
|
134
|
+
fix: 'Check which env vars are set: dailey env list <project>\nSet a missing var: dailey env set <project> MY_VAR "my value"\nThen redeploy: dailey deploy <project>',
|
|
135
|
+
severity: 'warn',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
pattern: /secretOrPrivateKey must have a value|jwt.*secret.*undefined|invalid signature/i,
|
|
140
|
+
issue: {
|
|
141
|
+
id: 'missing_jwt_secret',
|
|
142
|
+
name: 'Missing JWT secret',
|
|
143
|
+
plain_english:
|
|
144
|
+
'Your app uses JWT (JSON Web Tokens) but the secret key env var is not set. Sessions and auth will fail.',
|
|
145
|
+
fix: 'Set your JWT secret: dailey env set <project> JWT_SECRET "$(openssl rand -hex 32)"\nThen redeploy: dailey deploy <project>',
|
|
146
|
+
severity: 'fail',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
pattern: /SSL SYSCALL error|SSL connection has been closed|EPROTO.*SSL|certificate verify failed/i,
|
|
151
|
+
issue: {
|
|
152
|
+
id: 'ssl_db_error',
|
|
153
|
+
name: 'Database SSL error',
|
|
154
|
+
plain_english:
|
|
155
|
+
'Your app failed to establish a secure connection to the database. This usually means the SSL mode in your connection string does not match what the server requires.',
|
|
156
|
+
fix: 'If using PostgreSQL, add ?sslmode=require to DATABASE_URL.\nIf using MySQL, add ?ssl=true.\nCheck current DATABASE_URL: dailey env list <project>',
|
|
157
|
+
severity: 'fail',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
pattern: /SIGTERM|graceful shutdown|terminating connection|Gracefully stopping/i,
|
|
162
|
+
issue: {
|
|
163
|
+
id: 'sigterm_restart',
|
|
164
|
+
name: 'Pod restarting (SIGTERM)',
|
|
165
|
+
plain_english:
|
|
166
|
+
'Your app is being stopped and restarted by the platform. This is normal during deploys, but if it is happening repeatedly it means the app is not starting up properly after being stopped.',
|
|
167
|
+
fix: 'Check pod restart count and crash reasons: dailey processes <project>\nCheck if the latest deploy succeeded: dailey deploy-status <project>',
|
|
168
|
+
severity: 'warn',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
];
|
|
172
|
+
|
|
35
173
|
async function resolveProjectId(
|
|
36
174
|
projectOrSlug: string,
|
|
37
175
|
): Promise<{ id: string | null; matched_by: 'id' | 'slug' | 'name' | 'none'; hint?: string }> {
|
|
@@ -275,6 +413,46 @@ async function checkRecentErrors(projectId: string): Promise<Lane> {
|
|
|
275
413
|
};
|
|
276
414
|
}
|
|
277
415
|
|
|
416
|
+
async function checkKnownPatterns(projectId: string): Promise<Lane> {
|
|
417
|
+
const res = await apiRequest<{ logs?: string[] }>('GET', `/projects/${projectId}/logs?tail=100`);
|
|
418
|
+
if (!res.ok) {
|
|
419
|
+
return { name: 'known_issues', status: 'skip', summary: 'No logs available to scan for known issues.' };
|
|
420
|
+
}
|
|
421
|
+
const lines = res.data.logs || [];
|
|
422
|
+
const logText = lines.join('\n');
|
|
423
|
+
|
|
424
|
+
const matched: KnownIssue[] = [];
|
|
425
|
+
const seen = new Set<string>();
|
|
426
|
+
for (const rule of KNOWN_PATTERNS) {
|
|
427
|
+
if (rule.pattern.test(logText) && !seen.has(rule.issue.id)) {
|
|
428
|
+
seen.add(rule.issue.id);
|
|
429
|
+
matched.push(rule.issue);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (matched.length === 0) {
|
|
434
|
+
return { name: 'known_issues', status: 'ok', summary: 'No known crash patterns detected in last 100 log lines.' };
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
const hasFail = matched.some((i) => i.severity === 'fail');
|
|
438
|
+
const laneStatus: LaneStatus = hasFail ? 'fail' : 'warn';
|
|
439
|
+
const names = matched.map((i) => i.name).join('; ');
|
|
440
|
+
|
|
441
|
+
return {
|
|
442
|
+
name: 'known_issues',
|
|
443
|
+
status: laneStatus,
|
|
444
|
+
summary: `${matched.length} known issue(s) detected: ${names}`,
|
|
445
|
+
detail: {
|
|
446
|
+
issues: matched.map((i) => ({
|
|
447
|
+
id: i.id,
|
|
448
|
+
name: i.name,
|
|
449
|
+
plain_english: i.plain_english,
|
|
450
|
+
fix: i.fix,
|
|
451
|
+
})),
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
278
456
|
function aggregateVerdict(lanes: Lane[]): { verdict: 'healthy' | 'degraded' | 'broken'; summary: string } {
|
|
279
457
|
const hasFail = lanes.some((l) => l.status === 'fail');
|
|
280
458
|
const hasWarn = lanes.some((l) => l.status === 'warn');
|
|
@@ -362,6 +540,11 @@ export function registerDiagnoseTools(server: McpServer) {
|
|
|
362
540
|
status: 'fail' as LaneStatus,
|
|
363
541
|
summary: `lane crashed: ${err.message}`,
|
|
364
542
|
})),
|
|
543
|
+
checkKnownPatterns(projectId).catch((err) => ({
|
|
544
|
+
name: 'known_issues',
|
|
545
|
+
status: 'fail' as LaneStatus,
|
|
546
|
+
summary: `lane crashed: ${err.message}`,
|
|
547
|
+
})),
|
|
365
548
|
]);
|
|
366
549
|
|
|
367
550
|
const { verdict, summary } = aggregateVerdict(lanes);
|
package/src/tools/projects.ts
CHANGED
|
@@ -26,7 +26,9 @@ export function registerProjectTools(server: McpServer) {
|
|
|
26
26
|
|
|
27
27
|
const projects = res.data.projects;
|
|
28
28
|
if (!projects || projects.length === 0) {
|
|
29
|
-
return textResult(
|
|
29
|
+
return textResult(
|
|
30
|
+
`No projects found.\n\nNew to Dailey OS? Call dailey_buddy to get started — it can deploy the blog template (covers every DOS feature in ~30 min) or help you get your own app running.`,
|
|
31
|
+
);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
// Include slug — when multiple projects share a name (common with
|