chaimi-bookkeeping-mcp 3.1.8 → 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/bin/cli.js +21 -19
- package/oauth.js +5 -4
- package/package.json +1 -1
- package/server.js +21 -15
package/bin/cli.js
CHANGED
|
@@ -155,9 +155,10 @@ function installToAgent(agent) {
|
|
|
155
155
|
|
|
156
156
|
/**
|
|
157
157
|
* 配置所有支持的 Agent
|
|
158
|
+
* 注意:所有输出使用 console.error,避免污染 stdout(MCP 协议通信使用 stdout)
|
|
158
159
|
*/
|
|
159
160
|
function configureAllAgents() {
|
|
160
|
-
console.
|
|
161
|
+
console.error('🔧 正在检测并配置 AI Agent...\n');
|
|
161
162
|
|
|
162
163
|
const results = [];
|
|
163
164
|
|
|
@@ -165,20 +166,20 @@ function configureAllAgents() {
|
|
|
165
166
|
const result = installToAgent(agent);
|
|
166
167
|
results.push({ agent: agent.name, ...result });
|
|
167
168
|
|
|
168
|
-
//
|
|
169
|
+
// 显示结果(使用 stderr)
|
|
169
170
|
if (result.success) {
|
|
170
171
|
if (result.action === 'skipped') {
|
|
171
|
-
console.
|
|
172
|
+
console.error(`✓ ${agent.name}: 配置已存在,已保留`);
|
|
172
173
|
} else if (result.action === 'created') {
|
|
173
|
-
console.
|
|
174
|
+
console.error(`✓ ${agent.name}: 已创建配置`);
|
|
174
175
|
} else {
|
|
175
|
-
console.
|
|
176
|
+
console.error(`✓ ${agent.name}: 已添加配置`);
|
|
176
177
|
}
|
|
177
178
|
} else {
|
|
178
179
|
if (result.reason === 'platform-not-supported') {
|
|
179
180
|
// 静默跳过不支持的平台的 Agent
|
|
180
181
|
} else {
|
|
181
|
-
console.
|
|
182
|
+
console.error(`✗ ${agent.name}: 配置失败 (${result.error})`);
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
}
|
|
@@ -188,29 +189,30 @@ function configureAllAgents() {
|
|
|
188
189
|
const skipped = results.filter(r => r.success && r.action === 'skipped').length;
|
|
189
190
|
const failed = results.filter(r => !r.success).length;
|
|
190
191
|
|
|
191
|
-
console.
|
|
192
|
-
console.
|
|
193
|
-
console.
|
|
192
|
+
console.error('\n📊 配置统计:');
|
|
193
|
+
console.error(` 新增配置: ${configured} 个`);
|
|
194
|
+
console.error(` 已存在: ${skipped} 个`);
|
|
194
195
|
if (failed > 0) {
|
|
195
|
-
console.
|
|
196
|
+
console.error(` 失败: ${failed} 个`);
|
|
196
197
|
}
|
|
197
|
-
console.
|
|
198
|
+
console.error('');
|
|
198
199
|
|
|
199
200
|
return results;
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
/**
|
|
203
204
|
* 显示欢迎信息
|
|
205
|
+
* 注意:使用 console.error,避免污染 stdout(MCP 协议通信使用 stdout)
|
|
204
206
|
*/
|
|
205
207
|
function showWelcome() {
|
|
206
|
-
console.
|
|
207
|
-
console.
|
|
208
|
-
console.
|
|
209
|
-
console.
|
|
210
|
-
console.
|
|
211
|
-
console.
|
|
212
|
-
console.
|
|
213
|
-
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('');
|
|
214
216
|
}
|
|
215
217
|
|
|
216
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
|
+
});
|