UNPKG

yapi-devloper-mcp

Version:

YApi MCP Integration

51 lines 2.2 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 __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.startServer = startServer; const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js"); const server_1 = require("./server"); const config_1 = require("./config"); async function startServer() { const config = (0, config_1.getServerConfig)(); const server = new server_1.YapiMcpServer(config.yapiBaseUrl, { type: config.yapiToken ? 'token' : 'password', token: config.yapiToken, username: config.yapiUsername, password: config.yapiPassword }); const isStdioMode = process.env.NODE_ENV === "cli" || process.argv.includes("--stdio"); if (isStdioMode) { console.log("正在以 stdio 模式初始化 Yapi MCP 服务器..."); const transport = new stdio_js_1.StdioServerTransport(); await server.connect(transport); } else { console.log(`正在以 HTTP 模式初始化 Yapi MCP 服务器,端口 ${config.port}...`); await server.startHttpServer(config.port || 3000); } console.log("\n可用工具:"); console.log("- get_api_desc: 获取YApi接口信息"); console.log("- create_api: 创建新的API接口"); console.log("- update_api: 更新已有的API接口"); } if (require.main === module) { startServer().catch((error) => { console.error("服务器启动失败:", error); process.exit(1); }); } __exportStar(require("./services/yapi"), exports); //# sourceMappingURL=index.js.map