scanwarp 0.3.2 → 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/dist/integrations/mcp.js +53 -19
- 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
|
+
}
|
package/dist/integrations/mcp.js
CHANGED
|
@@ -11,28 +11,63 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
11
11
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
12
12
|
async function setupMCP(serverUrl) {
|
|
13
13
|
const homeDir = os_1.default.homedir();
|
|
14
|
-
|
|
15
|
-
const
|
|
14
|
+
// Detect operating system and set config paths
|
|
15
|
+
const platform = os_1.default.platform();
|
|
16
|
+
let cursorConfigPath;
|
|
17
|
+
let claudeConfigPath;
|
|
18
|
+
let claudeCodeConfigPath;
|
|
19
|
+
if (platform === 'darwin') {
|
|
20
|
+
// macOS
|
|
21
|
+
cursorConfigPath = path_1.default.join(homeDir, '.cursor', 'mcp.json');
|
|
22
|
+
claudeConfigPath = path_1.default.join(homeDir, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
|
|
23
|
+
claudeCodeConfigPath = path_1.default.join(homeDir, '.config', 'claude-code', 'mcp.json');
|
|
24
|
+
}
|
|
25
|
+
else if (platform === 'win32') {
|
|
26
|
+
// Windows
|
|
27
|
+
cursorConfigPath = path_1.default.join(homeDir, '.cursor', 'mcp.json');
|
|
28
|
+
claudeConfigPath = path_1.default.join(homeDir, 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json');
|
|
29
|
+
claudeCodeConfigPath = path_1.default.join(homeDir, '.config', 'claude-code', 'mcp.json');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// Linux
|
|
33
|
+
cursorConfigPath = path_1.default.join(homeDir, '.cursor', 'mcp.json');
|
|
34
|
+
claudeConfigPath = path_1.default.join(homeDir, '.config', 'Claude', 'claude_desktop_config.json');
|
|
35
|
+
claudeCodeConfigPath = path_1.default.join(homeDir, '.config', 'claude-code', 'mcp.json');
|
|
36
|
+
}
|
|
16
37
|
let configPath = null;
|
|
17
|
-
|
|
38
|
+
let toolName = '';
|
|
39
|
+
// Detect which config exists (or create default)
|
|
18
40
|
if (fs_1.default.existsSync(cursorConfigPath)) {
|
|
19
41
|
configPath = cursorConfigPath;
|
|
42
|
+
toolName = 'Cursor';
|
|
20
43
|
console.log(chalk_1.default.green('✓ Detected Cursor'));
|
|
21
44
|
}
|
|
45
|
+
else if (fs_1.default.existsSync(claudeCodeConfigPath)) {
|
|
46
|
+
configPath = claudeCodeConfigPath;
|
|
47
|
+
toolName = 'Claude Code';
|
|
48
|
+
console.log(chalk_1.default.green('✓ Detected Claude Code'));
|
|
49
|
+
}
|
|
22
50
|
else if (fs_1.default.existsSync(claudeConfigPath)) {
|
|
23
51
|
configPath = claudeConfigPath;
|
|
52
|
+
toolName = 'Claude Desktop';
|
|
24
53
|
console.log(chalk_1.default.green('✓ Detected Claude Desktop'));
|
|
25
54
|
}
|
|
26
55
|
if (!configPath) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
56
|
+
// No config found - try to create one for Claude Code (most common for CLI users)
|
|
57
|
+
configPath = claudeCodeConfigPath;
|
|
58
|
+
toolName = 'Claude Code';
|
|
59
|
+
console.log(chalk_1.default.yellow('⚠ No MCP config found, creating default for Claude Code'));
|
|
60
|
+
// Ensure directory exists
|
|
61
|
+
const configDir = path_1.default.dirname(configPath);
|
|
62
|
+
if (!fs_1.default.existsSync(configDir)) {
|
|
63
|
+
fs_1.default.mkdirSync(configDir, { recursive: true });
|
|
64
|
+
}
|
|
30
65
|
}
|
|
31
66
|
const { addMcp } = await inquirer_1.default.prompt([
|
|
32
67
|
{
|
|
33
68
|
type: 'confirm',
|
|
34
69
|
name: 'addMcp',
|
|
35
|
-
message:
|
|
70
|
+
message: `Add ScanWarp MCP server to ${toolName}?`,
|
|
36
71
|
default: true,
|
|
37
72
|
},
|
|
38
73
|
]);
|
|
@@ -51,18 +86,16 @@ async function setupMCP(serverUrl) {
|
|
|
51
86
|
if (!config.mcpServers) {
|
|
52
87
|
config.mcpServers = {};
|
|
53
88
|
}
|
|
89
|
+
// Use npx to run the published package - works anywhere
|
|
54
90
|
config.mcpServers.scanwarp = {
|
|
55
|
-
command: '
|
|
56
|
-
args: [
|
|
57
|
-
env: {
|
|
58
|
-
SCANWARP_SERVER_URL: serverUrl,
|
|
59
|
-
},
|
|
91
|
+
command: 'npx',
|
|
92
|
+
args: ['-y', 'scanwarp', 'mcp', '--server', serverUrl],
|
|
60
93
|
};
|
|
61
94
|
// Write config
|
|
62
95
|
fs_1.default.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
63
|
-
console.log(chalk_1.default.green(
|
|
96
|
+
console.log(chalk_1.default.green(`✓ MCP server added to ${toolName} configuration`));
|
|
64
97
|
console.log(chalk_1.default.gray(` Config: ${configPath}\n`));
|
|
65
|
-
console.log(chalk_1.default.yellow(
|
|
98
|
+
console.log(chalk_1.default.yellow(` Restart ${toolName} to load the MCP server\n`));
|
|
66
99
|
}
|
|
67
100
|
catch (error) {
|
|
68
101
|
console.log(chalk_1.default.red('✗ Failed to update MCP config'));
|
|
@@ -76,12 +109,13 @@ function printManualInstructions(serverUrl) {
|
|
|
76
109
|
console.log(chalk_1.default.cyan(' {'));
|
|
77
110
|
console.log(chalk_1.default.cyan(' "mcpServers": {'));
|
|
78
111
|
console.log(chalk_1.default.cyan(' "scanwarp": {'));
|
|
79
|
-
console.log(chalk_1.default.cyan(' "command": "
|
|
80
|
-
console.log(chalk_1.default.cyan(
|
|
81
|
-
console.log(chalk_1.default.cyan(' "env": {'));
|
|
82
|
-
console.log(chalk_1.default.cyan(` "SCANWARP_SERVER_URL": "${serverUrl}"`));
|
|
83
|
-
console.log(chalk_1.default.cyan(' }'));
|
|
112
|
+
console.log(chalk_1.default.cyan(' "command": "npx",'));
|
|
113
|
+
console.log(chalk_1.default.cyan(` "args": ["-y", "scanwarp", "mcp", "--server", "${serverUrl}"]`));
|
|
84
114
|
console.log(chalk_1.default.cyan(' }'));
|
|
85
115
|
console.log(chalk_1.default.cyan(' }'));
|
|
86
116
|
console.log(chalk_1.default.cyan(' }\n'));
|
|
117
|
+
console.log(chalk_1.default.gray(' Config file locations:'));
|
|
118
|
+
console.log(chalk_1.default.gray(' • Cursor: ~/.cursor/mcp.json'));
|
|
119
|
+
console.log(chalk_1.default.gray(' • Claude Code: ~/.config/claude-code/mcp.json'));
|
|
120
|
+
console.log(chalk_1.default.gray(' • Claude Desktop (macOS): ~/Library/Application Support/Claude/claude_desktop_config.json\n'));
|
|
87
121
|
}
|