UNPKG

dynamic-interaction

Version:

Dynamic interaction 动态交互mcp,用于cursor、windsurf、trae 等 AI 智能编辑器 Agent 运行时交互使用

39 lines (38 loc) 1.43 kB
"use strict"; /** * Dynamic Interaction 应用程序入口点 * * 该文件负责初始化和启动各个模块,不包含具体业务逻辑 * 采用懒启动策略,仅在需要时启动HTTP服务器 */ Object.defineProperty(exports, "__esModule", { value: true }); const config_1 = require("./config"); const logger_1 = require("./logger"); const mcp_1 = require("./mcp"); require("./server/messaging/handlers"); // 自动注册所有消息处理器 /** * 应用程序主函数 */ async function main() { // 1. 预配置服务器组件(不启动) logger_1.logger.info('初始化服务器组件...'); // 2. 配置MCP服务器 (0, mcp_1.configureMcpServer)(); // 3. 仅启动 MCP 服务器,HTTP 服务器将在需要时懒启动 try { await (0, mcp_1.startMcpServer)(); logger_1.logger.info('MCP 服务器已成功启动。HTTP 服务器将在需要时启动。'); } catch (error) { logger_1.logger.error('启动 MCP 服务器失败:', error); if (typeof error === 'object' && error !== null && 'code' in error) { const nodeError = error; if (nodeError.code === 'EADDRINUSE') { logger_1.logger.error(`端口 ${config_1.PORT} 已被占用。是否有另一个服务器实例正在运行?`); } } process.exit(1); } } // main function ends here // 启动应用程序 main();