@mambasms/mcp-server 0.1.3 → 0.2.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.
Files changed (2) hide show
  1. package/index.js +69 -11
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -92,23 +92,41 @@ server.tool(
92
92
 
93
93
  server.tool(
94
94
  "template_create",
95
- `创建邮件模板:传纯HTML(title+html),后端包装成平台编辑器结构,模板出现在后台「我的模板」,可被营销活动/自动化流程引用,也可在后台可视化微调。
96
- html 要求:完整邮件HTML、内联样式(客户端兼容)、必须含 {Unsubscribe} 退订占位符。
95
+ `创建邮件模板:两种方式二选一——
96
+ 1) html:传纯HTML(适合从零生成/迁移现有邮件);
97
+ 2) sections:语义化区块列表(推荐,支持购物车列表/浏览商品推荐等动态区块):
98
+ [{type:"html",html:"..."}, {type:"cart_list",buttonText:"Back to Cart",limit:3},
99
+ {type:"browse_list",buttonText:"TAKE ANOTHER LOOK",limit:2}, ...]
100
+ 动态区块在发送时自动填充该联系人的购物车/浏览商品数据。
101
+ html/sections 都要求页脚含 {Unsubscribe} 退订占位符。创建后出现在后台「我的模板」,可被营销活动/自动化流程引用,也可在后台可视化微调。
97
102
  ${PLACEHOLDER_GUIDE}`,
98
103
  {
99
104
  title: z.string().min(1).max(100).describe("模板标题"),
100
105
  html: z
101
106
  .string()
102
- .min(1)
103
107
  .max(500000)
104
- .describe("完整邮件HTML,内联样式,必须含 {Unsubscribe}"),
108
+ .optional()
109
+ .describe("完整邮件HTML(与 sections 二选一)"),
110
+ sections: z
111
+ .array(
112
+ z.object({
113
+ type: z.enum(["html", "cart_list", "browse_list"]).describe("区块类型"),
114
+ html: z.string().optional().describe("type=html 时的HTML内容"),
115
+ buttonText: z.string().optional().describe("动态区块按钮文案"),
116
+ buttonStyle: z.enum(["primaryButton", "secondaryButton"]).optional().describe("按钮样式"),
117
+ limit: z.number().int().min(1).max(10).optional().describe("动态区块展示商品数(1~10)"),
118
+ })
119
+ )
120
+ .max(20)
121
+ .optional()
122
+ .describe("语义化区块列表(与 html 二选一)"),
105
123
  summary: z.string().optional().describe("模板备注/摘要,可选"),
106
124
  },
107
- async ({ title, html, summary }) => {
108
- const body = { title, html };
109
- if (summary !== undefined) {
110
- body.summary = summary;
111
- }
125
+ async ({ title, html, sections, summary }) => {
126
+ const body = { title };
127
+ if (html !== undefined) body.html = html;
128
+ if (sections !== undefined) body.sections = sections;
129
+ if (summary !== undefined) body.summary = summary;
112
130
  const data = await callApi("/api/v1/template/create", body);
113
131
  return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
114
132
  }
@@ -116,24 +134,64 @@ ${PLACEHOLDER_GUIDE}`,
116
134
 
117
135
  server.tool(
118
136
  "template_update",
119
- `更新已有模板(id 必填;title/html/summary 至少传一个)。html 不传则保留原内容(可只改标题/摘要)。
137
+ `更新已有模板(id 必填;title/html/sections/summary 至少传一个)。html/sections 不传则保留原内容(可只改标题/摘要)。
120
138
  ${PLACEHOLDER_GUIDE}`,
121
139
  {
122
140
  id: z.string().min(1).describe("模板id"),
123
141
  title: z.string().min(1).max(100).optional().describe("新标题,可选"),
124
142
  html: z.string().min(1).max(500000).optional().describe("新HTML,可选;不传则保留原内容"),
143
+ sections: z
144
+ .array(
145
+ z.object({
146
+ type: z.enum(["html", "cart_list", "browse_list"]).describe("区块类型"),
147
+ html: z.string().optional().describe("type=html 时的HTML内容"),
148
+ buttonText: z.string().optional().describe("动态区块按钮文案"),
149
+ buttonStyle: z.enum(["primaryButton", "secondaryButton"]).optional().describe("按钮样式"),
150
+ limit: z.number().int().min(1).max(10).optional().describe("动态区块展示商品数(1~10)"),
151
+ })
152
+ )
153
+ .optional()
154
+ .describe("语义化区块列表(整体替换原内容)"),
125
155
  summary: z.string().optional().describe("新摘要,可选"),
126
156
  },
127
- async ({ id, title, html, summary }) => {
157
+ async ({ id, title, html, sections, summary }) => {
128
158
  const body = { id };
129
159
  if (title !== undefined) body.title = title;
130
160
  if (html !== undefined) body.html = html;
161
+ if (sections !== undefined) body.sections = sections;
131
162
  if (summary !== undefined) body.summary = summary;
132
163
  const data = await callApi("/api/v1/template/create", body);
133
164
  return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
134
165
  }
135
166
  );
136
167
 
168
+ server.tool(
169
+ "upload_image",
170
+ "上传图片到平台CDN,返回可直接用于模板HTML的图片URL。推荐用图片URL转存(商品图/图床图片);上传后把返回的 url 写进模板HTML的 <img src>。",
171
+ {
172
+ url: z.string().optional().describe("图片URL(http/https,jpg/jpeg/png/gif/webp,≤5MB)"),
173
+ },
174
+ async ({ url }) => {
175
+ if (url === undefined) {
176
+ throw new Error("url is required");
177
+ }
178
+ const data = await callApi("/api/v1/file/upload-from-url", { url });
179
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
180
+ }
181
+ );
182
+
183
+ server.tool(
184
+ "template_delete",
185
+ "删除模板。⚠️ 被营销活动/自动化流程引用中的模板无法删除(会返回引用数量)。删除前建议先和用户确认。",
186
+ {
187
+ id: z.string().min(1).describe("模板id"),
188
+ },
189
+ async ({ id }) => {
190
+ const data = await callApi("/api/v1/template/delete", { id });
191
+ return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
192
+ }
193
+ );
194
+
137
195
  const transport = new StdioServerTransport();
138
196
  await server.connect(transport);
139
197
  console.error(`mambasms-mcp-server ready, api=${API_BASE}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mambasms/mcp-server",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for MambaSMS email templates - create/manage templates from AI agents (Codex, Claude Desktop, Cursor)",
5
5
  "type": "module",
6
6
  "bin": {