UNPKG

csvlod-ai-mcp-server

Version:

CSVLOD-AI MCP Server v3.0 with Quantum Context Intelligence - Revolutionary Context Intelligence Engine and Multimodal Processor for sovereign AI development

540 lines (455 loc) 17.6 kB
#!/usr/bin/env node /** * CSVLOD-AI MCP Tools Installation Wizard * * A sovereignty-first installation experience that: * - Respects user choice and provides full transparency * - Offers clear sovereignty implications for each option * - Enables easy IDE integration with complete user control * - Provides opt-in telemetry with full data ownership * * Philosophy: "Installation should enhance sovereignty, not compromise it" */ import readline from 'readline'; import fs from 'fs'; import path from 'path'; import { execSync } from 'child_process'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Console styling for better UX const colors = { cyan: '\x1b[36m', green: '\x1b[32m', yellow: '\x1b[33m', red: '\x1b[31m', blue: '\x1b[34m', magenta: '\x1b[35m', reset: '\x1b[0m', bold: '\x1b[1m', dim: '\x1b[2m' }; class CSVLODInstaller { constructor() { this.rl = readline.createInterface({ input: process.stdin, output: process.stdout }); this.config = { sovereigntyLevel: 'high', // high, medium, basic ideChoice: null, projectType: 'individual', // individual, enterprise, minimal telemetryOptIn: false, dataLocation: 'local', // local, cloud, hybrid installLocation: process.cwd() }; } async start() { console.clear(); this.printHeader(); try { await this.welcomeMessage(); await this.sovereigntyAssessment(); await this.ideSelection(); await this.projectTypeSelection(); await this.telemetryConsent(); await this.dataLocationChoice(); await this.confirmInstallation(); await this.performInstallation(); await this.postInstallGuidance(); } catch (error) { console.error(`${colors.red}Installation failed:${colors.reset}`, error.message); console.log(`${colors.yellow}Please report issues at: https://github.com/hamzaamjad/csvlod-ai-framework/issues${colors.reset}`); } finally { this.rl.close(); } } printHeader() { console.log(`${colors.cyan}${colors.bold} ╔══════════════════════════════════════════════════════════════╗ ║ CSVLOD-AI MCP Tools ║ ║ Sovereignty-First Installation ║ ║ ║ ║ 🚀 12 Production-Ready MCP Tools ║ ║ 🛡️ Complete User Control & Data Ownership ║ ║ ⚡ 10x AI Effectiveness Through Context Engineering ║ ╚══════════════════════════════════════════════════════════════╝ ${colors.reset}`); } async welcomeMessage() { console.log(`${colors.green} Welcome to the CSVLOD-AI Framework installation! This wizard respects your digital sovereignty by: ✓ Providing complete transparency about what's installed ✓ Offering granular control over data and privacy settings ✓ Enabling easy uninstallation and configuration changes ✓ Never making decisions without your explicit consent Let's configure your AI-native development environment... ${colors.reset}`); await this.waitForEnter(); } async sovereigntyAssessment() { console.log(`${colors.blue}${colors.bold} 📊 SOVEREIGNTY ASSESSMENT ${colors.reset} Choose your preferred sovereignty level: ${colors.green}1. HIGH SOVEREIGNTY${colors.reset} • All data stays local • No external connections except explicit user requests • Complete audit trails of all AI decisions • Maximum privacy and control ${colors.yellow}2. MEDIUM SOVEREIGNTY${colors.reset} • Local-first with optional cloud features • Anonymous usage metrics (with your consent) • Enhanced collaboration capabilities • Balanced privacy and functionality ${colors.blue}3. BASIC SOVEREIGNTY${colors.reset} • Standard configuration with privacy protection • Some cloud integration for enhanced features • Transparent data handling • Good privacy with maximum convenience `); const choice = await this.askQuestion('Select sovereignty level (1-3): '); switch (choice) { case '1': this.config.sovereigntyLevel = 'high'; console.log(`${colors.green}✓ High sovereignty selected - Maximum privacy and control${colors.reset}`); break; case '2': this.config.sovereigntyLevel = 'medium'; console.log(`${colors.yellow}✓ Medium sovereignty selected - Balanced approach${colors.reset}`); break; case '3': this.config.sovereigntyLevel = 'basic'; console.log(`${colors.blue}✓ Basic sovereignty selected - Enhanced convenience${colors.reset}`); break; default: console.log(`${colors.yellow}Invalid choice, defaulting to High Sovereignty${colors.reset}`); this.config.sovereigntyLevel = 'high'; } } async ideSelection() { console.log(`${colors.blue}${colors.bold} 🔧 IDE INTEGRATION ${colors.reset} Select your development environment: ${colors.cyan}1. Cursor${colors.reset} (Recommended) • Native MCP support • Optimized for AI-native development • Best CSVLOD integration ${colors.green}2. VS Code${colors.reset} • Popular editor with MCP extension • Good community support • Solid CSVLOD integration ${colors.blue}3. Generic MCP Client${colors.reset} • Custom configuration • Manual setup required • Maximum flexibility ${colors.yellow}4. Multiple IDEs${colors.reset} • Install configurations for all supported IDEs • Choose later based on project needs `); const choice = await this.askQuestion('Select IDE (1-4): '); const ideMap = { '1': 'cursor', '2': 'vscode', '3': 'generic', '4': 'multiple' }; this.config.ideChoice = ideMap[choice] || 'cursor'; console.log(`${colors.green}✓ IDE selection: ${this.config.ideChoice}${colors.reset}`); } async projectTypeSelection() { console.log(`${colors.blue}${colors.bold} 🏗️ PROJECT TYPE ${colors.reset} Choose your use case: ${colors.green}1. Individual Developer${colors.reset} • Personal projects and learning • Streamlined setup • Basic collaboration features ${colors.blue}2. Enterprise/Team${colors.reset} • Multi-developer environments • Advanced security features • Team coordination tools • Audit and compliance support ${colors.yellow}3. Minimal Setup${colors.reset} • Core tools only • Lightweight installation • Fastest setup `); const choice = await this.askQuestion('Select project type (1-3): '); const typeMap = { '1': 'individual', '2': 'enterprise', '3': 'minimal' }; this.config.projectType = typeMap[choice] || 'individual'; console.log(`${colors.green}✓ Project type: ${this.config.projectType}${colors.reset}`); } async telemetryConsent() { if (this.config.sovereigntyLevel === 'high') { console.log(`${colors.green}✓ High sovereignty: Telemetry disabled by default${colors.reset}`); this.config.telemetryOptIn = false; return; } console.log(`${colors.blue}${colors.bold} 📊 PRIVACY & TELEMETRY ${colors.reset} Would you like to contribute anonymous usage data to improve CSVLOD-AI? ${colors.green}What we collect (if you opt-in):${colors.reset} • Tool usage frequency (no sensitive data) • Performance metrics (response times, success rates) • Error types (anonymized, no code content) • Feature usage patterns ${colors.red}What we NEVER collect:${colors.reset} • Your code or project content • Personal information • File names or paths • Specific AI interactions ${colors.cyan}Your data sovereignty:${colors.reset} • Stored locally first, sent anonymously • Easy opt-out anytime • Full deletion on request • Open source telemetry code `); const consent = await this.askQuestion('Enable anonymous telemetry? (y/N): '); this.config.telemetryOptIn = consent.toLowerCase() === 'y' || consent.toLowerCase() === 'yes'; if (this.config.telemetryOptIn) { console.log(`${colors.green}✓ Telemetry enabled - Thank you for contributing!${colors.reset}`); } else { console.log(`${colors.green}✓ Telemetry disabled - Complete privacy maintained${colors.reset}`); } } async dataLocationChoice() { console.log(`${colors.blue}${colors.bold} 💾 DATA STORAGE ${colors.reset} Choose where your CSVLOD data is stored: ${colors.green}1. Local Only${colors.reset} • All data stays on your machine • Maximum privacy and sovereignty • No cloud dependencies ${colors.yellow}2. Local + Optional Cloud Sync${colors.reset} • Primary storage local • Optional encrypted cloud backup • Cross-device synchronization • You control the sync ${colors.blue}3. Hybrid Approach${colors.reset} • Smart local/cloud distribution • Performance optimized • Privacy-preserving `); if (this.config.sovereigntyLevel === 'high') { console.log(`${colors.green}✓ High sovereignty: Local-only storage enforced${colors.reset}`); this.config.dataLocation = 'local'; return; } const choice = await this.askQuestion('Select data location (1-3): '); const locationMap = { '1': 'local', '2': 'hybrid', '3': 'hybrid' }; this.config.dataLocation = locationMap[choice] || 'local'; console.log(`${colors.green}✓ Data location: ${this.config.dataLocation}${colors.reset}`); } async confirmInstallation() { console.log(`${colors.magenta}${colors.bold} 📋 INSTALLATION SUMMARY ${colors.reset} ${colors.cyan}Sovereignty Level:${colors.reset} ${this.config.sovereigntyLevel} ${colors.cyan}IDE Integration:${colors.reset} ${this.config.ideChoice} ${colors.cyan}Project Type:${colors.reset} ${this.config.projectType} ${colors.cyan}Telemetry:${colors.reset} ${this.config.telemetryOptIn ? 'Enabled' : 'Disabled'} ${colors.cyan}Data Storage:${colors.reset} ${this.config.dataLocation} ${colors.cyan}Install Location:${colors.reset} ${this.config.installLocation} ${colors.green}Ready to install 12 MCP tools with these settings!${colors.reset} `); const confirm = await this.askQuestion('Proceed with installation? (Y/n): '); if (confirm.toLowerCase() === 'n' || confirm.toLowerCase() === 'no') { console.log(`${colors.yellow}Installation cancelled. Run again anytime!${colors.reset}`); process.exit(0); } } async performInstallation() { console.log(`${colors.blue}${colors.bold} 🚀 INSTALLING CSVLOD-AI MCP TOOLS... ${colors.reset}`); // Create configuration directory const configDir = path.join(this.config.installLocation, '.csvlod'); if (!fs.existsSync(configDir)) { fs.mkdirSync(configDir, { recursive: true }); } // Save configuration fs.writeFileSync( path.join(configDir, 'config.json'), JSON.stringify(this.config, null, 2) ); console.log(`${colors.green}✓ Configuration saved${colors.reset}`); // Install IDE configurations await this.installIDEConfigs(); // Setup MCP server configuration await this.setupMCPServer(); // Initialize sovereignty audit await this.initSovereigntyAudit(); console.log(`${colors.green}${colors.bold} 🎉 INSTALLATION COMPLETE! ${colors.reset}`); } async installIDEConfigs() { console.log(`${colors.cyan}Installing IDE configurations...${colors.reset}`); const templatesDir = path.join(__dirname, '..', 'templates'); const configDir = path.join(this.config.installLocation, '.csvlod'); if (this.config.ideChoice === 'cursor' || this.config.ideChoice === 'multiple') { // Install Cursor configuration const cursorConfig = this.generateCursorConfig(); fs.writeFileSync( path.join(configDir, 'cursor-config.json'), JSON.stringify(cursorConfig, null, 2) ); console.log(`${colors.green}✓ Cursor configuration installed${colors.reset}`); } if (this.config.ideChoice === 'vscode' || this.config.ideChoice === 'multiple') { // Install VS Code configuration const vscodeConfig = this.generateVSCodeConfig(); fs.writeFileSync( path.join(configDir, 'vscode-settings.json'), JSON.stringify(vscodeConfig, null, 2) ); console.log(`${colors.green}✓ VS Code configuration installed${colors.reset}`); } } async setupMCPServer() { console.log(`${colors.cyan}Configuring MCP server...${colors.reset}`); const serverConfig = { version: "2.0.4", sovereignty: { level: this.config.sovereigntyLevel, telemetry: this.config.telemetryOptIn, dataLocation: this.config.dataLocation }, tools: { enabled: this.getMCPToolsForProjectType(), projectType: this.config.projectType } }; const configDir = path.join(this.config.installLocation, '.csvlod'); fs.writeFileSync( path.join(configDir, 'mcp-server-config.json'), JSON.stringify(serverConfig, null, 2) ); console.log(`${colors.green}✓ MCP server configured${colors.reset}`); } async initSovereigntyAudit() { console.log(`${colors.cyan}Initializing sovereignty audit...${colors.reset}`); // Create sovereignty audit configuration const auditConfig = { enabled: true, schedule: 'weekly', thresholds: { minimum: this.config.sovereigntyLevel === 'high' ? 90 : this.config.sovereigntyLevel === 'medium' ? 75 : 60 }, notifications: true }; const configDir = path.join(this.config.installLocation, '.csvlod'); fs.writeFileSync( path.join(configDir, 'sovereignty-audit.json'), JSON.stringify(auditConfig, null, 2) ); console.log(`${colors.green}✓ Sovereignty audit initialized${colors.reset}`); } async postInstallGuidance() { console.log(`${colors.blue}${colors.bold} 🎯 NEXT STEPS ${colors.reset} ${colors.green}1. Start using MCP tools:${colors.reset} • Open your IDE (${this.config.ideChoice}) • Access CSVLOD tools via MCP integration • Try: csvlod_init to initialize a project ${colors.green}2. Run sovereignty audit:${colors.reset} • cd ${this.config.installLocation} • python tools/sovereignty-audit.py • Monitor your sovereignty score ${colors.green}3. Explore agent swarms:${colors.reset} • Use swarm_init to set up multi-agent coordination • Try swarm_decompose for complex tasks • Maintain full control over agent decisions ${colors.green}4. Documentation & Support:${colors.reset} • Visit: https://csvlod.ai/documentation • GitHub: https://github.com/hamzaamjad/csvlod-ai-framework • Community: https://csvlod.ai/community ${colors.yellow}💡 Pro Tip:${colors.reset} Run 'csvlod_validate' regularly to ensure your project maintains high sovereignty standards! ${colors.green}Welcome to the future of AI-native development! 🚀${colors.reset} `); } generateCursorConfig() { return { "mcp": { "servers": { "csvlod-ai": { "command": "node", "args": [path.join(__dirname, "..", "dist", "index.js")], "sovereignty": this.config.sovereigntyLevel, "telemetry": this.config.telemetryOptIn } } }, "sovereignty": { "auditEnabled": true, "dataLocation": this.config.dataLocation, "level": this.config.sovereigntyLevel } }; } generateVSCodeConfig() { return { "mcp.servers": { "csvlod-ai": { "command": "node", "args": [path.join(__dirname, "..", "dist", "index.js")], "sovereignty": this.config.sovereigntyLevel } }, "csvlod.sovereignty.level": this.config.sovereigntyLevel, "csvlod.telemetry.enabled": this.config.telemetryOptIn, "csvlod.dataLocation": this.config.dataLocation }; } getMCPToolsForProjectType() { const allTools = [ "csvlod_init", "csvlod_validate", "csvlod_generate", "csvlod_analyze", "mcp_registry", "mcp_orchestrate", "swarm_init", "swarm_decompose", "swarm_status", "swarm_assign", "swarm_complete", "swarm_tasks" ]; switch (this.config.projectType) { case 'minimal': return ["csvlod_init", "csvlod_validate", "csvlod_generate"]; case 'enterprise': return allTools; default: return [ "csvlod_init", "csvlod_validate", "csvlod_generate", "csvlod_analyze", "swarm_init", "swarm_decompose", "swarm_status" ]; } } async askQuestion(question) { return new Promise((resolve) => { this.rl.question(`${colors.cyan}${question}${colors.reset}`, resolve); }); } async waitForEnter() { return new Promise((resolve) => { this.rl.question(`${colors.dim}Press Enter to continue...${colors.reset}`, resolve); }); } } // Run the installer if (import.meta.url === `file://${process.argv[1]}`) { const installer = new CSVLODInstaller(); installer.start().catch(console.error); } export { CSVLODInstaller };