mta-mcp 2.3.1 → 2.4.0

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 CHANGED
@@ -1,43 +1,37 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * MTA MCP Server - 自动兼容 CommonJS 和 ES Module
5
- * 根据当前 Node.js 版本自动选择合适的模块格式
4
+ * MTA MCP Server 入口
5
+ * 最低要求: Node.js 16+ (由 @modelcontextprotocol/sdk 决定)
6
6
  */
7
7
 
8
8
  const { existsSync } = require('fs');
9
- const { join, dirname } = require('path');
9
+ const { join } = require('path');
10
10
 
11
11
  // 检测 Node.js 版本
12
12
  const nodeVersion = process.versions.node;
13
13
  const majorVersion = parseInt(nodeVersion.split('.')[0]);
14
14
 
15
- // 获取包根目录(bin 的上一级)
15
+ // 最低版本检查
16
+ if (majorVersion < 16) {
17
+ console.error(`[MCP Error] Node.js 版本过低: v${nodeVersion}`);
18
+ console.error('[MCP Error] mta-mcp 需要 Node.js 16.0.0 或更高版本');
19
+ console.error('[MCP Error] 请升级 Node.js: https://nodejs.org/');
20
+ process.exit(1);
21
+ }
22
+
23
+ // 获取包根目录
16
24
  const packageRoot = join(__dirname, '..');
17
- const distPath = join(packageRoot, 'dist');
25
+ const esmPath = join(packageRoot, 'dist', 'index.js');
18
26
 
19
- // Node.js 12-13 只支持 CommonJS
20
- if (majorVersion < 14) {
21
- const cjsPath = join(distPath, 'index.cjs');
22
- if (existsSync(cjsPath)) {
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
- }
27
+ if (!existsSync(esmPath)) {
28
+ console.error(`[MCP Error] 未找到构建版本: ${esmPath}`);
29
+ console.error('[MCP Error] 请确保已运行: npm run build');
30
+ process.exit(1);
43
31
  }
32
+
33
+ // 加载 ES Module
34
+ import(esmPath).catch(err => {
35
+ console.error('[MCP Error] 启动失败:', err.message);
36
+ process.exit(1);
37
+ });