UNPKG

automagik-genie

Version:

Self-evolving AI agent orchestration framework with Model Context Protocol support

57 lines (56 loc) 2.04 kB
"use strict"; /** * MCP stdio mode starter * For Claude Desktop integration */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.startMCPStdio = startMCPStdio; const service_config_js_1 = require("./service-config.js"); const path_1 = __importDefault(require("path")); const fs_1 = __importDefault(require("fs")); const child_process_1 = require("child_process"); const forge_manager_1 = require("./forge-manager"); /** * Start MCP in stdio mode (for Claude Desktop integration) * Requires Forge to already be running */ async function startMCPStdio() { const mcpServer = path_1.default.join(__dirname, '../../../dist/mcp/server.js'); // Check if MCP server exists if (!fs_1.default.existsSync(mcpServer)) { console.error('Error: MCP server not built. Run: pnpm run build:mcp'); process.exit(1); } // Check if Forge is running const baseUrl = process.env.FORGE_BASE_URL || (0, service_config_js_1.getForgeConfig)().baseUrl; const forgeRunning = await (0, forge_manager_1.isForgeRunning)(baseUrl); if (!forgeRunning) { console.error('❌ Forge is not running.'); console.error(''); console.error('Please start the Genie server first:'); console.error(' npx automagik-genie'); console.error(''); console.error('This will start both Forge backend and MCP server.'); process.exit(1); } // Set environment for stdio transport const env = { ...process.env, MCP_TRANSPORT: 'stdio' }; // Start MCP in stdio mode const child = (0, child_process_1.spawn)('node', [mcpServer], { stdio: 'inherit', env }); child.on('exit', (code) => { process.exit(code === null ? 0 : code); }); child.on('error', (err) => { console.error('Failed to start MCP server:', err); process.exit(1); }); }