@mambasms/mcp-server 0.7.23 → 0.7.25
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/index.js +46 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -123,7 +123,7 @@ function defineTool(name, description, shape, handler) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
const server = new McpServer(
|
|
126
|
-
{ name: "mambasms-mcp-server", version: "0.7.
|
|
126
|
+
{ name: "mambasms-mcp-server", version: "0.7.25" },
|
|
127
127
|
{
|
|
128
128
|
instructions: `MambaSMS 营销自动化(店铺级,鉴权用 MAMBA_ACCESS_TOKEN 店铺密钥)。共 66 个工具,分四组。
|
|
129
129
|
不确定用什么/想先看总览 → mamba_guide;只知道关键词 → mamba_search;要参数细节 → mamba_tool_schema。
|
|
@@ -161,6 +161,23 @@ defineTool(
|
|
|
161
161
|
{ id: z.string().min(1).describe("模板id(template_list 返回的 id)") },
|
|
162
162
|
async ({ id }) => {
|
|
163
163
|
const data = await callApi("/api/v1/template/details", [id]);
|
|
164
|
+
// 预览是"变量替换后的渲染",但部分变量(联系人邮箱/评价链接等)无上下文时会保留原占位符;
|
|
165
|
+
// 不说明的话 AI 会以为模板写错了,或者把占位符当正文再回写
|
|
166
|
+
try {
|
|
167
|
+
// /template/details 返回的是数组,逐个补提示(之前只处理对象,导致提示永远不出现)
|
|
168
|
+
const items = Array.isArray(data) ? data : [data];
|
|
169
|
+
for (const item of items) {
|
|
170
|
+
if (!item || typeof item !== "object") continue;
|
|
171
|
+
const html = String(item.htmlContext || item.html || item.content || "");
|
|
172
|
+
const left = [...new Set((html.match(/\{[A-Za-z][A-Za-z0-9_]*\}/g) || []))]
|
|
173
|
+
.filter((x) => x !== "{Unsubscribe}");
|
|
174
|
+
if (left.length) {
|
|
175
|
+
item.placeholdersRemaining = left.slice(0, 20);
|
|
176
|
+
item.placeholderNote = "以下占位符在预览里没有被替换(需要收件人/订单上下文),发送时会按真实数据渲染,不是模板写错;"
|
|
177
|
+
+ "不要把预览 HTML 当原模板回写";
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} catch (e) { /* ignore */ }
|
|
164
181
|
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
165
182
|
}
|
|
166
183
|
);
|
|
@@ -1348,6 +1365,25 @@ defineTool(
|
|
|
1348
1365
|
variant: z.enum(["A", "B"]).optional().describe("AB 测试时指定改哪一版"),
|
|
1349
1366
|
},
|
|
1350
1367
|
async (a) => {
|
|
1368
|
+
// 互斥校验必须前置:后端按 emailDesign 优先,同时传会静默忽略另一个,AI 会以为按自己意图改了
|
|
1369
|
+
if (a.email_design && a.html) {
|
|
1370
|
+
return {
|
|
1371
|
+
isError: true,
|
|
1372
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
1373
|
+
error: "email_design 与 html 互斥",
|
|
1374
|
+
next: "整体重做正文用 email_design;只想替换整份 HTML 用 html;只改主题/预览文本就只传 subject_line/preheader",
|
|
1375
|
+
}, null, 2) }],
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
if (a.email_design && a.message_text) {
|
|
1379
|
+
return {
|
|
1380
|
+
isError: true,
|
|
1381
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
1382
|
+
error: "email_design(邮件) 与 message_text(短信) 互斥",
|
|
1383
|
+
next: "邮件活动用 email_design,短信活动用 message_text",
|
|
1384
|
+
}, null, 2) }],
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1351
1387
|
if (a.html) {
|
|
1352
1388
|
const body = { campaignsId: a.campaigns_id, html: a.html };
|
|
1353
1389
|
if (a.subject_line !== undefined) body.subjectLine = a.subject_line;
|
|
@@ -1396,6 +1432,15 @@ defineTool(
|
|
|
1396
1432
|
frequency_unit: z.enum(["minute", "hour", "day"]).optional().describe("频率单位"),
|
|
1397
1433
|
},
|
|
1398
1434
|
async (a) => {
|
|
1435
|
+
if (a.email_design && (a.email_content || a.html)) {
|
|
1436
|
+
return {
|
|
1437
|
+
isError: true,
|
|
1438
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
1439
|
+
error: "email_design 与 email_content/html 互斥",
|
|
1440
|
+
next: "结构化内容用 email_design;已经有整份 HTML 就用 email_content(或 html 别名),只传一个",
|
|
1441
|
+
}, null, 2) }],
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1399
1444
|
const args = {
|
|
1400
1445
|
flowName: a.flow_name,
|
|
1401
1446
|
triggerKey: a.trigger_key,
|
package/package.json
CHANGED