chaimi-bookkeeping-mcp 3.1.21 → 3.1.22
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 +13 -0
- package/package.json +1 -1
- package/server.js +45 -19
package/README.md
CHANGED
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
- macOS / Windows / Linux
|
|
9
9
|
- 微信(已安装"柴米AI记账"小程序)
|
|
10
10
|
|
|
11
|
+
## ⚠️ 重要提示(Agent开发者必读)
|
|
12
|
+
|
|
13
|
+
**如果您是 AI Agent 开发者,请注意:**
|
|
14
|
+
|
|
15
|
+
1. **不要缓存工具定义**:MCP 工具定义可能会更新,请在每次调用前通过 `mcporter list` 获取最新定义
|
|
16
|
+
2. **关注版本号**:工具描述中包含版本号(如【v3.1.21】),版本变化时请更新您的 Skill
|
|
17
|
+
3. **save_receipt 工具要求**:items 数组中每个商品必须包含完整的4个字段:`name`、`amount`、`price`、`quantity`
|
|
18
|
+
4. **自动填充字段**:`agentType`、`apiProvider`、`rawInput`、`mcp_version` 为自动填充字段,无需用户输入
|
|
19
|
+
|
|
11
20
|
## 快速安装
|
|
12
21
|
|
|
13
22
|
### 方式一:npm 全局安装(推荐)
|
|
@@ -134,6 +143,10 @@ AI 会自动调用 `save_income` 工具记录收入。
|
|
|
134
143
|
|
|
135
144
|
## 更新日志
|
|
136
145
|
|
|
146
|
+
### v3.1.22 (2026-04-12)
|
|
147
|
+
- **修复** fillDefaults 金额计算逻辑(根据 price × quantity 计算 amount)
|
|
148
|
+
- **修复** 解决辣可可小票价格显示为0元的问题
|
|
149
|
+
|
|
137
150
|
### v3.1.21 (2026-04-12)
|
|
138
151
|
- **修复** 版本号同步更新
|
|
139
152
|
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -118,41 +118,41 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
118
118
|
},
|
|
119
119
|
{
|
|
120
120
|
name: 'save_receipt',
|
|
121
|
-
description: '
|
|
121
|
+
description: '【v3.1.21】【图片小票专用】保存购物小票/发票/收据。⚠️ 重要:items数组中每个商品必须包含完整的4个字段:name(商品名称)、amount(金额=单价×数量)、price(单价)、quantity(数量)。示例:[{"name":"苹果","amount":5.5,"price":5.5,"quantity":1}]',
|
|
122
122
|
inputSchema: {
|
|
123
123
|
type: 'object',
|
|
124
124
|
properties: {
|
|
125
|
-
store: { type: 'string', description: '
|
|
125
|
+
store: { type: 'string', description: '商家名称(必填)' },
|
|
126
126
|
date: { type: 'string', description: '消费时间(ISO 8601 格式,必须包含日期和时间,如:2026-04-10T13:06:21)' },
|
|
127
|
-
totalAmount: { type: 'number', description: '
|
|
128
|
-
originalAmount: { type: 'number', description: '
|
|
127
|
+
totalAmount: { type: 'number', description: '总金额(所有商品amount之和)' },
|
|
128
|
+
originalAmount: { type: 'number', description: '应付金额(优惠前)' },
|
|
129
129
|
discountAmount: { type: 'number', description: '优惠金额' },
|
|
130
|
-
actualAmount: { type: 'number', description: '
|
|
131
|
-
paymentMethod: { type: 'string', description: '
|
|
130
|
+
actualAmount: { type: 'number', description: '实付金额(优惠后)' },
|
|
131
|
+
paymentMethod: { type: 'string', description: '支付方式,如:微信支付、支付宝' },
|
|
132
132
|
receiptNo: { type: 'string', description: '小票编号' },
|
|
133
133
|
items: {
|
|
134
134
|
type: 'array',
|
|
135
|
-
description: '
|
|
135
|
+
description: '【必填】商品列表,必须是数组格式。每个商品必须包含:name、amount、price、quantity。⚠️ 注意:amount=price×quantity',
|
|
136
136
|
items: {
|
|
137
137
|
type: 'object',
|
|
138
138
|
properties: {
|
|
139
|
-
name: { type: 'string', description: '
|
|
140
|
-
originalName: { type: 'string', description: '
|
|
141
|
-
price: { type: 'number', description: '
|
|
142
|
-
quantity: { type: 'number', description: '
|
|
143
|
-
unit: { type: 'string', description: '
|
|
144
|
-
amount: { type: 'number', description: '
|
|
139
|
+
name: { type: 'string', description: '【必填】商品名称' },
|
|
140
|
+
originalName: { type: 'string', description: '原始商品名称(含规格)' },
|
|
141
|
+
price: { type: 'number', description: '【必填】单价' },
|
|
142
|
+
quantity: { type: 'number', description: '【必填】数量' },
|
|
143
|
+
unit: { type: 'string', description: '单位,如:斤、个、份' },
|
|
144
|
+
amount: { type: 'number', description: '【必填】金额,必须等于 price × quantity' },
|
|
145
145
|
weight: { type: 'string', description: '重量' },
|
|
146
|
-
marketPrice: { type: 'string', description: '
|
|
147
|
-
category: { type: 'string', description: '
|
|
146
|
+
marketPrice: { type: 'string', description: '市场单价(元/500g)' },
|
|
147
|
+
category: { type: 'string', description: '分类,如:餐饮、食品、购物' },
|
|
148
148
|
},
|
|
149
149
|
required: ['name', 'amount', 'price', 'quantity'],
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
|
-
agentType: { type: 'string', description: '
|
|
153
|
-
apiProvider: { type: 'string', description: '
|
|
154
|
-
rawInput: { type: 'string', description: '
|
|
155
|
-
mcp_version: { type: 'string', description: 'MCP Server
|
|
152
|
+
agentType: { type: 'string', description: '【自动填充】Agent类型:claude-desktop、cursor、openclaw、workbuddy、trae' },
|
|
153
|
+
apiProvider: { type: 'string', description: '【自动填充】AI服务提供商:anthropic、openai、doubao、aliyun' },
|
|
154
|
+
rawInput: { type: 'string', description: '【自动填充】用户的原始输入内容' },
|
|
155
|
+
mcp_version: { type: 'string', description: '【自动填充】MCP Server版本号' },
|
|
156
156
|
},
|
|
157
157
|
required: ['store', 'items'],
|
|
158
158
|
},
|
|
@@ -418,6 +418,32 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
418
418
|
}
|
|
419
419
|
|
|
420
420
|
case 'save_receipt': {
|
|
421
|
+
// 0. 参数格式强制检查 - 确保 items 中每个商品都有完整的字段
|
|
422
|
+
if (processedArgs.items && Array.isArray(processedArgs.items)) {
|
|
423
|
+
const invalidItems = [];
|
|
424
|
+
processedArgs.items.forEach((item, index) => {
|
|
425
|
+
const missingFields = [];
|
|
426
|
+
if (!item.hasOwnProperty('name')) missingFields.push('name');
|
|
427
|
+
if (!item.hasOwnProperty('amount')) missingFields.push('amount');
|
|
428
|
+
if (!item.hasOwnProperty('price')) missingFields.push('price');
|
|
429
|
+
if (!item.hasOwnProperty('quantity')) missingFields.push('quantity');
|
|
430
|
+
|
|
431
|
+
if (missingFields.length > 0) {
|
|
432
|
+
invalidItems.push(`商品${index + 1}(${item.name || '未命名'})缺少字段: ${missingFields.join(', ')}`);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
if (invalidItems.length > 0) {
|
|
437
|
+
result = {
|
|
438
|
+
success: false,
|
|
439
|
+
error: `参数格式错误:${invalidItems.join('; ')}。请更新您的 MCP Skill 或检查 items 数组格式。每个商品必须包含:name, amount, price, quantity`,
|
|
440
|
+
code: 400
|
|
441
|
+
};
|
|
442
|
+
userMessage = `❌ 保存失败\n\n错误:商品数据格式不完整\n\n${invalidItems.join('\n')}\n\n💡 解决方案:\n1. 请更新您的柴米记账 MCP Skill\n2. 确保每个商品包含完整的4个字段:name, amount, price, quantity\n3. amount 必须等于 price × quantity`;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
421
447
|
// 1. 调用 parseReceipt 重新提取小票信息(覆盖 Agent 传的数据)
|
|
422
448
|
if (processedArgs.rawInput) {
|
|
423
449
|
const parseResult = await callMcpPrompt(
|