@buzzposter/mcp 0.3.2 → 0.3.3

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/dist/index.js CHANGED
@@ -12,8 +12,8 @@ var BuzzPosterClient = class {
12
12
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
13
13
  this.apiKey = config.apiKey;
14
14
  }
15
- async request(method, path, body, query) {
16
- const url = new URL(`${this.baseUrl}${path}`);
15
+ async request(method, path2, body, query) {
16
+ const url = new URL(`${this.baseUrl}${path2}`);
17
17
  if (query) {
18
18
  for (const [k, v] of Object.entries(query)) {
19
19
  if (v !== void 0 && v !== "") url.searchParams.set(k, v);
@@ -107,13 +107,6 @@ var BuzzPosterClient = class {
107
107
  async deleteMedia(key) {
108
108
  return this.request("DELETE", `/api/v1/media/${encodeURIComponent(key)}`);
109
109
  }
110
- // Newsletter Preview (no ESP required)
111
- async createPreview(data) {
112
- return this.request("POST", "/api/v1/newsletters/preview", data);
113
- }
114
- async updatePreview(id, data) {
115
- return this.request("PUT", `/api/v1/newsletters/preview/${id}`, data);
116
- }
117
110
  // Newsletter
118
111
  async listSubscribers(params) {
119
112
  return this.request(
@@ -1067,37 +1060,27 @@ import {
1067
1060
  registerAppTool,
1068
1061
  RESOURCE_MIME_TYPE
1069
1062
  } from "@modelcontextprotocol/ext-apps/server";
1063
+ import * as fs from "fs";
1064
+ import * as path from "path";
1065
+ import { fileURLToPath } from "url";
1066
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
1070
1067
  var NEWSLETTER_STUDIO_RESOURCE = "ui://newsletter-studio/app.html";
1071
- function buildStudioHtml(apiUrl2) {
1072
- const base = apiUrl2.replace(/\/$/, "");
1073
- return `<!DOCTYPE html>
1074
- <html lang="en">
1075
- <head>
1076
- <meta charset="utf-8">
1077
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
1078
- <link rel="stylesheet" href="${base}/newsletter-assets/newsletter-studio.css">
1079
- <style>html,body,#root{margin:0;padding:0;height:100%;}</style>
1080
- </head>
1081
- <body>
1082
- <div id="root"></div>
1083
- <script type="module" src="${base}/newsletter-assets/newsletter-studio.js"></script>
1084
- </body>
1085
- </html>`;
1086
- }
1087
1068
  function registerNewsletterTools(server2, client2, options = {}) {
1088
- const apiUrl2 = options.apiUrl || "";
1089
1069
  registerAppResource(
1090
1070
  server2,
1091
1071
  NEWSLETTER_STUDIO_RESOURCE,
1092
1072
  NEWSLETTER_STUDIO_RESOURCE,
1093
1073
  { mimeType: RESOURCE_MIME_TYPE },
1094
1074
  async () => {
1075
+ const distDir = __dirname.endsWith("dist") ? __dirname : path.resolve(__dirname, "..", "dist");
1076
+ const htmlPath = path.join(distDir, "newsletter-studio.html");
1077
+ const html = fs.readFileSync(htmlPath, "utf-8");
1095
1078
  return {
1096
1079
  contents: [
1097
1080
  {
1098
1081
  uri: NEWSLETTER_STUDIO_RESOURCE,
1099
1082
  mimeType: RESOURCE_MIME_TYPE,
1100
- text: buildStudioHtml(apiUrl2)
1083
+ text: html
1101
1084
  }
1102
1085
  ]
1103
1086
  };
@@ -1157,8 +1140,8 @@ function registerNewsletterTools(server2, client2, options = {}) {
1157
1140
  server2,
1158
1141
  "create_newsletter",
1159
1142
  {
1160
- title: "Create Newsletter Preview",
1161
- description: "Create a newsletter preview. Uploads HTML to a preview URL for review in Newsletter Studio. Does NOT push to ESP \u2014 use push_newsletter_to_esp for that. Always call get_brand_voice first. Use table-based layouts, inline CSS only, 600px max width, email-safe fonts only (Arial, Helvetica, Georgia, Verdana), all images must use absolute URLs, keep under 102KB to avoid Gmail clipping.",
1143
+ title: "Create Newsletter Draft",
1144
+ description: "Push a newsletter to the user's ESP as a draft. Always call get_brand_voice first. Show an HTML preview to the user before calling this. Use table-based layouts, inline CSS only, 600px max width, email-safe fonts only (Arial, Helvetica, Georgia, Verdana), all images must use absolute URLs, keep under 102KB to avoid Gmail clipping. Optionally pass template_id to use an ESP-native template. Use list_esp_templates to discover available templates.",
1162
1145
  inputSchema: {
1163
1146
  subject: z5.string().describe("Email subject line"),
1164
1147
  content: z5.string().describe("HTML content of the newsletter"),
@@ -1172,17 +1155,15 @@ function registerNewsletterTools(server2, client2, options = {}) {
1172
1155
  resourceUri: NEWSLETTER_STUDIO_RESOURCE,
1173
1156
  csp: {
1174
1157
  resourceDomains: [
1175
- apiUrl2,
1176
1158
  "https://cdn.jsdelivr.net",
1177
1159
  "https://fonts.googleapis.com",
1178
1160
  "https://fonts.gstatic.com",
1179
1161
  "https://unpkg.com"
1180
- ].filter(Boolean),
1162
+ ],
1181
1163
  connectDomains: [
1182
- apiUrl2,
1183
1164
  "https://fonts.googleapis.com",
1184
1165
  "https://fonts.gstatic.com"
1185
- ].filter(Boolean)
1166
+ ]
1186
1167
  }
1187
1168
  }
1188
1169
  }
@@ -1194,7 +1175,7 @@ function registerNewsletterTools(server2, client2, options = {}) {
1194
1175
  previewText: args.preview_text
1195
1176
  };
1196
1177
  if (args.template_id) payload.templateId = args.template_id;
1197
- const result = await client2.createPreview(payload);
1178
+ const result = await client2.createBroadcast(payload);
1198
1179
  const response = {
1199
1180
  ...result,
1200
1181
  subject: args.subject,
@@ -1202,7 +1183,6 @@ function registerNewsletterTools(server2, client2, options = {}) {
1202
1183
  previewText: args.preview_text
1203
1184
  };
1204
1185
  return {
1205
- _meta: { ui: { resourceUri: NEWSLETTER_STUDIO_RESOURCE } },
1206
1186
  content: [
1207
1187
  { type: "text", text: JSON.stringify(response, null, 2) }
1208
1188
  ]
@@ -1211,15 +1191,15 @@ function registerNewsletterTools(server2, client2, options = {}) {
1211
1191
  );
1212
1192
  server2.tool(
1213
1193
  "update_newsletter",
1214
- "Update an existing newsletter preview.",
1194
+ "Update an existing newsletter draft.",
1215
1195
  {
1216
- preview_id: z5.string().describe("The preview ID to update"),
1196
+ broadcast_id: z5.string().describe("The broadcast/newsletter ID to update"),
1217
1197
  subject: z5.string().optional().describe("Updated subject line"),
1218
1198
  content: z5.string().optional().describe("Updated HTML content"),
1219
1199
  preview_text: z5.string().optional().describe("Updated preview text")
1220
1200
  },
1221
1201
  {
1222
- title: "Update Newsletter Preview",
1202
+ title: "Update Newsletter Draft",
1223
1203
  readOnlyHint: false,
1224
1204
  destructiveHint: false,
1225
1205
  idempotentHint: true,
@@ -1230,45 +1210,7 @@ function registerNewsletterTools(server2, client2, options = {}) {
1230
1210
  if (args.subject) data.subject = args.subject;
1231
1211
  if (args.content) data.content = args.content;
1232
1212
  if (args.preview_text) data.previewText = args.preview_text;
1233
- const result = await client2.updatePreview(args.preview_id, data);
1234
- const response = {
1235
- ...result,
1236
- subject: args.subject,
1237
- content: args.content,
1238
- previewText: args.preview_text
1239
- };
1240
- return {
1241
- _meta: { ui: { resourceUri: NEWSLETTER_STUDIO_RESOURCE } },
1242
- content: [
1243
- { type: "text", text: JSON.stringify(response, null, 2) }
1244
- ]
1245
- };
1246
- }
1247
- );
1248
- server2.tool(
1249
- "push_newsletter_to_esp",
1250
- "Push a newsletter to the user's ESP as a draft broadcast. Requires ESP to be configured. Use create_newsletter first for preview, then push when the user is happy with the content.",
1251
- {
1252
- subject: z5.string().describe("Email subject line"),
1253
- content: z5.string().describe("HTML content of the newsletter"),
1254
- preview_text: z5.string().optional().describe("Preview text shown in email clients"),
1255
- template_id: z5.string().optional().describe("ESP-native template ID")
1256
- },
1257
- {
1258
- title: "Push Newsletter to ESP",
1259
- readOnlyHint: false,
1260
- destructiveHint: false,
1261
- idempotentHint: false,
1262
- openWorldHint: true
1263
- },
1264
- async (args) => {
1265
- const payload = {
1266
- subject: args.subject,
1267
- content: args.content,
1268
- previewText: args.preview_text
1269
- };
1270
- if (args.template_id) payload.templateId = args.template_id;
1271
- const result = await client2.createBroadcast(payload);
1213
+ const result = await client2.updateBroadcast(args.broadcast_id, data);
1272
1214
  const response = {
1273
1215
  ...result,
1274
1216
  subject: args.subject,
@@ -3931,7 +3873,7 @@ registerAccountTools(server, client);
3931
3873
  registerAnalyticsTools(server, client);
3932
3874
  registerInboxTools(server, client);
3933
3875
  registerMediaTools(server, client);
3934
- registerNewsletterTools(server, client, { allowDirectSend, apiUrl });
3876
+ registerNewsletterTools(server, client, { allowDirectSend });
3935
3877
  registerRssTools(server, client);
3936
3878
  registerAccountInfoTool(server, client);
3937
3879
  registerBrandVoiceTools(server, client);