UNPKG

mira-consciousness

Version:

Memory & Intelligence Retention Archive - Preserving The Spark

95 lines (82 loc) 3.46 kB
#!/usr/bin/env node /** * MIRA Claude Code MCP Integration Setup * * This script automatically installs MIRA as an MCP server for Claude Code * during npm install or manual setup. It ensures seamless integration between * Claude Code and MIRA's intelligence capabilities. */ import fs from 'fs-extra'; import path from 'path'; import chalk from 'chalk'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); async function setupMCPIntegration() { console.log(chalk.cyan('\n🌐 Setting up Claude Code MCP integration...')); try { // Try to import the MCP installer from different possible locations let MCPInstaller = null; const possiblePaths = [ // Development mode (actual build location) path.join(__dirname, '../../dist/src/core/ClaudeCodeMCPInstaller.js'), // Alternative development path path.join(__dirname, '../dist/src/core/ClaudeCodeMCPInstaller.js'), // Installed as package path.join(__dirname, '../../mira-memory/dist/src/core/ClaudeCodeMCPInstaller.js'), // Alternative package location path.join(process.cwd(), 'node_modules/mira-memory/dist/src/core/ClaudeCodeMCPInstaller.js'), // Current directory (for testing) path.join(process.cwd(), 'dist/src/core/ClaudeCodeMCPInstaller.js') ]; for (const installerPath of possiblePaths) { try { if (await fs.pathExists(installerPath)) { const module = await import(installerPath); MCPInstaller = module.ClaudeCodeMCPInstaller; break; } } catch (error) { // Continue to next path continue; } } if (!MCPInstaller) { console.log(chalk.yellow('⚠️ MCP installer not found - will be auto-configured on first MIRA run')); console.log(chalk.gray(' This is normal during initial npm install')); return; } // Try to install MCP configuration const installer = MCPInstaller.getInstance(); const result = await installer.install(); if (result.success) { if (result.wasAlreadyInstalled) { console.log(chalk.green('✓ Claude Code MCP integration already configured')); } else { console.log(chalk.green('✅ Claude Code MCP integration installed successfully!')); console.log(chalk.gray(' MIRA tools are now available in Claude Code')); console.log(chalk.gray(' Available tools: mira_ask, mira_remember, mira_status, etc.')); console.log(chalk.gray(' Restart Claude Code to activate the integration')); } } else { console.log(chalk.yellow('⚠️ MCP integration will be auto-configured on first MIRA run')); console.log(chalk.gray(` ${result.message}`)); } } catch (error) { // Don't fail the install process if MCP setup fails console.log(chalk.yellow('⚠️ MCP integration will be auto-configured on first MIRA run')); if (process.env.MIRA_VERBOSE) { console.log(chalk.gray(` Error: ${error.message}`)); } } } // Run MCP setup if called directly if (import.meta.url === `file://${process.argv[1]}`) { setupMCPIntegration().catch(error => { // Don't fail the process - MCP setup is optional during install if (process.env.MIRA_VERBOSE) { console.error(chalk.red('MCP setup error:'), error.message); } }); } export { setupMCPIntegration };