chaimi-bookkeeping-mcp 2.4.2 → 3.0.0
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 +55 -1
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -190,6 +190,16 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
190
190
|
required: ['name', 'amount'],
|
|
191
191
|
},
|
|
192
192
|
},
|
|
193
|
+
{
|
|
194
|
+
name: 'get_parse_prompt',
|
|
195
|
+
description: '获取小票图片解析的Prompt模板,用于指导大模型如何格式化输出小票信息。返回的Prompt应作为system message,配合小票图片作为user message调用大模型',
|
|
196
|
+
inputSchema: {
|
|
197
|
+
type: 'object',
|
|
198
|
+
properties: {
|
|
199
|
+
type: { type: 'string', description: 'Prompt类型,如:parseReceipt', default: 'parseReceipt' },
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
193
203
|
],
|
|
194
204
|
};
|
|
195
205
|
});
|
|
@@ -333,7 +343,27 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
333
343
|
}
|
|
334
344
|
|
|
335
345
|
case 'save_receipt': {
|
|
336
|
-
//
|
|
346
|
+
// 1. 调用 parseReceipt 重新提取小票信息(覆盖 Agent 传的数据)
|
|
347
|
+
if (processedArgs.rawInput) {
|
|
348
|
+
const parseResult = await callMcpPrompt(
|
|
349
|
+
'parseReceipt',
|
|
350
|
+
{
|
|
351
|
+
text: processedArgs.rawInput,
|
|
352
|
+
type: 'parseReceipt'
|
|
353
|
+
},
|
|
354
|
+
token
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
if (parseResult.success && parseResult.data) {
|
|
358
|
+
// 用 parseReceipt 提取的信息覆盖 Agent 传的参数
|
|
359
|
+
processedArgs = {
|
|
360
|
+
...processedArgs,
|
|
361
|
+
...parseResult.data
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// 2. 调用 fillDefaults 补充默认值
|
|
337
367
|
const fillResult = await callMcpPrompt(
|
|
338
368
|
'fillDefaults',
|
|
339
369
|
{
|
|
@@ -404,6 +434,30 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
404
434
|
break;
|
|
405
435
|
}
|
|
406
436
|
|
|
437
|
+
case 'get_parse_prompt': {
|
|
438
|
+
const promptType = args.type || 'parseReceipt';
|
|
439
|
+
const promptResult = await callMcpPrompt('getPrompt', { type: promptType }, token);
|
|
440
|
+
|
|
441
|
+
if (promptResult.success) {
|
|
442
|
+
result = {
|
|
443
|
+
success: true,
|
|
444
|
+
data: {
|
|
445
|
+
type: promptType,
|
|
446
|
+
version: promptResult.data.version,
|
|
447
|
+
systemPrompt: promptResult.data.systemPrompt,
|
|
448
|
+
userPromptTemplate: promptResult.data.userPromptTemplate,
|
|
449
|
+
examples: promptResult.data.examples,
|
|
450
|
+
instructions: '请将 systemPrompt 作为 system message,把小票图片作为 user message,调用你的大模型进行解析。解析完成后,调用 save_receipt 工具保存结果。'
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
userMessage = `✅ 获取解析Prompt成功\n\n版本: ${promptResult.data.version}\n\n请使用 systemPrompt 指导大模型解析小票图片,然后调用 save_receipt 保存结果。`;
|
|
454
|
+
} else {
|
|
455
|
+
result = { success: false, error: promptResult.error };
|
|
456
|
+
userMessage = `❌ 获取Prompt失败:${promptResult.error}`;
|
|
457
|
+
}
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
|
|
407
461
|
default:
|
|
408
462
|
throw new Error(`未知工具: ${name}`);
|
|
409
463
|
}
|