chaimi-keep-mcp 3.1.45-beta.4 → 3.1.45-beta.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.
- package/package.json +1 -1
- package/server.js +11 -9
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -55,25 +55,25 @@ async function initializeConfig() {
|
|
|
55
55
|
const fs = require('fs');
|
|
56
56
|
const path = require('path');
|
|
57
57
|
const os = require('os');
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
// XDG 标准配置目录
|
|
60
60
|
// Linux/macOS: ~/.config/chaimi-keep-mcp/
|
|
61
61
|
// Windows: %APPDATA%/chaimi-keep-mcp/ (通过设置 XDG_CONFIG_HOME 环境变量)
|
|
62
62
|
const xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
63
|
-
const configDir = xdgConfigHome
|
|
63
|
+
const configDir = xdgConfigHome
|
|
64
64
|
? path.join(xdgConfigHome, 'chaimi-keep-mcp')
|
|
65
65
|
: path.join(os.homedir(), '.config', 'chaimi-keep-mcp');
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
// 确保配置目录存在
|
|
68
68
|
if (!fs.existsSync(configDir)) {
|
|
69
69
|
fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
const envPath = path.join(configDir, envFile);
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// 如果配置文件已存在,直接返回路径
|
|
75
75
|
if (fs.existsSync(envPath)) {
|
|
76
|
-
return;
|
|
76
|
+
return envPath;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// 首次启动,尝试从云端获取配置
|
|
@@ -117,8 +117,7 @@ JWT_SECRET=${config.JWT_SECRET}
|
|
|
117
117
|
console.error(` 文件位置:${envPath}`);
|
|
118
118
|
console.error('');
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
require('dotenv').config({ path: envPath });
|
|
120
|
+
return envPath;
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
const { Server } = require('@modelcontextprotocol/sdk/server/index.js');
|
|
@@ -2095,7 +2094,10 @@ let authState = {
|
|
|
2095
2094
|
|
|
2096
2095
|
async function main() {
|
|
2097
2096
|
// 首次启动时自动获取配置
|
|
2098
|
-
await initializeConfig();
|
|
2097
|
+
const envPath = await initializeConfig();
|
|
2098
|
+
|
|
2099
|
+
// 加载环境变量(无论文件是否存在都需要加载)
|
|
2100
|
+
require('dotenv').config({ path: envPath });
|
|
2099
2101
|
|
|
2100
2102
|
// 加载环境变量后赋值
|
|
2101
2103
|
CHAIMI_API_SECRET = process.env.CHAIMI_API_SECRET;
|