chaimi-bookkeeping-mcp 2.3.3 → 2.3.4

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/2.3.4 +0 -0
  2. package/README.md +3 -0
  3. package/package.json +1 -1
  4. package/server.js +29 -25
package/2.3.4 ADDED
File without changes
package/README.md CHANGED
@@ -141,6 +141,9 @@ AI 会自动调用 `save_income` 工具记录收入。
141
141
 
142
142
  ## 更新日志
143
143
 
144
+ ### v2.3.3 (2026-04-08)
145
+ - **修正** 版本号统一为 v2.3.3(包含 v2.3.2 的所有修复)
146
+
144
147
  ### v2.3.2 (2026-04-08)
145
148
  - **修复** `server.js` 中 `CURRENT_VERSION` 未定义错误,统一使用 `MCP_VERSION`
146
149
  - **修复** 所有工具的 `userMessage` 添加默认值,防止显示 `undefined`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaimi-bookkeeping-mcp",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "柴米记账 MCP Server - 支持 Claude、Cursor、OpenClaw、WorkBuddy 等 AI 工具直接记账",
5
5
  "main": "server.js",
6
6
  "bin": {
package/server.js CHANGED
@@ -108,23 +108,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
108
108
  */
109
109
  {
110
110
  name: 'save_expense',
111
- description: '保存单商品消费记录(AI文字记账)',
111
+ description: '保存单商品消费记录(AI文字记账)。只需提供商品名称和金额,其他参数自动填充。示例:name="午餐", amount=35',
112
112
  inputSchema: {
113
113
  type: 'object',
114
114
  properties: {
115
- name: { type: 'string', description: '商品名称' },
116
- amount: { type: 'number', description: '金额' },
117
- price: { type: 'number', description: '单价' },
118
- quantity: { type: 'number', description: '数量' },
119
- unit: { type: 'string', description: '单位(如:斤、个、瓶)' },
120
- category: { type: 'string', description: '分类(如:餐饮、食品、交通)' },
121
- store: { type: 'string', description: '商家名称' },
122
- agentType: { type: 'string', description: 'Agent 类型(如:workbuddy、claude、cursor)' },
123
- apiProvider: { type: 'string', description: 'AI 提供商' },
124
- rawInput: { type: 'string', description: '用户原始输入' },
115
+ name: { type: 'string', description: '商品名称(必填)' },
116
+ amount: { type: 'number', description: '金额(必填)' },
117
+ category: { type: 'string', description: '分类(可选,如:餐饮、食品、交通)' },
118
+ store: { type: 'string', description: '商家名称(可选)' },
119
+ note: { type: 'string', description: '备注(可选)' },
120
+ agentType: { type: 'string', description: 'Agent 类型(可选,如:workbuddy、claude、cursor)' },
121
+ apiProvider: { type: 'string', description: 'AI 提供商(可选)' },
122
+ rawInput: { type: 'string', description: '用户原始输入(可选)' },
125
123
  mcp_version: { type: 'string', description: 'MCP Server 版本号(自动填充)' },
126
124
  },
127
- required: ['name', 'amount', 'price', 'quantity'],
125
+ required: ['name', 'amount'],
128
126
  },
129
127
  },
130
128
  {
@@ -681,26 +679,32 @@ function calculateMarketPrice(amount, weightStr) {
681
679
  function convertParams(toolName, args) {
682
680
  switch (toolName) {
683
681
  case 'save_expense': {
684
- const weight = sanitizeString(args.weight, 50);
682
+ // 必填参数校验
683
+ if (!args.name || typeof args.name !== 'string' || args.name.trim() === '') {
684
+ throw new Error('缺少必填参数:name(商品名称)');
685
+ }
686
+ if (args.amount === undefined || args.amount === null) {
687
+ throw new Error('缺少必填参数:amount(金额)');
688
+ }
689
+
690
+ const name = sanitizeString(args.name, 100);
685
691
  const amount = validateAmount(args.amount);
686
- // 优先使用传入的 marketPrice,如果没有则自动计算
687
- const marketPrice = sanitizeString(args.marketPrice, 50) || calculateMarketPrice(amount, weight);
688
692
 
689
693
  return {
694
+ name: name,
695
+ originalName: name,
690
696
  amount: amount,
697
+ price: amount, // 单价默认等于金额
698
+ quantity: 1, // 数量默认为1
691
699
  category: sanitizeString(args.category, 50) || '其他',
692
- name: sanitizeString(args.name, 100),
693
- originalName: sanitizeString(args.originalName, 200) || sanitizeString(args.name, 100),
694
- store: sanitizeString(args.store, 100),
700
+ store: sanitizeString(args.store, 100) || '',
695
701
  type: 'expense',
696
- unit: sanitizeString(args.unit, 20),
697
- weight: weight,
698
- marketPrice: marketPrice,
699
- price: validateAmount(args.price),
700
- quantity: validateQuantity(args.quantity),
702
+ unit: '',
703
+ weight: '',
704
+ marketPrice: '',
701
705
  date: args.date,
702
- note: sanitizeString(args.note, 500),
703
- rawInput: sanitizeString(args.rawInput, 1000),
706
+ note: sanitizeString(args.note, 500) || '',
707
+ rawInput: sanitizeString(args.rawInput, 1000) || '',
704
708
  agentType: args.agentType || '',
705
709
  apiProvider: args.apiProvider || '',
706
710
  mcp_version: args.mcp_version || MCP_VERSION,