@buzzposter/mcp 0.3.0 → 0.3.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/dist/tools.d.ts CHANGED
@@ -122,6 +122,7 @@ declare function registerMediaTools(server: McpServer, client: BuzzPosterClient)
122
122
 
123
123
  interface NewsletterToolOptions {
124
124
  allowDirectSend?: boolean;
125
+ apiUrl?: string;
125
126
  }
126
127
  declare function registerNewsletterTools(server: McpServer, client: BuzzPosterClient, options?: NewsletterToolOptions): void;
127
128
 
package/dist/tools.js CHANGED
@@ -6,8 +6,8 @@ var BuzzPosterClient = class {
6
6
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
7
7
  this.apiKey = config.apiKey;
8
8
  }
9
- async request(method, path2, body, query) {
10
- const url = new URL(`${this.baseUrl}${path2}`);
9
+ async request(method, path, body, query) {
10
+ const url = new URL(`${this.baseUrl}${path}`);
11
11
  if (query) {
12
12
  for (const [k, v] of Object.entries(query)) {
13
13
  if (v !== void 0 && v !== "") url.searchParams.set(k, v);
@@ -1061,27 +1061,37 @@ import {
1061
1061
  registerAppTool,
1062
1062
  RESOURCE_MIME_TYPE
1063
1063
  } from "@modelcontextprotocol/ext-apps/server";
1064
- import * as fs from "fs";
1065
- import * as path from "path";
1066
- import { fileURLToPath } from "url";
1067
- var __dirname = path.dirname(fileURLToPath(import.meta.url));
1068
1064
  var NEWSLETTER_STUDIO_RESOURCE = "ui://newsletter-studio/app.html";
1065
+ function buildStudioHtml(apiUrl) {
1066
+ const base = apiUrl.replace(/\/$/, "");
1067
+ return `<!DOCTYPE html>
1068
+ <html lang="en">
1069
+ <head>
1070
+ <meta charset="utf-8">
1071
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1072
+ <link rel="stylesheet" href="${base}/newsletter-assets/newsletter-studio.css">
1073
+ <style>html,body,#root{margin:0;padding:0;height:100%;}</style>
1074
+ </head>
1075
+ <body>
1076
+ <div id="root"></div>
1077
+ <script type="module" src="${base}/newsletter-assets/newsletter-studio.js"></script>
1078
+ </body>
1079
+ </html>`;
1080
+ }
1069
1081
  function registerNewsletterTools(server, client, options = {}) {
1082
+ const apiUrl = options.apiUrl || "";
1070
1083
  registerAppResource(
1071
1084
  server,
1072
1085
  NEWSLETTER_STUDIO_RESOURCE,
1073
1086
  NEWSLETTER_STUDIO_RESOURCE,
1074
1087
  { mimeType: RESOURCE_MIME_TYPE },
1075
1088
  async () => {
1076
- const distDir = __dirname.endsWith("dist") ? __dirname : path.resolve(__dirname, "..", "dist");
1077
- const htmlPath = path.join(distDir, "newsletter-studio.html");
1078
- const html = fs.readFileSync(htmlPath, "utf-8");
1079
1089
  return {
1080
1090
  contents: [
1081
1091
  {
1082
1092
  uri: NEWSLETTER_STUDIO_RESOURCE,
1083
1093
  mimeType: RESOURCE_MIME_TYPE,
1084
- text: html
1094
+ text: buildStudioHtml(apiUrl)
1085
1095
  }
1086
1096
  ]
1087
1097
  };
@@ -1156,15 +1166,17 @@ function registerNewsletterTools(server, client, options = {}) {
1156
1166
  resourceUri: NEWSLETTER_STUDIO_RESOURCE,
1157
1167
  csp: {
1158
1168
  resourceDomains: [
1169
+ apiUrl,
1159
1170
  "https://cdn.jsdelivr.net",
1160
1171
  "https://fonts.googleapis.com",
1161
1172
  "https://fonts.gstatic.com",
1162
1173
  "https://unpkg.com"
1163
- ],
1174
+ ].filter(Boolean),
1164
1175
  connectDomains: [
1176
+ apiUrl,
1165
1177
  "https://fonts.googleapis.com",
1166
1178
  "https://fonts.gstatic.com"
1167
- ]
1179
+ ].filter(Boolean)
1168
1180
  }
1169
1181
  }
1170
1182
  }
@@ -1184,6 +1196,7 @@ function registerNewsletterTools(server, client, options = {}) {
1184
1196
  previewText: args.preview_text
1185
1197
  };
1186
1198
  return {
1199
+ _meta: { ui: { resourceUri: NEWSLETTER_STUDIO_RESOURCE } },
1187
1200
  content: [
1188
1201
  { type: "text", text: JSON.stringify(response, null, 2) }
1189
1202
  ]
@@ -1219,6 +1232,7 @@ function registerNewsletterTools(server, client, options = {}) {
1219
1232
  previewText: args.preview_text
1220
1233
  };
1221
1234
  return {
1235
+ _meta: { ui: { resourceUri: NEWSLETTER_STUDIO_RESOURCE } },
1222
1236
  content: [
1223
1237
  { type: "text", text: JSON.stringify(response, null, 2) }
1224
1238
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buzzposter/mcp",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "BuzzPoster MCP server - Social media, newsletters, and media hosting for any AI chatbot",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",