Skip to main content
Glama
install.js•4.04 kB
#!/usr/bin/env node import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'; import { homedir, platform } from 'os'; import { dirname, join, resolve } from 'path'; import { fileURLToPath } from 'url'; // Get the actual package directory const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const packageDir = __dirname; console.log('šŸš€ Configuring Snapshot MCP Server...\n'); // Detect Claude Desktop config location const getClaudeConfigPath = () => { const os = platform(); if (os === 'darwin') { return join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'); } else if (os === 'win32') { return join(process.env.APPDATA || '', 'Claude', 'claude_desktop_config.json'); } else { // Linux const xdgConfig = process.env.XDG_CONFIG_HOME || join(homedir(), '.config'); return join(xdgConfig, 'Claude', 'claude_desktop_config.json'); } }; // Get database path const getDbPath = () => { const os = platform(); if (os === 'darwin') { return join(homedir(), '.claude-snapshots', 'snapshots.db'); } else if (os === 'win32') { return join(process.env.APPDATA || '', 'claude-snapshots', 'snapshots.db'); } else { const xdgData = process.env.XDG_DATA_HOME || join(homedir(), '.local', 'share'); return join(xdgData, 'claude-snapshots', 'snapshots.db'); } }; try { const indexPath = join(packageDir, 'dist', 'index.js'); const configPath = getClaudeConfigPath(); const dbPath = getDbPath(); console.log('šŸ“ Paths:'); console.log(` Server: ${indexPath}`); console.log(` Config: ${configPath}`); console.log(` Database: ${dbPath}\n`); // Create database directory const dbDir = dirname(dbPath); if (!existsSync(dbDir)) { mkdirSync(dbDir, { recursive: true }); console.log('āœ… Created database directory\n'); } // Update Claude config console.log('āš™ļø Updating Claude Desktop config...\n'); let config = {}; let configExists = existsSync(configPath); if (configExists) { try { config = JSON.parse(readFileSync(configPath, 'utf8')); console.log(' āœ“ Found existing config file'); if (config.mcpServers && Object.keys(config.mcpServers).length > 0) { console.log(' āœ“ Existing MCP servers:', Object.keys(config.mcpServers).join(', ')); } } catch (e) { console.log(' āš ļø Could not parse existing config, creating new one'); config = {}; } } else { console.log(' ℹ No existing config found, creating new one'); const configDir = dirname(configPath); if (!existsSync(configDir)) { mkdirSync(configDir, { recursive: true }); } } if (!config.mcpServers) { config.mcpServers = {}; } // Windows requires cmd /c wrapper for npx, but for local install we use node directly const snapshotConfig = { command: 'node', args: [indexPath], env: { SNAPSHOT_DB_PATH: dbPath } }; const alreadyExists = config.mcpServers.snapshot !== undefined; if (alreadyExists) { console.log(' ℹ Snapshot server already configured - updating...\n'); } else { console.log(' āž• Adding snapshot server to config\n'); } // Create backup if config exists if (configExists) { const backupPath = configPath + '.backup'; writeFileSync(backupPath, JSON.stringify(config, null, 2)); console.log(` šŸ’¾ Backup created: ${backupPath}`); } // Update config config.mcpServers.snapshot = snapshotConfig; writeFileSync(configPath, JSON.stringify(config, null, 2)); console.log(` āœ… Config updated: ${configPath}\n`); console.log('āœ… Setup complete!\n'); console.log('šŸ“ Next steps:'); console.log(' 1. Restart Claude Desktop completely (quit and reopen)'); console.log(' 2. Try: "Save a snapshot with summary: test, context: testing"'); console.log(' 3. Try: "List all snapshots"\n'); } catch (error) { console.error('\nāŒ Setup failed:', error.message); process.exit(1); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/WhenMoon-afk/snapshot-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server