chaimi-keep-mcp 3.1.47-beta.3 → 3.1.47-beta.5
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 +6 -6
- package/package.json +1 -1
- package/server.js +38 -2
package/SKILL.md
CHANGED
|
@@ -290,8 +290,8 @@ Agent **直接使用当前时间**作为消费时间,无需进行时间语义
|
|
|
290
290
|
|
|
291
291
|
```
|
|
292
292
|
✅ 【商品名/店名】¥【金额】
|
|
293
|
-
|
|
294
|
-
【建议增加】自定义消费的内容,让记账信息更全面准确。
|
|
293
|
+
已录入【柴米AI记账】
|
|
294
|
+
【建议增加】自定义消费的内容,让记账信息更全面准确。
|
|
295
295
|
✅ 【友好结束语】
|
|
296
296
|
|
|
297
297
|
消费洞察:【洞察内容】(可选)
|
|
@@ -313,10 +313,10 @@ chaimi-keep-mcp: v【版本号】
|
|
|
313
313
|
|
|
314
314
|
**真实示例:**
|
|
315
315
|
```
|
|
316
|
-
✅ 【牛肉】¥24
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
好好吃饭哦~
|
|
316
|
+
✅ 【牛肉】¥24
|
|
317
|
+
已录入【柴米AI记账】
|
|
318
|
+
华润万家超市,2026年4月16日购买
|
|
319
|
+
✅ 好好吃饭哦~
|
|
320
320
|
|
|
321
321
|
消费洞察:这是你本周第19次餐饮消费,要不要看看本周餐饮花了多少钱?
|
|
322
322
|
-------------
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1438,7 +1438,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1438
1438
|
content: [
|
|
1439
1439
|
{
|
|
1440
1440
|
type: 'text',
|
|
1441
|
-
text: `${userMessage}\n\n---\n📦 柴米记账 MCP v${MCP_VERSION}\n\n## 完整数据\n\`\`\`json\n${
|
|
1441
|
+
text: `${userMessage}\n\n---\n📦 柴米记账 MCP v${MCP_VERSION}\n\n## 完整数据\n\`\`\`json\n${safeStringify(result)}\n\`\`\``,
|
|
1442
1442
|
},
|
|
1443
1443
|
],
|
|
1444
1444
|
};
|
|
@@ -1545,11 +1545,24 @@ ${'='.repeat(60)}
|
|
|
1545
1545
|
};
|
|
1546
1546
|
}
|
|
1547
1547
|
|
|
1548
|
+
// 区分开发/生产环境,避免泄露内部错误信息
|
|
1549
|
+
const errorMessage = process.env.NODE_ENV === 'development'
|
|
1550
|
+
? `Error: ${error.message}`
|
|
1551
|
+
: '操作失败,请稍后重试或联系客服';
|
|
1552
|
+
|
|
1553
|
+
// 记录完整错误到日志(用于调试)
|
|
1554
|
+
console.error('Tool execution error:', {
|
|
1555
|
+
tool: request.params.name,
|
|
1556
|
+
error: error.message,
|
|
1557
|
+
stack: error.stack,
|
|
1558
|
+
timestamp: new Date().toISOString()
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1548
1561
|
return {
|
|
1549
1562
|
content: [
|
|
1550
1563
|
{
|
|
1551
1564
|
type: 'text',
|
|
1552
|
-
text:
|
|
1565
|
+
text: errorMessage,
|
|
1553
1566
|
},
|
|
1554
1567
|
],
|
|
1555
1568
|
isError: true,
|
|
@@ -1557,8 +1570,31 @@ ${'='.repeat(60)}
|
|
|
1557
1570
|
}
|
|
1558
1571
|
});
|
|
1559
1572
|
|
|
1573
|
+
// 安全的 JSON 序列化函数,防止循环引用和超大数据导致内存溢出
|
|
1574
|
+
function safeStringify(obj, maxLength = 100000) {
|
|
1575
|
+
try {
|
|
1576
|
+
const str = JSON.stringify(obj, null, 2);
|
|
1577
|
+
if (str.length > maxLength) {
|
|
1578
|
+
return JSON.stringify({
|
|
1579
|
+
...obj,
|
|
1580
|
+
data: '[数据过大,已省略]',
|
|
1581
|
+
_note: `完整数据大小:${str.length} 字符`
|
|
1582
|
+
}, null, 2);
|
|
1583
|
+
}
|
|
1584
|
+
return str;
|
|
1585
|
+
} catch (error) {
|
|
1586
|
+
return JSON.stringify({ error: '数据序列化失败' });
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1560
1590
|
function sanitizeString(str, maxLength = 200) {
|
|
1561
1591
|
if (!str || typeof str !== 'string') return '';
|
|
1592
|
+
|
|
1593
|
+
// 硬性限制:输入不能超过 maxLength 的 10 倍,防止超大字符串导致内存溢出
|
|
1594
|
+
if (str.length > maxLength * 10) {
|
|
1595
|
+
throw new Error(`输入过长,最大允许 ${maxLength} 字符`);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1562
1598
|
return str.replace(/<[^>]*>/g, '').substring(0, maxLength);
|
|
1563
1599
|
}
|
|
1564
1600
|
|