chaimi-keep-mcp 3.1.28 → 3.1.29
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/SKILL.md +25 -1
- package/package.json +1 -1
- package/server.js +22 -8
package/SKILL.md
CHANGED
|
@@ -120,7 +120,31 @@ Agent 通过 MCP 协议自动获取工具列表,无需手动查询。
|
|
|
120
120
|
⚠️ **强制流程**:保存小票时必须按以下顺序执行:
|
|
121
121
|
1. 调用 `get_parse_prompt` 获取 prompt 模板
|
|
122
122
|
2. 使用 prompt 模板调用大模型解析小票图片
|
|
123
|
-
3.
|
|
123
|
+
3. **调用 `save_receipt` 前,必须完成字段核对清单(见下文)**
|
|
124
|
+
4. 调用 `save_receipt` 保存解析结果
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### 🚨 小票字段核对清单(调用前必须检查)
|
|
129
|
+
|
|
130
|
+
**从 prompt 解析结果中提取的所有字段,必须全部传递给 `save_receipt`**:
|
|
131
|
+
|
|
132
|
+
| 字段 | 是否必须 | 常见遗漏 | 检查方式 |
|
|
133
|
+
|------|----------|----------|----------|
|
|
134
|
+
| `store` | ✅ | 否 | 商家名称 |
|
|
135
|
+
| `date` | ✅ **高频遗漏** | **是** | ISO 8601 格式,如:2026-01-08T11:42:27 |
|
|
136
|
+
| `totalAmount` | ✅ | 否 | 商品原价总和 |
|
|
137
|
+
| `actualAmount` | ✅ **高频遗漏** | **是** | 实付金额(优惠后)|
|
|
138
|
+
| `originalAmount` | ✅ **高频遗漏** | **是** | 原价(优惠前)|
|
|
139
|
+
| `discountAmount` | ✅ **高频遗漏** | **是** | 优惠金额 |
|
|
140
|
+
| `paymentMethod` | ✅ **高频遗漏** | **是** | 如:支付宝支付、微信支付 |
|
|
141
|
+
| `items` | ✅ | 否 | 商品数组,每个必须有 name/amount/price/quantity |
|
|
142
|
+
|
|
143
|
+
**核对步骤**:
|
|
144
|
+
1. 提取完小票信息后,对照上表检查每个字段
|
|
145
|
+
2. **重点检查标记"高频遗漏"的字段**:date、actualAmount、originalAmount、discountAmount、paymentMethod
|
|
146
|
+
3. 确认所有字段都在 args 中后再调用 `save_receipt`
|
|
147
|
+
4. 如果某个字段小票上确实没有,可以传空字符串或 0,但不能省略
|
|
124
148
|
|
|
125
149
|
**注意**:MCP 工具会不断迭代更新,请以实际通过 MCP 协议获取的工具定义为准。
|
|
126
150
|
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -459,18 +459,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
case 'save_receipt': {
|
|
462
|
-
// 0.
|
|
462
|
+
// 0. 参数完整性检查 - 提醒 Agent 哪些字段缺失
|
|
463
|
+
const requiredFields = ['store', 'date', 'totalAmount', 'actualAmount', 'originalAmount', 'discountAmount', 'paymentMethod'];
|
|
464
|
+
const missingFields = [];
|
|
465
|
+
requiredFields.forEach(field => {
|
|
466
|
+
if (processedArgs[field] === undefined || processedArgs[field] === null || processedArgs[field] === '') {
|
|
467
|
+
missingFields.push(field);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
if (missingFields.length > 0) {
|
|
472
|
+
console.error(`⚠️ 警告:save_receipt 缺少以下字段:${missingFields.join(', ')}`);
|
|
473
|
+
console.error(` 请从 get_parse_prompt 的解析结果中提取并传递所有字段`);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// 1. 参数格式强制检查 - 确保 items 中每个商品都有完整的字段
|
|
463
477
|
if (processedArgs.items && Array.isArray(processedArgs.items)) {
|
|
464
478
|
const invalidItems = [];
|
|
465
479
|
processedArgs.items.forEach((item, index) => {
|
|
466
|
-
const
|
|
467
|
-
if (!item.hasOwnProperty('name'))
|
|
468
|
-
if (!item.hasOwnProperty('amount'))
|
|
469
|
-
if (!item.hasOwnProperty('price'))
|
|
470
|
-
if (!item.hasOwnProperty('quantity'))
|
|
480
|
+
const itemMissingFields = [];
|
|
481
|
+
if (!item.hasOwnProperty('name')) itemMissingFields.push('name');
|
|
482
|
+
if (!item.hasOwnProperty('amount')) itemMissingFields.push('amount');
|
|
483
|
+
if (!item.hasOwnProperty('price')) itemMissingFields.push('price');
|
|
484
|
+
if (!item.hasOwnProperty('quantity')) itemMissingFields.push('quantity');
|
|
471
485
|
|
|
472
|
-
if (
|
|
473
|
-
invalidItems.push(`商品${index + 1}(${item.name || '未命名'})缺少字段: ${
|
|
486
|
+
if (itemMissingFields.length > 0) {
|
|
487
|
+
invalidItems.push(`商品${index + 1}(${item.name || '未命名'})缺少字段: ${itemMissingFields.join(', ')}`);
|
|
474
488
|
}
|
|
475
489
|
});
|
|
476
490
|
|