chaimi-bookkeeping-mcp 3.1.7 → 3.1.9
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/README.md +5 -2
- package/bin/cli.js +39 -19
- package/oauth.js +5 -4
- package/package.json +1 -1
- package/server.js +21 -15
package/README.md
CHANGED
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
### 方式一:npm 全局安装(推荐)
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
# 安装
|
|
16
|
+
# 1. 安装 MCPorter(WorkBuddy/OpenClaw 等 OpenClaw 架构的 Agent 必需)
|
|
17
|
+
npm install -g mcporter
|
|
18
|
+
|
|
19
|
+
# 2. 安装柴米记账 MCP
|
|
17
20
|
npm install -g chaimi-bookkeeping-mcp
|
|
18
21
|
|
|
19
|
-
# 启动(自动配置 mcporter)
|
|
22
|
+
# 3. 启动(自动配置 mcporter)
|
|
20
23
|
chaimi-bookkeeping-mcp
|
|
21
24
|
```
|
|
22
25
|
|
package/bin/cli.js
CHANGED
|
@@ -35,17 +35,35 @@ const SUPPORTED_AGENTS = [
|
|
|
35
35
|
configPath: path.join(os.homedir(), '.mcporter', 'mcporter.json'),
|
|
36
36
|
format: 'json'
|
|
37
37
|
},
|
|
38
|
+
{
|
|
39
|
+
name: 'WorkBuddy (Windows)',
|
|
40
|
+
configPath: path.join(os.homedir(), 'workbuddy', 'mcp.json'),
|
|
41
|
+
format: 'json',
|
|
42
|
+
platform: 'win32'
|
|
43
|
+
},
|
|
38
44
|
{
|
|
39
45
|
name: 'Claude Desktop',
|
|
40
46
|
configPath: path.join(os.homedir(), 'Library/Application Support/Claude/claude_desktop_config.json'),
|
|
41
47
|
format: 'json',
|
|
42
48
|
platform: 'darwin'
|
|
43
49
|
},
|
|
50
|
+
{
|
|
51
|
+
name: 'Claude Desktop (Windows)',
|
|
52
|
+
configPath: path.join(process.env.APPDATA || path.join(os.homedir(), 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json'),
|
|
53
|
+
format: 'json',
|
|
54
|
+
platform: 'win32'
|
|
55
|
+
},
|
|
44
56
|
{
|
|
45
57
|
name: 'Cursor',
|
|
46
58
|
configPath: path.join(os.homedir(), '.cursor', 'mcp.json'),
|
|
47
59
|
format: 'json'
|
|
48
60
|
},
|
|
61
|
+
{
|
|
62
|
+
name: 'Cursor (Windows)',
|
|
63
|
+
configPath: path.join(os.homedir(), '.cursor', 'mcp.json'),
|
|
64
|
+
format: 'json',
|
|
65
|
+
platform: 'win32'
|
|
66
|
+
},
|
|
49
67
|
{
|
|
50
68
|
name: 'Windsurf',
|
|
51
69
|
configPath: path.join(os.homedir(), '.codeium', 'windsurf', 'mcp_config.json'),
|
|
@@ -137,9 +155,10 @@ function installToAgent(agent) {
|
|
|
137
155
|
|
|
138
156
|
/**
|
|
139
157
|
* 配置所有支持的 Agent
|
|
158
|
+
* 注意:所有输出使用 console.error,避免污染 stdout(MCP 协议通信使用 stdout)
|
|
140
159
|
*/
|
|
141
160
|
function configureAllAgents() {
|
|
142
|
-
console.
|
|
161
|
+
console.error('🔧 正在检测并配置 AI Agent...\n');
|
|
143
162
|
|
|
144
163
|
const results = [];
|
|
145
164
|
|
|
@@ -147,20 +166,20 @@ function configureAllAgents() {
|
|
|
147
166
|
const result = installToAgent(agent);
|
|
148
167
|
results.push({ agent: agent.name, ...result });
|
|
149
168
|
|
|
150
|
-
//
|
|
169
|
+
// 显示结果(使用 stderr)
|
|
151
170
|
if (result.success) {
|
|
152
171
|
if (result.action === 'skipped') {
|
|
153
|
-
console.
|
|
172
|
+
console.error(`✓ ${agent.name}: 配置已存在,已保留`);
|
|
154
173
|
} else if (result.action === 'created') {
|
|
155
|
-
console.
|
|
174
|
+
console.error(`✓ ${agent.name}: 已创建配置`);
|
|
156
175
|
} else {
|
|
157
|
-
console.
|
|
176
|
+
console.error(`✓ ${agent.name}: 已添加配置`);
|
|
158
177
|
}
|
|
159
178
|
} else {
|
|
160
179
|
if (result.reason === 'platform-not-supported') {
|
|
161
180
|
// 静默跳过不支持的平台的 Agent
|
|
162
181
|
} else {
|
|
163
|
-
console.
|
|
182
|
+
console.error(`✗ ${agent.name}: 配置失败 (${result.error})`);
|
|
164
183
|
}
|
|
165
184
|
}
|
|
166
185
|
}
|
|
@@ -170,29 +189,30 @@ function configureAllAgents() {
|
|
|
170
189
|
const skipped = results.filter(r => r.success && r.action === 'skipped').length;
|
|
171
190
|
const failed = results.filter(r => !r.success).length;
|
|
172
191
|
|
|
173
|
-
console.
|
|
174
|
-
console.
|
|
175
|
-
console.
|
|
192
|
+
console.error('\n📊 配置统计:');
|
|
193
|
+
console.error(` 新增配置: ${configured} 个`);
|
|
194
|
+
console.error(` 已存在: ${skipped} 个`);
|
|
176
195
|
if (failed > 0) {
|
|
177
|
-
console.
|
|
196
|
+
console.error(` 失败: ${failed} 个`);
|
|
178
197
|
}
|
|
179
|
-
console.
|
|
198
|
+
console.error('');
|
|
180
199
|
|
|
181
200
|
return results;
|
|
182
201
|
}
|
|
183
202
|
|
|
184
203
|
/**
|
|
185
204
|
* 显示欢迎信息
|
|
205
|
+
* 注意:使用 console.error,避免污染 stdout(MCP 协议通信使用 stdout)
|
|
186
206
|
*/
|
|
187
207
|
function showWelcome() {
|
|
188
|
-
console.
|
|
189
|
-
console.
|
|
190
|
-
console.
|
|
191
|
-
console.
|
|
192
|
-
console.
|
|
193
|
-
console.
|
|
194
|
-
console.
|
|
195
|
-
console.
|
|
208
|
+
console.error('╔════════════════════════════════════════════════════════╗');
|
|
209
|
+
console.error('║ ║');
|
|
210
|
+
console.error(`║ 柴米记账 MCP Server v${CURRENT_VERSION} ║`);
|
|
211
|
+
console.error('║ ║');
|
|
212
|
+
console.error('║ 支持: OpenClaw | WorkBuddy | Claude | Cursor ║');
|
|
213
|
+
console.error('║ ║');
|
|
214
|
+
console.error('╚════════════════════════════════════════════════════════╝');
|
|
215
|
+
console.error('');
|
|
196
216
|
}
|
|
197
217
|
|
|
198
218
|
// 主程序
|
package/oauth.js
CHANGED
|
@@ -58,10 +58,11 @@ class OAuthManager {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// 3. 轮询获取 Token
|
|
61
|
-
console.
|
|
62
|
-
console.
|
|
63
|
-
console.
|
|
64
|
-
console.
|
|
61
|
+
// 注意:使用 console.error,避免污染 stdout(MCP 协议通信使用 stdout)
|
|
62
|
+
console.error('');
|
|
63
|
+
console.error('⏳ 等待用户授权,请勿关闭窗口...');
|
|
64
|
+
console.error(' (请在手机微信中完成授权操作)');
|
|
65
|
+
console.error('');
|
|
65
66
|
const token = await this.pollForToken(
|
|
66
67
|
deviceCodeRes.deviceCode,
|
|
67
68
|
deviceCodeRes.interval * 1000 || 5000
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -53,25 +53,26 @@ function initOAuthManager() {
|
|
|
53
53
|
// ⚠️ 重要:此回调在用户首次使用时显示验证码,切勿删除或清空!
|
|
54
54
|
// 如果删除,用户将无法看到授权验证码,导致无法使用 MCP Server
|
|
55
55
|
// 参见 FUNCTION_REGISTRY.md 中的 "验证码显示" 功能
|
|
56
|
+
// 注意:使用 console.error,避免污染 stdout(MCP 协议通信使用 stdout)
|
|
56
57
|
onQrCode: (qrData) => {
|
|
57
58
|
// 输出授权信息到控制台(用户可见)
|
|
58
|
-
console.
|
|
59
|
-
console.
|
|
60
|
-
console.
|
|
61
|
-
console.
|
|
62
|
-
console.
|
|
63
|
-
console.
|
|
64
|
-
console.
|
|
65
|
-
console.
|
|
66
|
-
console.
|
|
67
|
-
console.
|
|
68
|
-
console.
|
|
69
|
-
console.
|
|
70
|
-
console.
|
|
59
|
+
console.error('\n' + '='.repeat(60));
|
|
60
|
+
console.error(' 柴米AI记账 MCP Server - 首次使用需要授权');
|
|
61
|
+
console.error('='.repeat(60));
|
|
62
|
+
console.error('');
|
|
63
|
+
console.error(` 验证码:${qrData.userCode}`);
|
|
64
|
+
console.error('');
|
|
65
|
+
console.error(' 请在"柴米AI记账"小程序中完成授权:');
|
|
66
|
+
console.error('');
|
|
67
|
+
console.error(' 1. 打开"柴米AI记账"小程序');
|
|
68
|
+
console.error(' 2. 点击"我的" → "🤖 Agent 授权"');
|
|
69
|
+
console.error(` 3. 输入验证码:${qrData.userCode}`);
|
|
70
|
+
console.error('');
|
|
71
|
+
console.error('='.repeat(60) + '\n');
|
|
71
72
|
},
|
|
72
73
|
// ⚠️ 重要:此回调在授权成功后通知用户,切勿删除!
|
|
73
74
|
onTokenReady: (token) => {
|
|
74
|
-
console.
|
|
75
|
+
console.error('✅ 授权成功!Token 已保存。');
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
|
|
@@ -709,4 +710,9 @@ async function main() {
|
|
|
709
710
|
await server.connect(transport);
|
|
710
711
|
}
|
|
711
712
|
|
|
712
|
-
|
|
713
|
+
// 注意:使用 console.error,避免污染 stdout(MCP 协议通信使用 stdout)
|
|
714
|
+
main().catch((err) => {
|
|
715
|
+
console.error('❌ MCP Server 启动失败:', err.message);
|
|
716
|
+
console.error('堆栈:', err.stack);
|
|
717
|
+
process.exit(1);
|
|
718
|
+
});
|