chaimi-bookkeeping-mcp 2.3.11 → 2.4.2
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/package.json +1 -1
- package/server.js +10 -33
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -302,7 +302,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
302
302
|
try {
|
|
303
303
|
const token = await getToken();
|
|
304
304
|
|
|
305
|
-
|
|
305
|
+
let processedArgs = { ...args };
|
|
306
306
|
if (processedArgs.items && typeof processedArgs.items === 'string') {
|
|
307
307
|
try {
|
|
308
308
|
processedArgs.items = JSON.parse(processedArgs.items);
|
|
@@ -333,8 +333,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
case 'save_receipt': {
|
|
336
|
-
|
|
337
|
-
|
|
336
|
+
// 总是调用 fillDefaults 来补充默认值(包括 actualAmount 等字段)
|
|
337
|
+
const fillResult = await callMcpPrompt(
|
|
338
|
+
'fillDefaults',
|
|
338
339
|
{
|
|
339
340
|
data: processedArgs,
|
|
340
341
|
type: 'parseReceipt'
|
|
@@ -342,35 +343,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
342
343
|
token
|
|
343
344
|
);
|
|
344
345
|
|
|
345
|
-
if (
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
type: 'parseReceipt'
|
|
351
|
-
},
|
|
352
|
-
token
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
if (fillResult.success) {
|
|
356
|
-
const savedAgentType = processedArgs.agentType;
|
|
357
|
-
const savedApiProvider = processedArgs.apiProvider;
|
|
358
|
-
const savedRawInput = processedArgs.rawInput;
|
|
359
|
-
const savedDate = processedArgs.date;
|
|
360
|
-
processedArgs = fillResult.data;
|
|
361
|
-
if (savedAgentType) {
|
|
362
|
-
processedArgs.agentType = savedAgentType;
|
|
363
|
-
}
|
|
364
|
-
if (savedApiProvider) {
|
|
365
|
-
processedArgs.apiProvider = savedApiProvider;
|
|
366
|
-
}
|
|
367
|
-
if (savedRawInput) {
|
|
368
|
-
processedArgs.rawInput = savedRawInput;
|
|
369
|
-
}
|
|
370
|
-
if (savedDate) {
|
|
371
|
-
processedArgs.date = savedDate;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
346
|
+
if (fillResult.success) {
|
|
347
|
+
processedArgs = {
|
|
348
|
+
...fillResult.data,
|
|
349
|
+
...processedArgs
|
|
350
|
+
};
|
|
374
351
|
}
|
|
375
352
|
|
|
376
353
|
const mcpParams = convertParams('save_receipt', processedArgs);
|
|
@@ -529,11 +506,11 @@ function convertParams(toolName, args) {
|
|
|
529
506
|
quantity: 1,
|
|
530
507
|
category: sanitizeString(args.category, 50) || '其他',
|
|
531
508
|
store: sanitizeString(args.store, 100) || '',
|
|
509
|
+
date: args.date,
|
|
532
510
|
transactionType: 'expense',
|
|
533
511
|
unit: '',
|
|
534
512
|
weight: '',
|
|
535
513
|
marketPrice: '',
|
|
536
|
-
date: args.date,
|
|
537
514
|
note: sanitizeString(args.note, 500) || '',
|
|
538
515
|
rawInput: sanitizeString(args.rawInput, 1000) || '',
|
|
539
516
|
agentType: args.agentType || '',
|