scanwarp 0.3.3 → 0.3.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.
- package/dist/commands/mcp.js +38 -1
- package/package.json +1 -1
package/dist/commands/mcp.js
CHANGED
|
@@ -20,7 +20,7 @@ async function mcpCommand(options = {}) {
|
|
|
20
20
|
// Create MCP server
|
|
21
21
|
const server = new index_js_1.Server({
|
|
22
22
|
name: 'scanwarp',
|
|
23
|
-
version: '0.3.
|
|
23
|
+
version: '0.3.3',
|
|
24
24
|
}, {
|
|
25
25
|
capabilities: {
|
|
26
26
|
tools: {},
|
|
@@ -376,5 +376,42 @@ async function mcpCommand(options = {}) {
|
|
|
376
376
|
console.error(`Connected to: ${serverUrl}`);
|
|
377
377
|
if (projectId) {
|
|
378
378
|
console.error(`Default project: ${projectId}`);
|
|
379
|
+
// Poll for new incidents and send notifications
|
|
380
|
+
startIncidentPolling(server, api, projectId);
|
|
379
381
|
}
|
|
380
382
|
}
|
|
383
|
+
// Poll for new incidents and log alerts
|
|
384
|
+
function startIncidentPolling(_server, api, projectId) {
|
|
385
|
+
const seenIncidents = new Set();
|
|
386
|
+
const poll = async () => {
|
|
387
|
+
try {
|
|
388
|
+
const incidents = await api.getIncidents({
|
|
389
|
+
projectId,
|
|
390
|
+
status: 'open'
|
|
391
|
+
});
|
|
392
|
+
for (const incident of incidents) {
|
|
393
|
+
// New incident detected
|
|
394
|
+
if (!seenIncidents.has(incident.id)) {
|
|
395
|
+
seenIncidents.add(incident.id);
|
|
396
|
+
// Log alert to stderr (visible in Claude Code output)
|
|
397
|
+
const message = incident.diagnosis_text
|
|
398
|
+
? `🚨 New incident: ${incident.diagnosis_text.slice(0, 100)}...`
|
|
399
|
+
: `🚨 New ${incident.severity} incident detected with ${incident.events?.length || 0} event(s)`;
|
|
400
|
+
console.error(`\n[ALERT] ${message}`);
|
|
401
|
+
console.error(`[ALERT] Incident ID: ${incident.id}`);
|
|
402
|
+
console.error(`[ALERT] Severity: ${incident.severity}`);
|
|
403
|
+
if (incident.diagnosis_text) {
|
|
404
|
+
console.error(`[ALERT] Diagnosis: ${incident.diagnosis_text}\n`);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
console.error('[Polling] Error checking incidents:', error instanceof Error ? error.message : error);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
// Poll every 30 seconds
|
|
414
|
+
setInterval(poll, 30000);
|
|
415
|
+
// Initial poll
|
|
416
|
+
poll();
|
|
417
|
+
}
|