UNPKG

@realeng/maestro

Version:

Easy setup and management for local MCP servers

91 lines • 4.61 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.mcpConfigCommand = mcpConfigCommand; const chalk_1 = __importDefault(require("chalk")); const fs = __importStar(require("fs")); const path = __importStar(require("path")); const config_1 = require("../utils/config"); const servers_1 = require("../servers"); async function mcpConfigCommand() { const config = (0, config_1.loadConfig)(); const enabledServers = Object.entries(config.servers) .filter(([_, serverConfig]) => serverConfig.enabled); if (enabledServers.length === 0) { console.log(chalk_1.default.yellow('\nāš ļø No MCP servers configured.')); console.log(chalk_1.default.gray('Run "maestro init" to configure servers.')); return; } console.log(chalk_1.default.blue('\nšŸ“‹ Generating Claude configuration...\n')); const claudeConfig = { mcpServers: {} }; for (const [name, serverConfig] of enabledServers) { const serverDef = (0, servers_1.getServer)(serverConfig.type); if (!serverDef) { console.warn(chalk_1.default.yellow(`Warning: Server definition not found for ${serverConfig.type}`)); continue; } const command = serverDef.command(serverConfig); // Include env object if server has includeEnvInConfig flag set to true const includeEnv = serverDef.includeEnvInConfig && serverDef.env; const env = includeEnv && serverDef.env ? serverDef.env(serverConfig) : undefined; claudeConfig.mcpServers[name] = { command: command[0], args: command.slice(1).length > 0 ? command.slice(1) : undefined, ...(env && { env }) }; } const configJson = JSON.stringify(claudeConfig, null, 2); console.log(chalk_1.default.cyan('Claude Desktop/Code Configuration:')); console.log(chalk_1.default.gray('─'.repeat(50))); console.log(configJson); console.log(chalk_1.default.gray('─'.repeat(50))); console.log(chalk_1.default.green('\nāœ… Configuration generated!')); console.log(chalk_1.default.gray('\nTo use this configuration:')); console.log(chalk_1.default.white('1. Copy the JSON above')); console.log(chalk_1.default.white('2. Add it to your Claude Desktop or Claude Code settings')); console.log(chalk_1.default.white(' - Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json')); console.log(chalk_1.default.white(' - Claude Code: Add to your settings')); console.log(chalk_1.default.blue('\nšŸ’” Tip: Use ') + chalk_1.default.green('maestro sync') + chalk_1.default.blue(' to automatically update Claude Desktop')); console.log(chalk_1.default.gray(' Then run ') + chalk_1.default.green('claude mcp add-from-claude-desktop') + chalk_1.default.gray(' to sync with Claude Code')); const outputPath = path.join(process.cwd(), 'claude-config.json'); fs.writeFileSync(outputPath, configJson); console.log(chalk_1.default.gray(`\nConfiguration also saved to: ${outputPath}`)); } //# sourceMappingURL=mcp-config.js.map