@mambasms/mcp-server 0.5.0 → 0.5.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/index.js +43 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -56,7 +56,7 @@ async function callApi(path, body) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
const server = new McpServer(
|
|
59
|
-
{ name: "mambasms-mcp-server", version: "0.5.
|
|
59
|
+
{ name: "mambasms-mcp-server", version: "0.5.2" },
|
|
60
60
|
{
|
|
61
61
|
instructions: `MambaSMS 邮件模板管理(店铺级,鉴权用 MAMBA_ACCESS_TOKEN)。
|
|
62
62
|
四条创建路径,按场景选(另有一组只读洞察工具(活动/流程/分组/联系人/报表/余额)与一组写工具(活动/流程草稿、建分组;只建草稿不发送)):
|
|
@@ -752,10 +752,17 @@ const DRAFT_NOTE = "⚠️本工具只创建/修改草稿,不会发送、不会
|
|
|
752
752
|
server.tool(
|
|
753
753
|
"campaign_create_email",
|
|
754
754
|
`创建邮件营销活动草稿。${DRAFT_NOTE}
|
|
755
|
-
|
|
755
|
+
正文两种写法:email_design(结构化JSON,推荐;先 catalog_query(topic=emailDesign) 查规范,或 template_list_system 选模板后传 template_id)或 html(整份 HTML,走后台 HTML 编辑器)。二者必传其一、互斥。`,
|
|
756
756
|
{
|
|
757
757
|
title: z.string().min(1).describe("活动名称"),
|
|
758
|
-
email_design: z
|
|
758
|
+
email_design: z
|
|
759
|
+
.string()
|
|
760
|
+
.optional()
|
|
761
|
+
.describe("邮件内容结构化 JSON 字符串(推荐;数组可传1-3版)。与 html 二选一"),
|
|
762
|
+
html: z
|
|
763
|
+
.string()
|
|
764
|
+
.optional()
|
|
765
|
+
.describe("整份邮件 HTML(贴现成 HTML / 迁移时用;走后台同款 HTML 编辑器 edition=richtext)。与 email_design 二选一"),
|
|
759
766
|
template_id: z.string().optional().describe("套用的系统模板 id(来自 template_list_system)"),
|
|
760
767
|
layout_skeleton: z
|
|
761
768
|
.enum(["promo-hero", "promo-flash", "single-spotlight", "new-arrival", "newsletter", "win-back"])
|
|
@@ -776,6 +783,26 @@ server.tool(
|
|
|
776
783
|
discount_code: z.string().optional().describe("折扣码"),
|
|
777
784
|
},
|
|
778
785
|
async (a) => {
|
|
786
|
+
if (!a.email_design && !a.html) {
|
|
787
|
+
throw new Error("either email_design or html is required");
|
|
788
|
+
}
|
|
789
|
+
if (a.email_design && a.html) {
|
|
790
|
+
throw new Error("email_design and html are mutually exclusive");
|
|
791
|
+
}
|
|
792
|
+
if (a.html) {
|
|
793
|
+
const body = { title: a.title, html: a.html };
|
|
794
|
+
for (const [k, v] of Object.entries({
|
|
795
|
+
subjectLine: a.subject_line,
|
|
796
|
+
preheader: a.preheader,
|
|
797
|
+
sendEmail: a.send_email,
|
|
798
|
+
sendName: a.send_name,
|
|
799
|
+
communicationSelect: a.communication_select,
|
|
800
|
+
tagId: a.tag_id,
|
|
801
|
+
nonSendTagId: a.non_send_tag_id,
|
|
802
|
+
})) if (v !== undefined) body[k] = v;
|
|
803
|
+
const data = await callApi("/api/v1/campaign/draft/create-html", body);
|
|
804
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
805
|
+
}
|
|
779
806
|
const args = { title: a.title, emailDesign: a.email_design };
|
|
780
807
|
const map = {
|
|
781
808
|
templateId: a.template_id,
|
|
@@ -910,7 +937,8 @@ server.tool(
|
|
|
910
937
|
campaigns_id: z.string().min(1).describe("活动id(campaign_list 返回)"),
|
|
911
938
|
subject_line: z.string().optional().describe("新主题"),
|
|
912
939
|
preheader: z.string().optional().describe("新预览文本"),
|
|
913
|
-
email_design: z.string().optional().describe("新的 emailDesign JSON(与 message_text 互斥)"),
|
|
940
|
+
email_design: z.string().optional().describe("新的 emailDesign JSON(与 message_text/html 互斥)"),
|
|
941
|
+
html: z.string().optional().describe("整份新邮件 HTML(走 HTML 编辑器;与 email_design/message_text 互斥)"),
|
|
914
942
|
layout_skeleton: z
|
|
915
943
|
.enum(["promo-hero", "promo-flash", "single-spotlight", "new-arrival", "newsletter", "win-back"])
|
|
916
944
|
.optional()
|
|
@@ -919,6 +947,13 @@ server.tool(
|
|
|
919
947
|
variant: z.enum(["A", "B"]).optional().describe("AB 测试时指定改哪一版"),
|
|
920
948
|
},
|
|
921
949
|
async (a) => {
|
|
950
|
+
if (a.html) {
|
|
951
|
+
const body = { campaignsId: a.campaigns_id, html: a.html };
|
|
952
|
+
if (a.subject_line !== undefined) body.subjectLine = a.subject_line;
|
|
953
|
+
if (a.preheader !== undefined) body.preheader = a.preheader;
|
|
954
|
+
const data = await callApi("/api/v1/campaign/draft/update-html", body);
|
|
955
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
956
|
+
}
|
|
922
957
|
const args = { campaignsId: a.campaigns_id };
|
|
923
958
|
const map = {
|
|
924
959
|
subjectLine: a.subject_line,
|
|
@@ -1007,8 +1042,10 @@ server.tool(
|
|
|
1007
1042
|
|
|
1008
1043
|
server.tool(
|
|
1009
1044
|
"user_group_create",
|
|
1010
|
-
`创建用户分组。⚠️必传 query_content
|
|
1011
|
-
|
|
1045
|
+
`创建用户分组。⚠️必传 query_content:二维数组的 JSON 字符串(外层=OR组,内层=AND条件),条件对象字段名为 field / condition / value / logic / nestedPath。
|
|
1046
|
+
例:[[{"field":"country","condition":"term_query","value":"US","logic":"must","nestedPath":""}]]
|
|
1047
|
+
condition 仅支持 gte/gt/lt/lte/term_query/terms_query/fuzzy_query/not_fuzzy_query/exists_field/exists_field_not;字段与 nestedPath 先用 group_catalog 查。
|
|
1048
|
+
创建后 status=draft,人数由系统后台打包计算(通常几分钟内出数)。`,
|
|
1012
1049
|
{
|
|
1013
1050
|
name: z.string().min(1).describe("分组名称"),
|
|
1014
1051
|
query_content: z.string().min(2).describe("条件树 JSON 字符串(见 group_catalog 规则)"),
|
package/package.json
CHANGED