@mambasms/mcp-server 0.6.2 → 0.6.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.
- package/README.md +11 -10
- package/index.js +118 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,23 +18,24 @@ MambaSMS 邮件模板 MCP server(stdio)。让 AI 工具(Codex / Claude Desktop /
|
|
|
18
18
|
| `template_snippets` | 页头/页脚 HTML 片段(含社交图标) |
|
|
19
19
|
|
|
20
20
|
通用发现/调度(0.6.0,参考 Omnisend MCP):
|
|
21
|
-
| `mamba_search` / `mamba_tool_schema` / `mamba_execute` | 搜索操作 / 查参数 / 按名执行 |
|
|
21
|
+
| `mamba_guide` / `mamba_search` / `mamba_tool_schema` / `mamba_execute` | 能力总览(按主题) / 搜索操作 / 查参数 / 按名执行 |
|
|
22
22
|
|
|
23
|
-
环境变量 `MAMBA_READONLY=1` 时只注册只读工具(
|
|
23
|
+
环境变量 `MAMBA_READONLY=1` 时只注册只读工具(52→36),写操作一律拒绝。
|
|
24
24
|
|
|
25
25
|
创建时后端自动做两类校验(非阻断,以 `warnings` 返回给 AI 自纠):
|
|
26
26
|
- 缺少退订占位符 `{Unsubscribe}`
|
|
27
27
|
- `{{ }}` 花括号混用(引擎只支持单花括号,混用会导致发送失败)
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## 只读与质检(23 个,统一 page/page_size 分页,报表默认近 180 天)
|
|
30
30
|
|
|
31
31
|
| Tool | 说明 |
|
|
32
32
|
|---|---|
|
|
33
33
|
| `campaign_list` / `campaign_report` / `campaign_link_report` / `campaign_abtest_result` / `campaign_content` | 活动列表 / 单活动指标 / 链接点击 / AB 结果 / 内容审核 |
|
|
34
34
|
| `flow_list` / `flow_report` / `flow_send_failure` / `flow_content` / `flow_triggers` | 自动化列表 / 指标 / 失败明细 / 结构 / 触发器目录 |
|
|
35
35
|
| `group_list` / `group_catalog` / `group_members` | 分组列表 / 条件目录(真源) / 成员分页 |
|
|
36
|
-
| `contact_get` / `contact_send_status`
|
|
36
|
+
| `contact_get` / `contact_send_status` | 联系人精确查(含订单聚合/订阅状态) / 收信状态 |
|
|
37
37
|
| `audience_growth` / `form_performance` / `domain_health` / `store_overview` / `order_stats` / `account_balance` | 受众增长 / 表单 / 发件域健康 / 经营概览 / 订单 / 余额 |
|
|
38
|
+
| `email_audit` / `brand_profile` | 邮件质检(13 条规则+评分,`deep=true` 追加模型审查) / 品牌声音档案 |
|
|
38
39
|
|
|
39
40
|
口径:订单类已排除 `CANCELLED`;余额单位美元且为 group 级;联系人只支持精确查。
|
|
40
41
|
|
|
@@ -110,17 +111,17 @@ env = { "MAMBA_API_BASE" = "https://api.mambasms.com", "MAMBA_ACCESS_TOKEN" = "s
|
|
|
110
111
|
## 回归测试
|
|
111
112
|
|
|
112
113
|
```bash
|
|
113
|
-
# HTTP 层全能力(
|
|
114
|
+
# HTTP 层全能力(50 项)
|
|
114
115
|
python scripts/smoke.py --base https://olapapi.mambasend.com --token shop_xxx
|
|
115
116
|
|
|
116
|
-
# MCP stdio 层(
|
|
117
|
+
# MCP stdio 层(工具暴露/分组闸门/目录/质检接通/建组/幻觉字段拒绝,真起 server 走 JSON-RPC)
|
|
117
118
|
node scripts/mcp_stdio_probe.mjs --base https://olapapi.mambasend.com --token shop_xxx
|
|
118
119
|
```
|
|
119
120
|
|
|
120
|
-
覆盖
|
|
121
|
-
|
|
121
|
+
覆盖 50 项:模板域(列表/详情/建/改/删/预览/上传/系统模板/规范目录/区块库/设计路径/导出导入)、
|
|
122
|
+
只读与质检(分页、时间窗、分组成员、联系人精确查/412、订单与余额、邮件质检评分、品牌档案)、助手读代理、
|
|
122
123
|
写草稿(邮件/短信/HTML活动/流程/分组 含嵌套条件与 OR 结构)、
|
|
123
124
|
以及防护(改已发送→412、非白名单→412、幻觉字段→412)。
|
|
124
125
|
|
|
125
|
-
`mcp_stdio_probe.mjs` 额外验证 `index.js`
|
|
126
|
-
|
|
126
|
+
`mcp_stdio_probe.mjs` 额外验证 `index.js` 自己的逻辑:工具清单(52)、`mamba_guide` 总览与分主题、未查 `group_catalog` 直接建组会被 `isError` 拦下、
|
|
127
|
+
查过之后放行、`email_audit`/`brand_profile` 已接通;会在测试店铺真实建分组(名称带「探针」前缀),只读验证加 `--no-write`。
|
package/index.js
CHANGED
|
@@ -102,17 +102,16 @@ function defineTool(name, description, shape, handler) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
const server = new McpServer(
|
|
105
|
-
{ name: "mambasms-mcp-server", version: "0.6.
|
|
105
|
+
{ name: "mambasms-mcp-server", version: "0.6.4" },
|
|
106
106
|
{
|
|
107
|
-
instructions: `MambaSMS
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
B) template_create(html) —— 迁移现成 HTML /
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
页脚与社交链接:不要自己发明图标地址,用 template_snippets(type=footer-social) 的片段,图标走 https://link.mambasms.com/dynamicImage/{platform}/{size}/{shape}/{color};平台 key 大小写敏感(youTube/linkedIn/soundCloud)。退订必须 {Unsubscribe}。
|
|
107
|
+
instructions: `MambaSMS 营销自动化(店铺级,鉴权用 MAMBA_ACCESS_TOKEN 店铺密钥)。共 52 个工具,分四组。
|
|
108
|
+
不确定用什么/想先看总览 → mamba_guide;只知道关键词 → mamba_search;要参数细节 → mamba_tool_schema。
|
|
109
|
+
|
|
110
|
+
【模板(17)】四条创建路径:A) template_create_from_design —— 首选,传结构化 emailDesign(style/theme/hero/intro/products/offer/cta/social),写前先 catalog_query(topic=emailDesign);要骨架传 catalog_query(topic=layouts);套已有模板传 templateId。B) template_create(html) —— 迁移现成 HTML/精细控制。C) template_create(sections) —— 动态区块(购物车/浏览列表),发送时填该联系人的数据。D) template_import —— mambatpl 或 zipHtml。参考面:template_list_system/template_get_system、block_library_query、catalog_query、template_snippets(页头页脚片段,社交图标走 link.mambasms.com/dynamicImage/{platform}/{size}/{shape}/{color},key 大小写敏感)。效果:template_preview(免登永久链接)、template_send_test。图片用 upload_image 转存 CDN。退订必须 {Unsubscribe}。
|
|
111
|
+
【只读/质检(23)】活动 campaign_*、流程 flow_*、分组 group_*、联系人 contact_get/contact_send_status、报表 audience_growth/form_performance/domain_health/store_overview/order_stats/account_balance、质检 email_audit、品牌 brand_profile。列表统一 page/page_size(≤100,默认 20);报表默认近 180 天,可传 start_date/end_date 覆盖;订单已排除 CANCELLED;余额单位为美元且是 group 级(同集团多店共享);联系人只支持精确查。
|
|
112
|
+
【写=只建草稿(8)】campaign_create_email/sms/abtest/smsabtest、campaign_update_content、flow_create、flow_update_content、user_group_create。一律 draft:不发送、不启用、不扣费;update 仅 draft 可改(否则 412);建分组前必须先 group_catalog 取真源(否则拒绝);活动指定人群用 communication_select=tag + tag_id。正文质量闸门:活动渲染后 ≥4200 字符、流程邮件节点 ≥3000 字符、须含 {Unsubscribe}、买家可见文案英文。
|
|
113
|
+
【通用(4)】mamba_guide 总览、mamba_search 搜索、mamba_tool_schema 查参数、mamba_execute 按名执行。MAMBA_READONLY=1 时只注册只读工具(52→35)。
|
|
114
|
+
明确不做:发送/启用/中断发送、删除活动、联系人模糊全表搜、拖拽式精修(留给后台)。
|
|
116
115
|
${PLACEHOLDER_GUIDE}`,
|
|
117
116
|
}
|
|
118
117
|
);
|
|
@@ -712,6 +711,37 @@ defineTool(
|
|
|
712
711
|
}
|
|
713
712
|
);
|
|
714
713
|
|
|
714
|
+
defineTool(
|
|
715
|
+
"email_audit",
|
|
716
|
+
"邮件质检(与平台 AI 助手同一套 13 条规则):返回评分 score/等级 level/问题清单 issues(规则+位置 locator+修改建议)。" +
|
|
717
|
+
"可审活动正文(source=campaigns)或流程邮件节点(source=flow,需 flow_id+node_uuid);deep=true 追加模型语义审查。",
|
|
718
|
+
{
|
|
719
|
+
source: z.enum(["campaigns", "flow"]).default("campaigns").describe("审活动还是自动化流程节点"),
|
|
720
|
+
campaigns_id: z.string().optional().describe("活动id(source=campaigns 时必传)"),
|
|
721
|
+
flow_id: z.string().optional().describe("流程id(source=flow 时必传)"),
|
|
722
|
+
node_uuid: z.string().optional().describe("流程邮件节点uuid(source=flow:flow_content 可查到)"),
|
|
723
|
+
deep: z.boolean().default(false).describe("true=额外跑模型语义审查(更慢,会消耗模型额度)"),
|
|
724
|
+
},
|
|
725
|
+
async ({ source, campaigns_id, flow_id, node_uuid, deep }) => {
|
|
726
|
+
const args = { source, deep: !!deep };
|
|
727
|
+
if (campaigns_id) args.campaignsId = campaigns_id;
|
|
728
|
+
if (flow_id) args.flowId = flow_id;
|
|
729
|
+
if (node_uuid) args.nodeUuid = node_uuid;
|
|
730
|
+
const data = await callAssistantTool("audit_email", args);
|
|
731
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
732
|
+
}
|
|
733
|
+
);
|
|
734
|
+
|
|
735
|
+
defineTool(
|
|
736
|
+
"brand_profile",
|
|
737
|
+
"读取店铺品牌声音档案(品牌语气/禁用词/核心卖点),用于写出与品牌一致的文案;未设置时返回 status=empty 与提示。",
|
|
738
|
+
{},
|
|
739
|
+
async () => {
|
|
740
|
+
const data = await callAssistantTool("get_brand_profile", {});
|
|
741
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
742
|
+
}
|
|
743
|
+
);
|
|
744
|
+
|
|
715
745
|
defineTool(
|
|
716
746
|
"audience_growth",
|
|
717
747
|
"受众增长趋势(按天):新增联系人/邮件订阅/短信订阅。默认30天(上限90)。",
|
|
@@ -1121,7 +1151,7 @@ name 最长 20 字。创建后 status=draft,人数由后台异步打包(可用 g
|
|
|
1121
1151
|
type: "text",
|
|
1122
1152
|
text: JSON.stringify({
|
|
1123
1153
|
error: "创建分组前必须先调用 group_catalog",
|
|
1124
|
-
next: "先调 group_catalog(不传参=数据域清单+通用规则;传 nested_path 如 success_checkout
|
|
1154
|
+
next: "先调 group_catalog(不传参=数据域清单+通用规则;传 nested_path 如 success_checkout=该域真实字段+写条件规则,多个域分多次查),再按返回的字段生成 query_content 重试",
|
|
1125
1155
|
why: "query_content 只能使用目录里真实存在的 field/nestedPath,凭印象写会被后端校验拒绝",
|
|
1126
1156
|
}, null, 2),
|
|
1127
1157
|
}],
|
|
@@ -1136,6 +1166,83 @@ name 最长 20 字。创建后 status=draft,人数由后台异步打包(可用 g
|
|
|
1136
1166
|
|
|
1137
1167
|
// ==================== 通用发现/调度工具(参考 Omnisend MCP 紧凑设计) ====================
|
|
1138
1168
|
|
|
1169
|
+
/** 能力总览(按主题返回,避免一次性灌 50 条工具说明) */
|
|
1170
|
+
const MCP_GUIDE = {
|
|
1171
|
+
templates: [
|
|
1172
|
+
"【模板 17 个】四条创建路径:",
|
|
1173
|
+
"A) template_create_from_design —— 首选。传结构化 emailDesign(style/theme/hero/intro/products/offer/cta/social),先 catalog_query(topic=emailDesign) 查规范;要骨架传 catalog_query(topic=layouts);套已有模板传 templateId。",
|
|
1174
|
+
"B) template_create(html) —— 迁移现成 HTML / 精细控制。",
|
|
1175
|
+
"C) template_create(sections) —— 动态区块(购物车/浏览列表),发送时自动填该联系人数据。",
|
|
1176
|
+
"D) template_import —— .mambatpl 平台模板 或 zipHtml(设计工具导出的 zip,图片自动转存 CDN)。",
|
|
1177
|
+
"辅助:template_list / template_get / template_update / template_delete / upload_image /",
|
|
1178
|
+
" template_list_system / template_get_system / template_system_categories(系统模板参考)/",
|
|
1179
|
+
" catalog_query(规范目录)/ block_library_query(预置区块)/ template_snippets(页头页脚片段)/",
|
|
1180
|
+
" template_preview(免登永久链接)/ template_send_test(发测试邮件)/ template_export / template_import。",
|
|
1181
|
+
"硬规则:退订必须 {Unsubscribe};社交图标用 template_snippets(type=footer-social) 的地址,key 大小写敏感。",
|
|
1182
|
+
].join("\n"),
|
|
1183
|
+
insights: [
|
|
1184
|
+
"【只读/质检 23 个】列表统一 page/page_size(默认20,上限100):",
|
|
1185
|
+
"- 活动:campaign_list / campaign_report / campaign_link_report / campaign_abtest_result / campaign_content",
|
|
1186
|
+
"- 自动化:flow_list / flow_report / flow_send_failure / flow_content / flow_triggers",
|
|
1187
|
+
"- 分组:group_list / group_catalog(条件真源)/ group_members(自动区分手动/条件分组)",
|
|
1188
|
+
"- 联系人:contact_get(精确查,含订单聚合)/ contact_send_status",
|
|
1189
|
+
"- 报表:audience_growth / form_performance / domain_health / store_overview / order_stats / account_balance",
|
|
1190
|
+
"- 质检:email_audit(13 条规则+评分,deep=true 追加模型审查)/ brand_profile(品牌语气档案)",
|
|
1191
|
+
"口径:报表默认近 180 天(可传 start_date/end_date 覆盖);订单已排除 CANCELLED;余额单位美元且为 group 级;联系人只支持精确查。",
|
|
1192
|
+
].join("\n"),
|
|
1193
|
+
drafts: [
|
|
1194
|
+
"【写=只建草稿 8 个】campaign_create_email / _sms / _abtest / _smsabtest、campaign_update_content、flow_create、flow_update_content、user_group_create。",
|
|
1195
|
+
"- 一律 draft:不发送、不启用、不扣费;发送与启用仍需商家在后台确认。",
|
|
1196
|
+
"- update_* 仅 draft 可改,已发送/已启用返回 412。",
|
|
1197
|
+
"- 活动正文二选一:结构化 email_design 或整份 html(等同后台 HTML 编辑器);流程邮件节点同样支持整份 html。",
|
|
1198
|
+
"- 指定人群:communication_select=tag + tag_id;排除人群 non_send_tag_id。",
|
|
1199
|
+
"- 质量闸门:活动渲染后 ≥4200 字符、流程邮件节点 ≥3000 字符、须含 {Unsubscribe}、买家可见文案英文。",
|
|
1200
|
+
].join("\n"),
|
|
1201
|
+
groups: [
|
|
1202
|
+
"【建分组三步】① group_catalog 取真源(必做,否则被拒;30 分钟内免再查)② user_group_create(name≤20字 + query_content)③ group_list / group_members 复查人数与成员。",
|
|
1203
|
+
"query_content = 二维数组 JSON 字符串:外层 OR、内层 AND。",
|
|
1204
|
+
'- "A或B" = [[A],[B]](不是 [[A,B]]);"A且(B或C)" = [[A,B],[A,C]];"(A或B)且没有C" = [[A,NOT C],[B,NOT C]]。',
|
|
1205
|
+
'- 时间写进 value:近30天下单 = {"field":"date_day","nestedPath":"success_checkout","condition":"gte","logic":"must","script":false,"value":"formerly:30"}。',
|
|
1206
|
+
'- 次数用 number:下过单=success_checkout、加购=shopping_cart、弃单=abandon_checkout。',
|
|
1207
|
+
"- 操作符只用 gte/gt/lt/lte/term_query/terms_query/fuzzy_query/not_fuzzy_query/exists_field/exists_field_not;禁止 eq/un_eq/empty/don_empty。",
|
|
1208
|
+
"- 人数由后台异步打包(实测数十秒),dynamicStatus=complete 后 userCount 才准。",
|
|
1209
|
+
].join("\n"),
|
|
1210
|
+
workflow: [
|
|
1211
|
+
"【推荐工作流】",
|
|
1212
|
+
"1) 从零做营销邮件:catalog_query(emailDesign) → template_create_from_design → template_preview → template_send_test → campaign_create_email(tag_id 指定人群) → email_audit",
|
|
1213
|
+
"2) 迁移现成 HTML:template_create(html) → template_preview → 用 template_id 建活动",
|
|
1214
|
+
"3) 按条件圈人:group_catalog → user_group_create → group_list(看人数)→ group_members(看明细)",
|
|
1215
|
+
"4) 弃单/欢迎自动化:flow_triggers(查 triggerKey 与 filters)→ flow_create(html 或 email_design)→ flow_list 确认 draft",
|
|
1216
|
+
"5) 复盘:campaign_list → campaign_report → campaign_link_report;或 flow_report / flow_send_failure",
|
|
1217
|
+
"6) 工具不熟:mamba_guide(本总览)→ mamba_search(关键词)→ mamba_tool_schema(参数)→ mamba_execute",
|
|
1218
|
+
].join("\n"),
|
|
1219
|
+
boundaries: [
|
|
1220
|
+
"【边界】不做发送/启用/中断发送、不删除活动、不做联系人模糊全表搜索、不做拖拽式精修(留给后台)。",
|
|
1221
|
+
"写操作全部落 mb_mcp_operation_log 审计(X-Mamba-Source=mcp)。",
|
|
1222
|
+
"MAMBA_READONLY=1 只注册只读工具(52→35),写工具与 mamba_execute 的写操作都会被拒绝。",
|
|
1223
|
+
].join("\n"),
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
defineTool(
|
|
1227
|
+
"mamba_guide",
|
|
1228
|
+
"本 MCP 的能力总览(不传 topic 返回四组能力+推荐工作流+边界)。AI 刚接入、或想知道'你能做什么/怎么做'时先调它," +
|
|
1229
|
+
"再按需 mamba_search 找具体工具。",
|
|
1230
|
+
{
|
|
1231
|
+
topic: z
|
|
1232
|
+
.enum(["templates", "insights", "drafts", "groups", "workflow", "boundaries"])
|
|
1233
|
+
.optional()
|
|
1234
|
+
.describe("只看某一主题;不传=全部"),
|
|
1235
|
+
},
|
|
1236
|
+
async ({ topic }) => {
|
|
1237
|
+
const keys = topic ? [topic] : Object.keys(MCP_GUIDE);
|
|
1238
|
+
const text = [
|
|
1239
|
+
`MambaSMS MCP 能力总览(v0.6.4,共 ${TOOL_REGISTRY.size} 个工具)`,
|
|
1240
|
+
...keys.map((k) => MCP_GUIDE[k]),
|
|
1241
|
+
].join("\n\n");
|
|
1242
|
+
return { content: [{ type: "text", text }] };
|
|
1243
|
+
}
|
|
1244
|
+
);
|
|
1245
|
+
|
|
1139
1246
|
defineTool(
|
|
1140
1247
|
"mamba_search",
|
|
1141
1248
|
"搜索本 MCP 可用的操作(工具名+一句话说明+是否只读)。当你不确定该用哪个工具、或工具很多时,先 search 再 execute。",
|
package/package.json
CHANGED