snow-flow 8.37.26 → 8.38.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 (41) hide show
  1. package/.snow-code/agent/deployment-specialist.md +346 -0
  2. package/.snow-code/agent/orchestrator.md +286 -0
  3. package/.snow-code/agent/risk-assessor.md +454 -0
  4. package/.snow-code/agent/solution-architect.md +582 -0
  5. package/.snow-code/agent/validator.md +503 -0
  6. package/.snow-code/opencode.json +49 -0
  7. package/README.md +141 -904
  8. package/dist/cli.d.ts.map +1 -1
  9. package/dist/cli.js +93 -256
  10. package/dist/cli.js.map +1 -1
  11. package/dist/utils/sync-mcp-configs.d.ts +7 -5
  12. package/dist/utils/sync-mcp-configs.d.ts.map +1 -1
  13. package/dist/utils/sync-mcp-configs.js +19 -74
  14. package/dist/utils/sync-mcp-configs.js.map +1 -1
  15. package/package.json +2 -3
  16. package/scripts/check-binary-updates.js +0 -169
  17. package/scripts/check-npm-version.js +0 -92
  18. package/scripts/classify-all-tools.ts +0 -446
  19. package/scripts/classify-edge-cases.ts +0 -275
  20. package/scripts/classify-operations-tools.sh +0 -96
  21. package/scripts/cleanup-mcp-servers.js +0 -115
  22. package/scripts/diagnose-mcp.js +0 -299
  23. package/scripts/generate-mcp-config.js +0 -45
  24. package/scripts/mcp-server-manager.sh +0 -320
  25. package/scripts/postinstall.js +0 -75
  26. package/scripts/reset-mcp-servers.js +0 -266
  27. package/scripts/safe-mcp-cleanup.js +0 -151
  28. package/scripts/setup-mcp.js +0 -106
  29. package/scripts/start-mcp-proper.js +0 -76
  30. package/scripts/start-snowcode.sh +0 -123
  31. package/scripts/start-sysprops-mcp.js +0 -43
  32. package/scripts/sync-snow-code-version.js +0 -74
  33. package/scripts/test-auth-flow.js +0 -172
  34. package/scripts/test-auth-location-fix.js +0 -84
  35. package/scripts/test-mcp-manual.js +0 -140
  36. package/scripts/test-todowrite-timeout.js +0 -108
  37. package/scripts/update-dependencies.js +0 -90
  38. package/scripts/update-mcp-config.js +0 -96
  39. package/scripts/update-snow-code.js +0 -146
  40. package/scripts/verify-snowcode-fork.sh +0 -141
  41. package/templates/snow-code-package.json +0 -3
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // Gracefully handle missing dependencies in restricted environments
4
- try {
5
- const fs = require('fs');
6
- const path = require('path');
7
- const os = require('os');
8
-
9
- console.log('šŸš€ Setting up Snow-Flow...');
10
-
11
- // Fix binary permissions (critical for containers/codespaces)
12
- try {
13
- const platforms = [
14
- 'snow-code-darwin-arm64',
15
- 'snow-code-darwin-x64',
16
- 'snow-code-linux-arm64',
17
- 'snow-code-linux-x64',
18
- 'snow-code-windows-x64'
19
- ];
20
-
21
- // Try both global and local node_modules locations
22
- const locations = [
23
- path.join(__dirname, '..', 'node_modules'),
24
- path.join(process.cwd(), 'node_modules'),
25
- path.join(os.homedir(), '.npm', '_npx', 'node_modules')
26
- ];
27
-
28
- platforms.forEach(platform => {
29
- locations.forEach(location => {
30
- const binaryPath = path.join(location, '@groeimetai', platform, 'bin', 'snow-code');
31
- if (fs.existsSync(binaryPath)) {
32
- try {
33
- fs.chmodSync(binaryPath, 0o755);
34
- console.log(`āœ… Fixed permissions for ${platform}`);
35
- } catch (err) {
36
- // Silently continue if chmod fails
37
- }
38
- }
39
- });
40
- });
41
- } catch (error) {
42
- // Continue silently if permission fixing fails
43
- }
44
-
45
- // Check if we're in a global install
46
- const isGlobalInstall = process.env.npm_config_global === 'true' ||
47
- process.env.npm_config_global === true;
48
-
49
- if (isGlobalInstall) {
50
- console.log('āœ… Snow-Flow installed globally');
51
- console.log('šŸ“ Run "snow-flow init" in your project directory to initialize');
52
-
53
- // Create global config directory
54
- try {
55
- const globalConfigDir = path.join(os.homedir(), '.snow-flow');
56
- if (!fs.existsSync(globalConfigDir)) {
57
- fs.mkdirSync(globalConfigDir, { recursive: true });
58
- console.log(`āœ… Created global config directory at ${globalConfigDir}`);
59
- }
60
- } catch (err) {
61
- // Silently fail if can't create directory
62
- }
63
- } else {
64
- // Local installation - don't create directories automatically
65
- console.log('āœ… Snow-Flow installed locally');
66
- console.log('šŸ”§ Run "snow-flow init" to initialize your project');
67
- }
68
-
69
- console.log('\nšŸ“š Documentation: https://github.com/groeimetai/snow-flow#readme');
70
- console.log('šŸ†˜ Get help: snow-flow --help');
71
- } catch (error) {
72
- // Silently fail in restricted environments (Docker, Cloud Build, etc.)
73
- // The || true in package.json postinstall ensures installation continues
74
- process.exit(0);
75
- }
@@ -1,266 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Reset MCP Servers Script
5
- * Kills all running MCP processes and optionally restarts them
6
- */
7
-
8
- const { exec, spawn } = require('child_process');
9
- const os = require('os');
10
- const path = require('path');
11
- const fs = require('fs');
12
-
13
- // Colors for console output
14
- const colors = {
15
- reset: '\x1b[0m',
16
- red: '\x1b[31m',
17
- green: '\x1b[32m',
18
- yellow: '\x1b[33m',
19
- blue: '\x1b[34m',
20
- magenta: '\x1b[35m',
21
- cyan: '\x1b[36m'
22
- };
23
-
24
- function log(message, color = 'reset') {
25
- console.log(`${colors[color]}${message}${colors.reset}`);
26
- }
27
-
28
- function logStep(step, message) {
29
- console.log(`${colors.cyan}[${step}]${colors.reset} ${message}`);
30
- }
31
-
32
- // Get platform-specific commands
33
- function getKillCommand() {
34
- const platform = os.platform();
35
- if (platform === 'win32') {
36
- return {
37
- list: 'wmic process where "commandline like \'%servicenow-%mcp%\'" get processid,commandline',
38
- kill: (pid) => `taskkill /F /PID ${pid}`
39
- };
40
- } else {
41
- return {
42
- list: "ps aux | grep -E 'servicenow-.*-mcp' | grep -v grep",
43
- kill: (pid) => `kill -9 ${pid}`
44
- };
45
- }
46
- }
47
-
48
- // Kill all MCP processes
49
- async function killMCPProcesses() {
50
- return new Promise((resolve) => {
51
- logStep('1/4', 'Finding running MCP processes...');
52
-
53
- const commands = getKillCommand();
54
-
55
- exec(commands.list, (error, stdout, stderr) => {
56
- if (error && !stderr) {
57
- log('No MCP processes found running.', 'green');
58
- resolve(0);
59
- return;
60
- }
61
-
62
- const lines = stdout.split('\n').filter(line => line.trim());
63
- let killed = 0;
64
-
65
- if (os.platform() === 'win32') {
66
- // Windows: Extract PIDs from wmic output
67
- lines.forEach(line => {
68
- const match = line.match(/(\d+)\s*$/);
69
- if (match) {
70
- const pid = match[1];
71
- exec(commands.kill(pid), (err) => {
72
- if (!err) {
73
- log(` āœ“ Killed process ${pid}`, 'yellow');
74
- killed++;
75
- }
76
- });
77
- }
78
- });
79
- } else {
80
- // Unix-like: Extract PIDs from ps output
81
- lines.forEach(line => {
82
- const parts = line.trim().split(/\s+/);
83
- if (parts.length > 1) {
84
- const pid = parts[1];
85
- exec(commands.kill(pid), (err) => {
86
- if (!err) {
87
- log(` āœ“ Killed process ${pid}`, 'yellow');
88
- killed++;
89
- }
90
- });
91
- }
92
- });
93
- }
94
-
95
- setTimeout(() => {
96
- if (killed > 0) {
97
- log(`Killed ${killed} MCP processes.`, 'green');
98
- }
99
- resolve(killed);
100
- }, 1000);
101
- });
102
- });
103
- }
104
-
105
- // Clear temporary files and cache
106
- async function clearCache() {
107
- logStep('2/4', 'Clearing MCP cache and temporary files...');
108
-
109
- const cacheLocations = [
110
- path.join(os.homedir(), '.snow-flow', 'mcp-cache'),
111
- path.join(os.homedir(), '.snow-flow', 'memory', '*.lock'),
112
- path.join(process.cwd(), '.mcp-temp'),
113
- path.join(process.cwd(), 'dist', 'mcp', '*.lock')
114
- ];
115
-
116
- let cleared = 0;
117
-
118
- cacheLocations.forEach(location => {
119
- try {
120
- if (location.includes('*')) {
121
- // Handle glob patterns
122
- const dir = path.dirname(location);
123
- const pattern = path.basename(location);
124
- if (fs.existsSync(dir)) {
125
- const files = fs.readdirSync(dir);
126
- files.forEach(file => {
127
- if (file.match(pattern.replace('*', '.*'))) {
128
- fs.unlinkSync(path.join(dir, file));
129
- cleared++;
130
- }
131
- });
132
- }
133
- } else if (fs.existsSync(location)) {
134
- // Handle directories
135
- fs.rmSync(location, { recursive: true, force: true });
136
- cleared++;
137
- }
138
- } catch (error) {
139
- // Ignore errors for non-existent files
140
- }
141
- });
142
-
143
- if (cleared > 0) {
144
- log(` āœ“ Cleared ${cleared} cache locations`, 'green');
145
- } else {
146
- log(' āœ“ No cache files found to clear', 'green');
147
- }
148
- }
149
-
150
- // Verify no processes are running
151
- async function verifyClean() {
152
- return new Promise((resolve) => {
153
- logStep('3/4', 'Verifying all MCP processes are stopped...');
154
-
155
- const commands = getKillCommand();
156
-
157
- exec(commands.list, (error, stdout) => {
158
- if (error || !stdout.trim()) {
159
- log(' āœ“ All MCP processes successfully stopped', 'green');
160
- resolve(true);
161
- } else {
162
- log(' ⚠ Some MCP processes may still be running', 'yellow');
163
- resolve(false);
164
- }
165
- });
166
- });
167
- }
168
-
169
- // Restart MCP servers if requested
170
- async function restartServers() {
171
- logStep('4/4', 'Restarting MCP servers using proper MCPServerManager...');
172
-
173
- const properStarterPath = path.join(__dirname, 'start-mcp-proper.js');
174
-
175
- if (!fs.existsSync(properStarterPath)) {
176
- log(' ⚠ Proper MCP starter not found. Run "npm run build" first.', 'yellow');
177
- return;
178
- }
179
-
180
- log(' Starting MCP servers with singleton protection...', 'cyan');
181
-
182
- try {
183
- // Use the proper MCPServerManager approach
184
- const child = spawn('node', [properStarterPath], {
185
- detached: true,
186
- stdio: ['ignore', 'pipe', 'pipe']
187
- });
188
-
189
- // Log startup messages
190
- child.stdout?.on('data', (data) => {
191
- log(` ${data.toString().trim()}`, 'green');
192
- });
193
-
194
- child.stderr?.on('data', (data) => {
195
- log(` Error: ${data.toString().trim()}`, 'red');
196
- });
197
-
198
- child.unref();
199
-
200
- // Give it time to start
201
- await new Promise(resolve => setTimeout(resolve, 2000));
202
-
203
- log(' āœ… MCP servers started with proper management!', 'green');
204
- log(' šŸ’” No more duplicate servers or memory issues!', 'cyan');
205
-
206
- } catch (error) {
207
- log(` āŒ Failed to start MCP servers: ${error.message}`, 'red');
208
- log(' šŸ”§ Try: npm run cleanup-mcp', 'yellow');
209
- }
210
- log('\n To view logs, check ~/.snow-flow/logs/', 'cyan');
211
- }
212
-
213
- // Main execution
214
- async function main() {
215
- console.log('\n' + colors.magenta + 'šŸ”„ Snow-Flow MCP Server Reset' + colors.reset + '\n');
216
-
217
- const args = process.argv.slice(2);
218
- const shouldRestart = args.includes('--restart') || args.includes('-r');
219
-
220
- try {
221
- // Kill processes
222
- await killMCPProcesses();
223
-
224
- // Clear cache
225
- await clearCache();
226
-
227
- // Verify clean
228
- await verifyClean();
229
-
230
- // Restart if requested
231
- if (shouldRestart) {
232
- await restartServers();
233
- } else {
234
- log('\nāœ… MCP servers reset complete!', 'green');
235
- log('To restart servers, run: npm run reset-mcp -- --restart', 'cyan');
236
- }
237
-
238
- } catch (error) {
239
- log(`\nāŒ Error resetting MCP servers: ${error.message}`, 'red');
240
- process.exit(1);
241
- }
242
- }
243
-
244
- // Help text
245
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
246
- console.log(`
247
- ${colors.cyan}Snow-Flow MCP Server Reset${colors.reset}
248
-
249
- Usage: node reset-mcp-servers.js [options]
250
-
251
- Options:
252
- -r, --restart Restart MCP servers after reset
253
- -h, --help Show this help message
254
-
255
- Examples:
256
- node reset-mcp-servers.js # Reset only
257
- node reset-mcp-servers.js --restart # Reset and restart
258
- `);
259
- process.exit(0);
260
- }
261
-
262
- // Run the script
263
- main().catch(error => {
264
- log(`Fatal error: ${error.message}`, 'red');
265
- process.exit(1);
266
- });
@@ -1,151 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Safe MCP Cleanup Script
5
- * Manual cleanup for MCP servers without causing memory crashes
6
- */
7
-
8
- const { execSync } = require('child_process');
9
- const readline = require('readline');
10
-
11
- const rl = readline.createInterface({
12
- input: process.stdin,
13
- output: process.stdout
14
- });
15
-
16
- function getProcesses() {
17
- try {
18
- const output = execSync('ps aux | grep -E "mcp|servicenow.*mcp" | grep -v grep', {
19
- encoding: 'utf8'
20
- }).trim();
21
-
22
- if (!output) return [];
23
-
24
- const lines = output.split('\n');
25
- const processes = [];
26
-
27
- for (const line of lines) {
28
- const parts = line.split(/\s+/);
29
- if (parts.length > 10) {
30
- processes.push({
31
- pid: parseInt(parts[1]),
32
- memory: Math.round(parseInt(parts[5]) / 1024), // MB
33
- name: parts.slice(10).join(' ').substring(0, 80)
34
- });
35
- }
36
- }
37
-
38
- return processes;
39
- } catch (error) {
40
- return [];
41
- }
42
- }
43
-
44
- async function main() {
45
- console.log('🧹 Safe MCP Cleanup Utility\n');
46
- console.log('āš ļø WARNING: This will terminate MCP server processes');
47
- console.log('Only use if experiencing memory issues or crashes\n');
48
-
49
- const processes = getProcesses();
50
-
51
- if (processes.length === 0) {
52
- console.log('āœ… No MCP processes found');
53
- process.exit(0);
54
- }
55
-
56
- console.log(`Found ${processes.length} MCP processes:\n`);
57
-
58
- // Group by type
59
- const groups = {};
60
- let totalMemory = 0;
61
-
62
- for (const proc of processes) {
63
- const match = proc.name.match(/servicenow-([^-]+)-mcp/);
64
- const type = match ? match[1] : 'other';
65
-
66
- if (!groups[type]) {
67
- groups[type] = [];
68
- }
69
- groups[type].push(proc);
70
- totalMemory += proc.memory;
71
- }
72
-
73
- // Display summary
74
- for (const [type, procs] of Object.entries(groups)) {
75
- const memSum = procs.reduce((sum, p) => sum + p.memory, 0);
76
- console.log(` ${type}: ${procs.length} process(es), ${memSum}MB`);
77
- }
78
-
79
- console.log(`\nTotal memory usage: ${totalMemory}MB`);
80
-
81
- // Ask for confirmation
82
- const answer = await new Promise(resolve => {
83
- rl.question('\nOptions:\n1. Kill ALL MCP processes\n2. Kill duplicates only (keep 1 of each type)\n3. Kill high memory processes (>100MB)\n4. Cancel\n\nChoice (1-4): ', resolve);
84
- });
85
-
86
- switch (answer.trim()) {
87
- case '1':
88
- console.log('\nšŸ”“ Killing ALL MCP processes...');
89
- for (const proc of processes) {
90
- try {
91
- process.kill(proc.pid, 'SIGTERM');
92
- console.log(` Killed PID ${proc.pid}`);
93
- } catch (e) {
94
- // Already dead
95
- }
96
- }
97
- console.log('āœ… All MCP processes terminated');
98
- break;
99
-
100
- case '2':
101
- console.log('\n🟔 Killing duplicate processes...');
102
- for (const [type, procs] of Object.entries(groups)) {
103
- if (procs.length > 1) {
104
- // Keep the first one, kill the rest
105
- for (let i = 1; i < procs.length; i++) {
106
- try {
107
- process.kill(procs[i].pid, 'SIGTERM');
108
- console.log(` Killed duplicate ${type} (PID ${procs[i].pid})`);
109
- } catch (e) {
110
- // Already dead
111
- }
112
- }
113
- }
114
- }
115
- console.log('āœ… Duplicates removed');
116
- break;
117
-
118
- case '3':
119
- console.log('\n🟠 Killing high memory processes...');
120
- const highMem = processes.filter(p => p.memory > 100);
121
- for (const proc of highMem) {
122
- try {
123
- process.kill(proc.pid, 'SIGTERM');
124
- console.log(` Killed PID ${proc.pid} (${proc.memory}MB)`);
125
- } catch (e) {
126
- // Already dead
127
- }
128
- }
129
- console.log('āœ… High memory processes terminated');
130
- break;
131
-
132
- default:
133
- console.log('āŒ Cancelled');
134
- break;
135
- }
136
-
137
- rl.close();
138
-
139
- // Show final status
140
- setTimeout(() => {
141
- console.log('\nšŸ“Š Final status:');
142
- const remaining = getProcesses();
143
- console.log(` Remaining processes: ${remaining.length}`);
144
- if (remaining.length > 0) {
145
- const memSum = remaining.reduce((sum, p) => sum + p.memory, 0);
146
- console.log(` Memory usage: ${memSum}MB`);
147
- }
148
- }, 1000);
149
- }
150
-
151
- main().catch(console.error);
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Dynamic MCP Configuration Generator
4
- * Generates .mcp.json from template with absolute paths and actual environment variables
5
- * This ensures compatibility with Claude Code while keeping the project portable
6
- */
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
- // Try to load .env file if it exists, but don't fail if it doesn't
11
- try {
12
- require('dotenv').config();
13
- } catch (err) {
14
- // .env file not found, that's OK
15
- }
16
-
17
- // Determine if we're in a global npm installation
18
- const isGlobalInstall = __dirname.includes('node_modules/snow-flow') ||
19
- __dirname.includes('.nvm/versions/node');
20
-
21
- // For global installs, use the package directory, not cwd
22
- const packageRoot = isGlobalInstall
23
- ? path.resolve(__dirname, '..') // Go up from scripts/ to package root
24
- : process.cwd();
25
-
26
- // The actual project root where we're running the command
27
- const projectRoot = process.cwd();
28
-
29
- const templatePath = path.join(packageRoot, '.mcp.json.template');
30
- const mcpFilePath = path.join(projectRoot, '.mcp.json');
31
-
32
- // Check if template exists
33
- if (!fs.existsSync(templatePath)) {
34
- console.error('āŒ Error: .mcp.json.template not found!');
35
- console.error(' This file should be in the project root.');
36
- process.exit(1);
37
- }
38
-
39
- // Check if required environment variables are set
40
- const requiredEnvVars = ['SNOW_INSTANCE', 'SNOW_CLIENT_ID', 'SNOW_CLIENT_SECRET'];
41
- const missingVars = requiredEnvVars.filter(varName => !process.env[varName]);
42
-
43
- if (missingVars.length > 0) {
44
- console.warn('āš ļø Warning: Missing environment variables:', missingVars.join(', '));
45
- console.warn(' MCP servers may not work without proper ServiceNow credentials.');
46
- console.warn(' Copy .env.example to .env and configure your ServiceNow credentials.');
47
- }
48
-
49
- // Read template
50
- const template = fs.readFileSync(templatePath, 'utf8');
51
-
52
- // Replace placeholders
53
- const replacements = {
54
- '{{PROJECT_ROOT}}': packageRoot, // Use packageRoot for MCP server paths
55
- '{{SNOW_INSTANCE}}': process.env.SNOW_INSTANCE || 'your-instance.service-now.com',
56
- '{{SNOW_CLIENT_ID}}': process.env.SNOW_CLIENT_ID || 'your-oauth-client-id',
57
- '{{SNOW_CLIENT_SECRET}}': process.env.SNOW_CLIENT_SECRET || 'your-oauth-client-secret',
58
- '{{NEO4J_URI}}': process.env.NEO4J_URI || 'bolt://localhost:7687',
59
- '{{NEO4J_USER}}': process.env.NEO4J_USER || 'neo4j',
60
- '{{NEO4J_PASSWORD}}': process.env.NEO4J_PASSWORD || 'password'
61
- };
62
-
63
- let mcpConfig = template;
64
- for (const [placeholder, value] of Object.entries(replacements)) {
65
- mcpConfig = mcpConfig.replace(new RegExp(placeholder, 'g'), value);
66
- }
67
-
68
- // Write the configuration file
69
- fs.writeFileSync(mcpFilePath, mcpConfig);
70
-
71
- // Make all MCP server files executable
72
- const mcpServerFiles = [
73
- 'servicenow-deployment-mcp.js',
74
- 'servicenow-update-set-mcp.js',
75
- 'servicenow-intelligent-mcp.js',
76
- 'servicenow-graph-memory-mcp.js',
77
- 'servicenow-operations-mcp.js',
78
- 'servicenow-platform-development-mcp.js',
79
- 'servicenow-integration-mcp.js',
80
- 'servicenow-automation-mcp.js',
81
- 'servicenow-security-compliance-mcp.js',
82
- 'servicenow-reporting-analytics-mcp.js',
83
- 'servicenow-memory-mcp.js'
84
- ];
85
-
86
- mcpServerFiles.forEach(file => {
87
- const filePath = path.join(packageRoot, 'dist/mcp', file);
88
- if (fs.existsSync(filePath)) {
89
- fs.chmodSync(filePath, '755');
90
- }
91
- });
92
-
93
- console.log('āœ… Generated .mcp.json with dynamic configuration');
94
- console.log('šŸ“ Project directory:', projectRoot);
95
- console.log('šŸ“¦ Package directory:', packageRoot);
96
- console.log('šŸ”§ Environment variables:', requiredEnvVars.filter(v => process.env[v]).length + '/' + requiredEnvVars.length + ' configured');
97
- console.log('šŸ” Made MCP server files executable');
98
- console.log('šŸ“ Using node + args format for Claude Code compatibility');
99
-
100
- if (missingVars.length === 0) {
101
- console.log('šŸŽ‰ All ServiceNow environment variables are configured!');
102
- console.log('šŸ’” MCP servers should now work properly in Claude Code');
103
- } else {
104
- console.log('āš ļø Configure missing environment variables in .env file');
105
- console.log('šŸ“– See .env.example for setup instructions');
106
- }
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Proper MCP Server Starter using MCPServerManager
5
- * REPLACES the legacy start-all-mcp-servers.ts approach
6
- */
7
-
8
- const path = require('path');
9
-
10
- async function startMCPServersProper() {
11
- console.log('šŸš€ Starting MCP servers using proper MCPServerManager...\n');
12
-
13
- try {
14
- // Import the proper MCPServerManager
15
- const { MCPServerManager } = require('../dist/utils/mcp-server-manager.js');
16
-
17
- // Initialize manager
18
- const manager = new MCPServerManager();
19
- await manager.initialize();
20
-
21
- console.log('šŸ“‹ Initializing MCP server configuration...');
22
-
23
- // Start all servers with singleton protection built-in
24
- await manager.startAllServers();
25
-
26
- console.log('āœ… All MCP servers started successfully!\n');
27
- console.log('šŸ“Š Server Status:');
28
-
29
- // Show server status
30
- const servers = manager.getServerList();
31
- for (const server of servers) {
32
- const status = server.status === 'running' ? '🟢' :
33
- server.status === 'starting' ? '🟔' :
34
- server.status === 'error' ? 'šŸ”“' : '⚫';
35
- console.log(` ${status} ${server.name}: ${server.status}`);
36
- }
37
-
38
- console.log('\nšŸ’” Benefits of using MCPServerManager:');
39
- console.log(' • āœ… Singleton protection (no duplicates)');
40
- console.log(' • āœ… Process lifecycle management');
41
- console.log(' • āœ… Configuration management');
42
- console.log(' • āœ… Proper logging and monitoring');
43
- console.log(' • āœ… Graceful shutdown handling');
44
- console.log(' • āœ… OAuth integration');
45
-
46
- console.log('\nšŸ”§ Management commands:');
47
- console.log(' • Status: manager.getServerStatus()');
48
- console.log(' • Stop: manager.stopAllServers()');
49
- console.log(' • Restart: manager.restartServer(name)');
50
-
51
- // Keep process alive to monitor servers
52
- process.on('SIGINT', async () => {
53
- console.log('\nšŸ›‘ Gracefully shutting down all MCP servers...');
54
- await manager.stopAllServers();
55
- console.log('āœ… All servers stopped. Goodbye!');
56
- process.exit(0);
57
- });
58
-
59
- console.log('\nā³ MCP servers running. Press Ctrl+C to stop.');
60
-
61
- } catch (error) {
62
- console.error('āŒ Failed to start MCP servers:', error.message);
63
- console.error('\nšŸ”§ Troubleshooting:');
64
- console.error(' 1. Run "npm run build" first');
65
- console.error(' 2. Check if servers are already running');
66
- console.error(' 3. Run "npm run cleanup-mcp" to clean state');
67
- process.exit(1);
68
- }
69
- }
70
-
71
- // Run if executed directly
72
- if (require.main === module) {
73
- startMCPServersProper().catch(console.error);
74
- }
75
-
76
- module.exports = { startMCPServersProper };