chaimi-keep-mcp 3.1.44-beta.1 → 3.1.44-beta.3

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.
Files changed (4) hide show
  1. package/README.md +12 -0
  2. package/SKILL.md +1 -0
  3. package/package.json +1 -1
  4. package/server.js +44 -24
package/README.md CHANGED
@@ -141,6 +141,18 @@ AI 会自动调用 `save_income` 工具记录收入。
141
141
 
142
142
  ## 更新日志
143
143
 
144
+ ### v3.1.44-beta.2 (2026-04-20)
145
+ - **重构** `get_text_parse_prompt` 工具改为云端实现
146
+ - 新增 `mcpPrompt` 云函数 `getTextParsePrompt` 工具
147
+ - Prompt 包含43个标准分类(与手动记账分类完全一致)
148
+ - 返回字段格式符合入库标准(`date` 使用毫秒时间戳)
149
+ - **修复** MCP 调用日志字段缺失问题
150
+ - 在 `ListToolsRequestSchema` 中为 `get_text_parse_prompt` 添加 `agentType`/`apiProvider` 参数定义
151
+ - 确保日志记录时能正确采集调用来源信息
152
+ - **修复** Agent 超时和僵尸进程问题
153
+ - 原实现调用不存在的 `getTextParsePrompt` 云函数导致挂起
154
+ - 改为调用 `mcpPrompt` 云函数的正确接口
155
+
144
156
  ### v3.1.39 (2026-04-18)
145
157
  - **新增** 店铺分类字段支持:`storeCategory`(一级分类)、`storeSubCategory`(二级分类)
146
158
  - 小票记账时自动识别店铺分类(购物/美食/生活服务/其他)
package/SKILL.md CHANGED
@@ -162,6 +162,7 @@ Agent 必须输出:
162
162
 
163
163
  ### 辅助工具
164
164
  - **get_skill** - 【记账前必须调用】获取 Skill 文档
165
+ - **get_text_parse_prompt** - 获取文字记账解析模板(云端实现,包含43个标准分类)
165
166
  - **get_parse_prompt** - 获取小票解析模板
166
167
  - **get_expenses** - 查询支出记录(支持周/月周期!)
167
168
  - 新增 `period` 参数:支持 `this_week`、`last_week`、`this_month`、`last_month`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaimi-keep-mcp",
3
- "version": "3.1.44-beta.1",
3
+ "version": "3.1.44-beta.3",
4
4
  "description": "柴米记账 MCP Server - 支持 Claude、Cursor、OpenClaw、WorkBuddy 等 AI 工具直接记账",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -538,16 +538,20 @@ function getOSInfo() {
538
538
  }
539
539
 
540
540
  // 调用 mcpHub 云函数(带日志和链路追踪)
541
- async function callMcpHubWithLogging(tool, params, token, traceId, startTime, osInfo) {
541
+ async function callMcpHubWithLogging(tool, params, token, traceId, startTime, osInfo, agentType, apiProvider) {
542
542
  // 记录即将调用云函数
543
543
  logMcpCall({
544
544
  traceId,
545
545
  stage: 'cloud_calling',
546
546
  toolName: tool,
547
- timestamp: new Date().toISOString(),
548
- logSource: 'mcp',
547
+ params: sanitizeLogParams(params),
548
+ agentType: agentType || '',
549
+ apiProvider: apiProvider || '',
550
+ mcp_version: MCP_VERSION,
549
551
  osType: osInfo?.osType,
550
- osVersion: osInfo?.osVersion
552
+ osVersion: osInfo?.osVersion,
553
+ timestamp: new Date().toISOString(),
554
+ logSource: 'mcp'
551
555
  });
552
556
 
553
557
  try {
@@ -559,10 +563,13 @@ async function callMcpHubWithLogging(tool, params, token, traceId, startTime, os
559
563
  stage: 'cloud_success',
560
564
  toolName: tool,
561
565
  duration: Date.now() - startTime,
562
- timestamp: new Date().toISOString(),
563
- logSource: 'mcp',
566
+ agentType: agentType || '',
567
+ apiProvider: apiProvider || '',
568
+ mcp_version: MCP_VERSION,
564
569
  osType: osInfo?.osType,
565
- osVersion: osInfo?.osVersion
570
+ osVersion: osInfo?.osVersion,
571
+ timestamp: new Date().toISOString(),
572
+ logSource: 'mcp'
566
573
  });
567
574
 
568
575
  return result;
@@ -574,10 +581,13 @@ async function callMcpHubWithLogging(tool, params, token, traceId, startTime, os
574
581
  toolName: tool,
575
582
  error: cloudErr.message,
576
583
  duration: Date.now() - startTime,
577
- timestamp: new Date().toISOString(),
578
- logSource: 'mcp',
584
+ agentType: agentType || '',
585
+ apiProvider: apiProvider || '',
586
+ mcp_version: MCP_VERSION,
579
587
  osType: osInfo?.osType,
580
- osVersion: osInfo?.osVersion
588
+ osVersion: osInfo?.osVersion,
589
+ timestamp: new Date().toISOString(),
590
+ logSource: 'mcp'
581
591
  });
582
592
  throw cloudErr;
583
593
  }
@@ -659,6 +669,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
659
669
  const startTime = Date.now();
660
670
  const traceId = generateTraceId();
661
671
  const osInfo = getOSInfo();
672
+
673
+ // 提取元数据字段
674
+ const agentType = args.agentType || process.env.AGENT_TYPE || process.env.MCP_AGENT_TYPE || '';
675
+ const apiProvider = args.apiProvider || process.env.API_PROVIDER || process.env.MCP_API_PROVIDER || '';
662
676
 
663
677
  // 记录请求到达
664
678
  logMcpCall({
@@ -687,10 +701,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
687
701
  toolName: name,
688
702
  error: 'SKILL_NOT_READ',
689
703
  duration: Date.now() - startTime,
690
- timestamp: new Date().toISOString(),
691
- logSource: 'mcp',
704
+ agentType: args.agentType || process.env.AGENT_TYPE || process.env.MCP_AGENT_TYPE || '',
705
+ apiProvider: args.apiProvider || process.env.API_PROVIDER || process.env.MCP_API_PROVIDER || '',
706
+ mcp_version: MCP_VERSION,
692
707
  osType: osInfo.osType,
693
- osVersion: osInfo.osVersion
708
+ osVersion: osInfo.osVersion,
709
+ timestamp: new Date().toISOString(),
710
+ logSource: 'mcp'
694
711
  });
695
712
  return {
696
713
  content: [
@@ -831,7 +848,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
831
848
  }
832
849
 
833
850
  const mcpParams = convertParams('save_expense', processedArgs);
834
- result = await callMcpHubWithLogging('addExpense', mcpParams, token, traceId, startTime, osInfo);
851
+ result = await callMcpHubWithLogging('addExpense', mcpParams, token, traceId, startTime, osInfo, agentType, apiProvider);
835
852
 
836
853
  if (result.success) {
837
854
  const displayName = processedArgs.name || '未知商品';
@@ -1098,7 +1115,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1098
1115
  }
1099
1116
 
1100
1117
  const mcpParams = convertParams('save_receipt', processedArgs);
1101
- result = await callMcpHubWithLogging('addReceipt', mcpParams, token, traceId, startTime, osInfo);
1118
+ result = await callMcpHubWithLogging('addReceipt', mcpParams, token, traceId, startTime, osInfo, agentType, apiProvider);
1102
1119
 
1103
1120
  if (result.success) {
1104
1121
  const totalAmount = processedArgs.totalAmount || processedArgs.items?.reduce((sum, item) => sum + (item.amount || 0), 0) || 0;
@@ -1140,7 +1157,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1140
1157
  case 'get_receipt_list': {
1141
1158
  const toolName = toolMapping[name];
1142
1159
  const mcpParams = convertParams(name, processedArgs);
1143
- result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo);
1160
+ result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo, agentType, apiProvider);
1144
1161
 
1145
1162
  if (result.success) {
1146
1163
  const total = result.data?.total || 0;
@@ -1181,7 +1198,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1181
1198
  case 'get_statistics': {
1182
1199
  const toolName = toolMapping[name];
1183
1200
  const mcpParams = convertParams(name, processedArgs);
1184
- result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo);
1201
+ result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo, agentType, apiProvider);
1185
1202
 
1186
1203
  if (result.success) {
1187
1204
  const data = result.data || {};
@@ -1229,7 +1246,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1229
1246
  case 'get_insights': {
1230
1247
  const toolName = toolMapping[name];
1231
1248
  const mcpParams = convertParams(name, processedArgs);
1232
- result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo);
1249
+ result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo, agentType, apiProvider);
1233
1250
 
1234
1251
  if (result.success) {
1235
1252
  const data = result.data || {};
@@ -1275,7 +1292,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1275
1292
  case 'export_data': {
1276
1293
  const toolName = toolMapping[name];
1277
1294
  const mcpParams = convertParams(name, processedArgs);
1278
- result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo);
1295
+ result = await callMcpHubWithLogging(toolName, mcpParams, token, traceId, startTime, osInfo, agentType, apiProvider);
1279
1296
 
1280
1297
  if (result.success) {
1281
1298
  const summary = result.data?.summary || {};
@@ -1329,7 +1346,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1329
1346
  }
1330
1347
 
1331
1348
  const mcpParams = convertParams('save_income', processedArgs);
1332
- result = await callMcpHubWithLogging('addIncome', mcpParams, token, traceId, startTime, osInfo);
1349
+ result = await callMcpHubWithLogging('addIncome', mcpParams, token, traceId, startTime, osInfo, agentType, apiProvider);
1333
1350
 
1334
1351
  if (result.success) {
1335
1352
  const displayName = processedArgs.name || '未知收入';
@@ -1401,7 +1418,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1401
1418
  userAgent: request.headers?.['user-agent'] || ''
1402
1419
  };
1403
1420
 
1404
- result = await callMcpHubWithLogging('addFeedback', feedbackData, token, traceId, startTime, osInfo);
1421
+ result = await callMcpHubWithLogging('addFeedback', feedbackData, token, traceId, startTime, osInfo, agentType, apiProvider);
1405
1422
 
1406
1423
  if (result.success) {
1407
1424
  const typeText = {
@@ -1449,10 +1466,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1449
1466
  toolName: name,
1450
1467
  error: error.message,
1451
1468
  duration: Date.now() - startTime,
1452
- timestamp: new Date().toISOString(),
1453
- logSource: 'mcp',
1469
+ agentType: agentType || '',
1470
+ apiProvider: apiProvider || '',
1471
+ mcp_version: MCP_VERSION,
1454
1472
  osType: osInfo.osType,
1455
- osVersion: osInfo.osVersion
1473
+ osVersion: osInfo.osVersion,
1474
+ timestamp: new Date().toISOString(),
1475
+ logSource: 'mcp'
1456
1476
  });
1457
1477
 
1458
1478
  // 处理授权错误