Skip to main content
Glama
coji
by coji
setup.tsβ€’3.2 kB
import { promises as fs } from 'node:fs'; import { dirname } from 'node:path'; import { fileExists, ensureDir } from './utils/files.js'; import { detectNpxPath, getClaudeConfigPath } from './utils/system.js'; export interface SetupOptions { configPath?: string; force?: boolean; } export async function setupClaudeDesktop( options: SetupOptions = {} ): Promise<void> { const configPath = options.configPath || getClaudeConfigPath(); console.log('πŸ”§ Setting up Claude Desktop configuration...'); console.log(`πŸ“ Config path: ${configPath}`); // Ensure config directory exists await ensureDir(dirname(configPath)); // Detect npx path const npxPath = await detectNpxPath(); console.log(`πŸ” Detected npx at: ${npxPath}`); // Read existing config or create empty one let config: any = {}; if (await fileExists(configPath)) { console.log('πŸ“– Reading existing configuration...'); // Create backup const backupPath = `${configPath}.backup.${Date.now()}`; const existingContent = await fs.readFile(configPath, 'utf-8'); await fs.writeFile(backupPath, existingContent, 'utf-8'); console.log(`πŸ’Ύ Backup created: ${backupPath}`); try { config = JSON.parse(existingContent); } catch (error) { console.warn('⚠️ Failed to parse existing config, creating new one'); config = {}; } } // Initialize mcpServers if not exists if (!config.mcpServers) { config.mcpServers = {}; } // Check if journal config already exists if (config.mcpServers.journal && !options.force) { console.log('βœ… Journal MCP server already configured'); console.log('πŸ’‘ Use --force to overwrite existing configuration'); return; } // Add journal MCP server configuration config.mcpServers.journal = { command: npxPath, args: ['@coji/journal-mcp'], }; // Write updated config const configContent = JSON.stringify(config, null, 2); await fs.writeFile(configPath, configContent, 'utf-8'); console.log('βœ… Claude Desktop configuration updated!'); console.log('\nπŸ“‹ Configuration added:'); console.log(JSON.stringify(config.mcpServers.journal, null, 2)); console.log('\nπŸš€ Next steps:'); console.log('1. Restart Claude Desktop'); console.log('2. The journal MCP server will be available in Claude Desktop'); console.log( '3. To start web viewer separately, run: npx @coji/journal-mcp --viewer' ); console.log( '\nπŸ’‘ Try asking Claude: "Add a journal entry about today\'s work"' ); } export async function verifySetup(): Promise<boolean> { const configPath = getClaudeConfigPath(); if (!(await fileExists(configPath))) { console.log('❌ Claude Desktop config not found'); return false; } try { const content = await fs.readFile(configPath, 'utf-8'); const config = JSON.parse(content); if (config.mcpServers?.journal) { console.log('βœ… Journal MCP server is configured'); return true; } else { console.log('❌ Journal MCP server not found in configuration'); return false; } } catch (error) { console.log('❌ Failed to read Claude Desktop configuration'); return false; } }

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/coji/journal-mcp'

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