mta-mcp 2.3.1 → 2.4.1
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.
- package/bin/mta.cjs +25 -29
- package/dist/index.js +100 -108
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
- package/dist/index.cjs +0 -4784
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1
package/bin/mta.cjs
CHANGED
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* MTA MCP Server
|
|
5
|
-
*
|
|
4
|
+
* MTA MCP Server 入口
|
|
5
|
+
* 最低要求: Node.js 16+ (由 @modelcontextprotocol/sdk 决定)
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const { existsSync } = require('fs');
|
|
9
|
-
const { join
|
|
9
|
+
const { join } = require('path');
|
|
10
|
+
const { pathToFileURL } = require('url');
|
|
10
11
|
|
|
11
12
|
// 检测 Node.js 版本
|
|
12
13
|
const nodeVersion = process.versions.node;
|
|
13
14
|
const majorVersion = parseInt(nodeVersion.split('.')[0]);
|
|
14
15
|
|
|
15
|
-
//
|
|
16
|
+
// 最低版本检查
|
|
17
|
+
if (majorVersion < 16) {
|
|
18
|
+
console.error(`[MCP Error] Node.js 版本过低: v${nodeVersion}`);
|
|
19
|
+
console.error('[MCP Error] mta-mcp 需要 Node.js 16.0.0 或更高版本');
|
|
20
|
+
console.error('[MCP Error] 请升级 Node.js: https://nodejs.org/');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 获取包根目录
|
|
16
25
|
const packageRoot = join(__dirname, '..');
|
|
17
|
-
const
|
|
26
|
+
const esmPath = join(packageRoot, 'dist', 'index.js');
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
require(cjsPath);
|
|
24
|
-
} else {
|
|
25
|
-
console.error(`[MCP Error] 未找到 CommonJS 构建版本: ${cjsPath}`);
|
|
26
|
-
console.error('[MCP Error] 请确保已运行: npm run build');
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
// Node.js 14+ 支持 ES Module
|
|
31
|
-
const esmPath = join(distPath, 'index.js');
|
|
32
|
-
if (existsSync(esmPath)) {
|
|
33
|
-
// 使用动态 import 加载 ES Module
|
|
34
|
-
import(esmPath).catch(err => {
|
|
35
|
-
console.error('[MCP Error] 启动失败:', err.message);
|
|
36
|
-
process.exit(1);
|
|
37
|
-
});
|
|
38
|
-
} else {
|
|
39
|
-
console.error(`[MCP Error] 未找到 ES Module 构建版本: ${esmPath}`);
|
|
40
|
-
console.error('[MCP Error] 请确保已运行: npm run build');
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
28
|
+
if (!existsSync(esmPath)) {
|
|
29
|
+
console.error(`[MCP Error] 未找到构建版本: ${esmPath}`);
|
|
30
|
+
console.error('[MCP Error] 请确保已运行: npm run build');
|
|
31
|
+
process.exit(1);
|
|
43
32
|
}
|
|
33
|
+
|
|
34
|
+
// 加载 ES Module - 在 Windows 上必须转换为 file:// URL
|
|
35
|
+
const esmUrl = pathToFileURL(esmPath).href;
|
|
36
|
+
import(esmUrl).catch(err => {
|
|
37
|
+
console.error('[MCP Error] 启动失败:', err.message);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|