@bangdao-ai/zentao-mcp 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +44 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -92,13 +92,46 @@ function getScriptPath() {
92
92
  return scriptPath;
93
93
  }
94
94
 
95
- // 检查 Python 依赖
96
- function checkPythonDependencies() {
97
- const requirementsPath = path.join(__dirname, 'requirements.txt');
98
-
99
- if (fs.existsSync(requirementsPath)) {
100
- // 可以在这里添加依赖检查逻辑
101
- // 例如:尝试导入模块,如果失败则提示用户安装
95
+ // 检查并安装 Python 依赖
96
+ function checkPythonDependencies(python) {
97
+ try {
98
+ // 检查 mcp 模块是否已安装
99
+ execSync(`${python} -c "import mcp"`, {
100
+ encoding: 'utf-8',
101
+ stdio: ['ignore', 'ignore', 'ignore']
102
+ });
103
+ // 如果导入成功,说明已安装
104
+ return true;
105
+ } catch (e) {
106
+ // 模块未安装,尝试自动安装
107
+ try {
108
+ console.error('检测到 mcp 模块未安装,正在自动安装...');
109
+ const requirementsPath = path.join(__dirname, 'requirements.txt');
110
+
111
+ if (fs.existsSync(requirementsPath)) {
112
+ // 使用 --user 标志安装,避免权限问题
113
+ execSync(`${python} -m pip install --user -r "${requirementsPath}"`, {
114
+ encoding: 'utf-8',
115
+ stdio: 'inherit'
116
+ });
117
+ console.error('依赖安装完成!');
118
+ return true;
119
+ } else {
120
+ // 如果找不到 requirements.txt,尝试直接安装 mcp
121
+ execSync(`${python} -m pip install --user mcp`, {
122
+ encoding: 'utf-8',
123
+ stdio: 'inherit'
124
+ });
125
+ console.error('mcp 模块安装完成!');
126
+ return true;
127
+ }
128
+ } catch (installError) {
129
+ console.error('自动安装失败,请手动安装依赖:');
130
+ console.error(` ${python} -m pip install --user -r "${path.join(__dirname, 'requirements.txt')}"`);
131
+ console.error('或者:');
132
+ console.error(` ${python} -m pip install --user mcp`);
133
+ return false;
134
+ }
102
135
  }
103
136
  }
104
137
 
@@ -108,8 +141,10 @@ function main() {
108
141
  const python = findPython();
109
142
  const scriptPath = getScriptPath();
110
143
 
111
- // 检查 Python 依赖(可选)
112
- checkPythonDependencies();
144
+ // 检查并自动安装 Python 依赖
145
+ if (!checkPythonDependencies(python)) {
146
+ process.exit(1);
147
+ }
113
148
 
114
149
  // 启动 Python MCP 服务器
115
150
  // 注意:MCP 服务器通过 stdio 通信,不会输出到控制台
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bangdao-ai/zentao-mcp",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "禅道Bug管理系统MCP工具",
5
5
  "main": "index.js",
6
6
  "bin": {