@charisol/plexo-mcp 1.0.6 → 1.0.8

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.
@@ -115,6 +115,119 @@ class PlexoClient {
115
115
  }
116
116
  return data;
117
117
  }
118
+ /**
119
+ * Creates a landing page template WITHOUT publishing it — a thin wrapper
120
+ * around the same /api/v1/publish endpoint publishLandingPage() uses,
121
+ * just never forwarding a domain/type even if the caller passed one, so
122
+ * this tool's contract ("never publishes") holds regardless of input.
123
+ */
124
+ async createLandingPage(params) {
125
+ return this.publishLandingPage({ name: params.name, designJson: params.designJson });
126
+ }
127
+ /**
128
+ * Links a subdomain or custom domain to an already-existing landing page
129
+ * template (unlike publishLandingPage, which always creates a new one).
130
+ * Used both for a plain create_landing_page template and for the home
131
+ * page of a multi-page site once its sub-pages are ready.
132
+ */
133
+ async publishExistingLandingPage(params) {
134
+ this.checkAuth();
135
+ const type = params.type || (params.domain.includes(".") ? "CUSTOM" : "SUBDOMAIN");
136
+ const res = await fetch(`${this.baseUrl}/api/v1/domains`, {
137
+ method: "POST",
138
+ headers: this.getHeaders(),
139
+ body: JSON.stringify({ templateId: params.templateId, domain: params.domain, type }),
140
+ });
141
+ const data = (await res.json());
142
+ if (!res.ok) {
143
+ throw new Error(data?.error || `Publishing failed with status ${res.status}`);
144
+ }
145
+ return data;
146
+ }
147
+ /**
148
+ * Creates a new page nested under an existing landing page (its home page
149
+ * for a top-level page, or another sub-page's id to nest deeper) — how a
150
+ * single landing page becomes a multi-page site. Starts blank; use
151
+ * updateTemplate() with the returned templateId to add content.
152
+ */
153
+ async createLandingPageSubpage(params) {
154
+ this.checkAuth();
155
+ const res = await fetch(`${this.baseUrl}/api/templates`, {
156
+ method: "POST",
157
+ headers: this.getHeaders(),
158
+ body: JSON.stringify({ name: params.name, parentId: params.parentTemplateId, slug: params.slug }),
159
+ });
160
+ const data = (await res.json());
161
+ if (!res.ok) {
162
+ throw new Error(data?.error || `Sub-page creation failed with status ${res.status}`);
163
+ }
164
+ return data;
165
+ }
166
+ /**
167
+ * Returns every page belonging to the same multi-page site as templateId
168
+ * — its home page plus all nested sub-pages. templateId can be the home
169
+ * page or any sub-page; either way the whole tree comes back.
170
+ */
171
+ async getLandingPagePages(templateId) {
172
+ this.checkAuth();
173
+ const res = await fetch(`${this.baseUrl}/api/templates/${encodeURIComponent(templateId)}/pages`, {
174
+ method: "GET",
175
+ headers: this.getHeaders(),
176
+ });
177
+ const data = (await res.json());
178
+ if (!res.ok) {
179
+ throw new Error(data?.error || `Failed to fetch page tree (Status ${res.status})`);
180
+ }
181
+ return data;
182
+ }
183
+ /**
184
+ * Renames a page, changes its URL segment, moves it under a different
185
+ * parent, or reorders it among siblings. Does not touch page content —
186
+ * use updateTemplate() for that.
187
+ */
188
+ async updateLandingPagePage(params) {
189
+ this.checkAuth();
190
+ const { templateId, parentTemplateId, ...rest } = params;
191
+ const body = { ...rest };
192
+ if (parentTemplateId !== undefined)
193
+ body.parentId = parentTemplateId;
194
+ const res = await fetch(`${this.baseUrl}/api/templates/${encodeURIComponent(templateId)}`, {
195
+ method: "PATCH",
196
+ headers: this.getHeaders(),
197
+ body: JSON.stringify(body),
198
+ });
199
+ const data = (await res.json());
200
+ if (!res.ok) {
201
+ throw new Error(data?.error || `Page update failed with status ${res.status}`);
202
+ }
203
+ return data;
204
+ }
205
+ /** Deletes a page. Sub-pages nested under it are cascade-deleted too. */
206
+ async deleteLandingPagePage(templateId) {
207
+ this.checkAuth();
208
+ const res = await fetch(`${this.baseUrl}/api/templates/${encodeURIComponent(templateId)}`, {
209
+ method: "DELETE",
210
+ headers: this.getHeaders(),
211
+ });
212
+ const data = (await res.json());
213
+ if (!res.ok) {
214
+ throw new Error(data?.error || `Page deletion failed with status ${res.status}`);
215
+ }
216
+ return data;
217
+ }
218
+ /** Clones a sub-page's content into a new sibling page under the same parent. */
219
+ async duplicateLandingPagePage(templateId) {
220
+ this.checkAuth();
221
+ const res = await fetch(`${this.baseUrl}/api/templates/${encodeURIComponent(templateId)}/duplicate`, {
222
+ method: "POST",
223
+ headers: this.getHeaders(),
224
+ });
225
+ const data = (await res.json());
226
+ if (!res.ok) {
227
+ throw new Error(data?.error || `Page duplication failed with status ${res.status}`);
228
+ }
229
+ return data;
230
+ }
118
231
  async listTemplates() {
119
232
  this.checkAuth();
120
233
  const res = await fetch(`${this.baseUrl}/api/templates`, {
@@ -160,5 +273,112 @@ class PlexoClient {
160
273
  }
161
274
  return data;
162
275
  }
276
+ /** Fetches a single template's full details, including designJson — used by the blog
277
+ * layout tools to read back a layout template's current content (there's no other
278
+ * templateId-scoped GET in the public API; list endpoints only return metadata). */
279
+ async getTemplate(templateId) {
280
+ this.checkAuth();
281
+ const res = await fetch(`${this.baseUrl}/api/v1/templates/${encodeURIComponent(templateId)}`, {
282
+ method: "GET",
283
+ headers: this.getHeaders(),
284
+ });
285
+ const data = (await res.json());
286
+ if (!res.ok) {
287
+ throw new Error(data?.error || `Failed to fetch template (Status ${res.status})`);
288
+ }
289
+ return data;
290
+ }
291
+ /** Shared request helper for every /api/blog/{templateId}/... route below — these are
292
+ * the same admin endpoints the Plexo dashboard's own blog UI calls, and (like every
293
+ * other route in this client) accept the same Bearer/x-api-key auth as the rest of the
294
+ * public API (see resolveUser/resolveBlogAdminSite server-side). */
295
+ async blogFetch(method, templateId, path, body) {
296
+ this.checkAuth();
297
+ const res = await fetch(`${this.baseUrl}/api/blog/${encodeURIComponent(templateId)}${path}`, {
298
+ method,
299
+ headers: this.getHeaders(),
300
+ ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
301
+ });
302
+ const data = (await res.json().catch(() => ({})));
303
+ if (!res.ok) {
304
+ throw new Error(data?.error || `Blog request failed (Status ${res.status})`);
305
+ }
306
+ return data;
307
+ }
308
+ /** Idempotent — returns the existing layout template id if one's already attached to
309
+ * this kind rather than creating a duplicate. Pair with updateTemplate() to set its
310
+ * designJson (see blogTools.ts's designBlogLayout). */
311
+ async ensureBlogLayout(templateId, kind) {
312
+ return this.blogFetch("POST", templateId, `/layout/${kind}`);
313
+ }
314
+ /** Detaches the layout (reverts to the default theme) without deleting the underlying Template row. */
315
+ async resetBlogLayout(templateId, kind) {
316
+ return this.blogFetch("DELETE", templateId, `/layout/${kind}`);
317
+ }
318
+ async getBlogSite(templateId) {
319
+ return this.blogFetch("GET", templateId, "/site");
320
+ }
321
+ async updateBlogSite(templateId, patch) {
322
+ return this.blogFetch("PATCH", templateId, "/site", patch);
323
+ }
324
+ async listBlogPosts(templateId, params = {}) {
325
+ const query = new URLSearchParams();
326
+ if (params.status)
327
+ query.set("status", params.status);
328
+ if (params.search)
329
+ query.set("search", params.search);
330
+ if (params.categoryId)
331
+ query.set("categoryId", params.categoryId);
332
+ const qs = query.toString();
333
+ return this.blogFetch("GET", templateId, `/posts${qs ? `?${qs}` : ""}`);
334
+ }
335
+ async getBlogPost(templateId, postId) {
336
+ return this.blogFetch("GET", templateId, `/posts/${encodeURIComponent(postId)}`);
337
+ }
338
+ async createBlogPost(templateId, payload) {
339
+ return this.blogFetch("POST", templateId, "/posts", payload);
340
+ }
341
+ async updateBlogPost(templateId, postId, payload) {
342
+ return this.blogFetch("PATCH", templateId, `/posts/${encodeURIComponent(postId)}`, payload);
343
+ }
344
+ async deleteBlogPost(templateId, postId) {
345
+ return this.blogFetch("DELETE", templateId, `/posts/${encodeURIComponent(postId)}`);
346
+ }
347
+ async listBlogCategories(templateId) {
348
+ return this.blogFetch("GET", templateId, "/categories");
349
+ }
350
+ async createBlogCategory(templateId, payload) {
351
+ return this.blogFetch("POST", templateId, "/categories", payload);
352
+ }
353
+ async deleteBlogCategory(templateId, categoryId) {
354
+ return this.blogFetch("DELETE", templateId, `/categories/${encodeURIComponent(categoryId)}`);
355
+ }
356
+ async listBlogTags(templateId) {
357
+ return this.blogFetch("GET", templateId, "/tags");
358
+ }
359
+ async createBlogTag(templateId, name) {
360
+ return this.blogFetch("POST", templateId, "/tags", { name });
361
+ }
362
+ async deleteBlogTag(templateId, tagId) {
363
+ return this.blogFetch("DELETE", templateId, `/tags/${encodeURIComponent(tagId)}`);
364
+ }
365
+ async listBlogAuthors(templateId) {
366
+ return this.blogFetch("GET", templateId, "/authors");
367
+ }
368
+ async createBlogAuthor(templateId, payload) {
369
+ return this.blogFetch("POST", templateId, "/authors", payload);
370
+ }
371
+ async deleteBlogAuthor(templateId, authorId) {
372
+ return this.blogFetch("DELETE", templateId, `/authors/${encodeURIComponent(authorId)}`);
373
+ }
374
+ async listBlogComments(templateId, status) {
375
+ return this.blogFetch("GET", templateId, `/comments${status ? `?status=${encodeURIComponent(status)}` : ""}`);
376
+ }
377
+ async moderateBlogComment(templateId, commentId, status) {
378
+ return this.blogFetch("PATCH", templateId, `/comments/${encodeURIComponent(commentId)}`, { status });
379
+ }
380
+ async deleteBlogComment(templateId, commentId) {
381
+ return this.blogFetch("DELETE", templateId, `/comments/${encodeURIComponent(commentId)}`);
382
+ }
163
383
  }
164
384
  exports.PlexoClient = PlexoClient;
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
5
5
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
6
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
7
7
  const plexoClient_js_1 = require("./client/plexoClient.js");
8
+ const blogTools_js_1 = require("./blogTools.js");
8
9
  const server = new index_js_1.Server({
9
10
  name: "plexo-mcp",
10
11
  version: "1.0.0",
@@ -129,7 +130,7 @@ EXAMPLE VALID designJson PAYLOAD (hero row, plus a 3-item product grid row):
129
130
  properties: {
130
131
  type: {
131
132
  type: "string",
132
- enum: ["heading", "paragraph", "text", "button", "card", "image", "menu", "social", "divider", "spacer", "form_container", "input", "textarea", "select", "carousel", "html", "icon", "table", "timer", "video"],
133
+ enum: ["heading", "paragraph", "text", "button", "card", "image", "menu", "social", "divider", "spacer", "form_container", "input", "textarea", "select", "carousel", "html", "icon", "table", "timer", "video", "accordion", "blog_title", "blog_content", "blog_featured_image", "blog_date", "blog_author", "blog_categories", "blog_comments", "blog_post_list"],
133
134
  },
134
135
  style: { type: "object" },
135
136
  attributes: { type: "object", description: "Component attributes (text, href, src, title, description, links, fields). For type 'html', raw markup goes under 'htmlContent' — NOT 'text'." },
@@ -221,7 +222,7 @@ Uses the SAME fully-hydrated layout schema as publish_landing_page — designJso
221
222
  properties: {
222
223
  type: {
223
224
  type: "string",
224
- enum: ["heading", "paragraph", "text", "button", "card", "image", "menu", "social", "divider", "spacer", "form_container", "input", "textarea", "select", "carousel", "html", "icon", "table", "timer", "video"],
225
+ enum: ["heading", "paragraph", "text", "button", "card", "image", "menu", "social", "divider", "spacer", "form_container", "input", "textarea", "select", "carousel", "html", "icon", "table", "timer", "video", "accordion", "blog_title", "blog_content", "blog_featured_image", "blog_date", "blog_author", "blog_categories", "blog_comments", "blog_post_list"],
225
226
  },
226
227
  style: { type: "object" },
227
228
  attributes: {
@@ -301,6 +302,147 @@ Uses the SAME fully-hydrated layout schema as publish_landing_page/create_email_
301
302
  required: ["templateId", "designJson"],
302
303
  },
303
304
  },
305
+ {
306
+ name: "create_landing_page",
307
+ description: `Creates and saves a landing page template WITHOUT publishing it to a domain — use this when the user wants to build a page (or start a multi-page site) first and go live later. Call publish_existing_landing_page afterward with the returned templateId to link a subdomain or custom domain whenever they're ready. To create a page AND publish it in one step, use publish_landing_page instead.
308
+
309
+ Uses the SAME fully-hydrated layout schema as publish_landing_page — see its description for a full worked example.`,
310
+ inputSchema: {
311
+ type: "object",
312
+ properties: {
313
+ name: {
314
+ type: "string",
315
+ description: "Title of the landing page (e.g. 'Kicks Store').",
316
+ },
317
+ designJson: {
318
+ type: "object",
319
+ description: "Plexo layout schema object — same shape as publish_landing_page's designJson.",
320
+ },
321
+ },
322
+ required: ["designJson"],
323
+ },
324
+ },
325
+ {
326
+ name: "publish_existing_landing_page",
327
+ description: `Links a subdomain or custom domain to an already-existing landing page template — for a template created via create_landing_page, or the home page of a multi-page site (see create_landing_page_subpage) once its sub-pages are ready. Unlike publish_landing_page, this does NOT create a new template — it publishes the one you already have. Every sub-page nested under templateId automatically becomes reachable at this domain too (e.g. domain.com/about) — no separate publish call is needed per sub-page.`,
328
+ inputSchema: {
329
+ type: "object",
330
+ properties: {
331
+ templateId: {
332
+ type: "string",
333
+ description: "ID of an existing landing page template to publish — must be a home page (no parent), not a sub-page.",
334
+ },
335
+ domain: {
336
+ type: "string",
337
+ description: "Subdomain slug (e.g. 'kicks') or custom domain ('kicks.com').",
338
+ },
339
+ type: {
340
+ type: "string",
341
+ enum: ["SUBDOMAIN", "CUSTOM"],
342
+ description: "Domain routing type. Inferred from the domain string if omitted.",
343
+ },
344
+ },
345
+ required: ["templateId", "domain"],
346
+ },
347
+ },
348
+ {
349
+ name: "create_landing_page_subpage",
350
+ description: `Adds a new page nested under an existing landing page, reachable at <site domain>/<slug> — or nested deeper (e.g. /blog/post-1) if parentTemplateId is itself a sub-page rather than the home page. This is how a single landing page becomes a multi-page site. No separate publish step is needed for sub-pages: they automatically become reachable once the site's home page has a domain linked (see publish_existing_landing_page). Requires an Ultra subscription plan — sub-pages are otherwise unlimited per site once enabled.
351
+
352
+ The new page starts blank — use update_template with the returned templateId to add content.`,
353
+ inputSchema: {
354
+ type: "object",
355
+ properties: {
356
+ parentTemplateId: {
357
+ type: "string",
358
+ description: "ID of the page this new page should be nested under — the site's home page for a top-level page (e.g. /about), or another sub-page's ID to nest deeper (e.g. a 'Blog' page's ID to create /blog/post-1).",
359
+ },
360
+ name: {
361
+ type: "string",
362
+ description: "Friendly name of the page (e.g. 'About Us').",
363
+ },
364
+ slug: {
365
+ type: "string",
366
+ description: "Optional URL segment (e.g. 'about-us'). Auto-generated from name if omitted; auto-suffixed (about-us-2, ...) if it collides with a sibling page under the same parent.",
367
+ },
368
+ },
369
+ required: ["parentTemplateId", "name"],
370
+ },
371
+ },
372
+ {
373
+ name: "get_landing_page_pages",
374
+ description: "Returns every page belonging to the same multi-page site as the given template — its home page plus all nested sub-pages, each with its name, URL segment (slug), parent, and full resolved path (e.g. '/blog/post-1'). Pass the home page's ID or any sub-page's ID — either way you get the whole tree back. Use this before create_landing_page_subpage/update_landing_page_page when you need to know what pages already exist or what a page's current slug/parent is.",
375
+ inputSchema: {
376
+ type: "object",
377
+ properties: {
378
+ templateId: {
379
+ type: "string",
380
+ description: "ID of the site's home page, or any sub-page within it.",
381
+ },
382
+ },
383
+ required: ["templateId"],
384
+ },
385
+ },
386
+ {
387
+ name: "update_landing_page_page",
388
+ description: `Renames a page, changes its URL segment (slug), moves it under a different parent page, or reorders it among its siblings. The home page of a site (no parent) can be renamed but has no slug of its own and can't be re-parented — use publish_existing_landing_page to manage its domain instead.
389
+
390
+ To edit a page's CONTENT (designJson), use update_template with the same templateId instead — this tool only manages the page's place in the site's structure, not what's on it.`,
391
+ inputSchema: {
392
+ type: "object",
393
+ properties: {
394
+ templateId: {
395
+ type: "string",
396
+ description: "ID of the page to update.",
397
+ },
398
+ name: {
399
+ type: "string",
400
+ description: "Optional new name.",
401
+ },
402
+ slug: {
403
+ type: "string",
404
+ description: "Optional new URL segment. Not allowed for the home page.",
405
+ },
406
+ parentTemplateId: {
407
+ type: "string",
408
+ description: "Optional new parent page ID, to move this page elsewhere in the site's tree. Rejected if it would create a cycle (e.g. moving a page underneath its own sub-page).",
409
+ },
410
+ order: {
411
+ type: "number",
412
+ description: "Optional sort position among sibling pages under the same parent (lower = earlier).",
413
+ },
414
+ },
415
+ required: ["templateId"],
416
+ },
417
+ },
418
+ {
419
+ name: "delete_landing_page_page",
420
+ description: "Deletes a page. If it has sub-pages nested under it, they're deleted too (cascade) — the response reports how many. Deleting a site's home page deletes the whole site, including every page nested under it and its published domain link — this can't be undone, confirm with the user first.",
421
+ inputSchema: {
422
+ type: "object",
423
+ properties: {
424
+ templateId: {
425
+ type: "string",
426
+ description: "ID of the page to delete.",
427
+ },
428
+ },
429
+ required: ["templateId"],
430
+ },
431
+ },
432
+ {
433
+ name: "duplicate_landing_page_page",
434
+ description: "Clones a sub-page's content into a new sibling page under the same parent — handy for building several similar pages (e.g. multiple product pages) without starting blank. Not available for a site's home page. Requires an Ultra subscription plan.",
435
+ inputSchema: {
436
+ type: "object",
437
+ properties: {
438
+ templateId: {
439
+ type: "string",
440
+ description: "ID of the sub-page to duplicate — must not be a home page.",
441
+ },
442
+ },
443
+ required: ["templateId"],
444
+ },
445
+ },
304
446
  {
305
447
  name: "list_landing_pages",
306
448
  description: "Lists all saved landing page templates and published domain URLs in the user's Plexo account.",
@@ -355,6 +497,7 @@ Uses the SAME fully-hydrated layout schema as publish_landing_page/create_email_
355
497
  },
356
498
  },
357
499
  },
500
+ ...blogTools_js_1.BLOG_TOOL_DEFS,
358
501
  ],
359
502
  };
360
503
  });
@@ -408,6 +551,83 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
408
551
  ],
409
552
  };
410
553
  }
554
+ case "create_landing_page": {
555
+ const result = await client.createLandingPage(args);
556
+ return {
557
+ content: [
558
+ {
559
+ type: "text",
560
+ text: JSON.stringify(result, null, 2),
561
+ },
562
+ ],
563
+ };
564
+ }
565
+ case "publish_existing_landing_page": {
566
+ const result = await client.publishExistingLandingPage(args);
567
+ return {
568
+ content: [
569
+ {
570
+ type: "text",
571
+ text: JSON.stringify(result, null, 2),
572
+ },
573
+ ],
574
+ };
575
+ }
576
+ case "create_landing_page_subpage": {
577
+ const result = await client.createLandingPageSubpage(args);
578
+ return {
579
+ content: [
580
+ {
581
+ type: "text",
582
+ text: JSON.stringify(result, null, 2),
583
+ },
584
+ ],
585
+ };
586
+ }
587
+ case "get_landing_page_pages": {
588
+ const result = await client.getLandingPagePages(args?.templateId);
589
+ return {
590
+ content: [
591
+ {
592
+ type: "text",
593
+ text: JSON.stringify(result, null, 2),
594
+ },
595
+ ],
596
+ };
597
+ }
598
+ case "update_landing_page_page": {
599
+ const result = await client.updateLandingPagePage(args);
600
+ return {
601
+ content: [
602
+ {
603
+ type: "text",
604
+ text: JSON.stringify(result, null, 2),
605
+ },
606
+ ],
607
+ };
608
+ }
609
+ case "delete_landing_page_page": {
610
+ const result = await client.deleteLandingPagePage(args?.templateId);
611
+ return {
612
+ content: [
613
+ {
614
+ type: "text",
615
+ text: JSON.stringify(result, null, 2),
616
+ },
617
+ ],
618
+ };
619
+ }
620
+ case "duplicate_landing_page_page": {
621
+ const result = await client.duplicateLandingPagePage(args?.templateId);
622
+ return {
623
+ content: [
624
+ {
625
+ type: "text",
626
+ text: JSON.stringify(result, null, 2),
627
+ },
628
+ ],
629
+ };
630
+ }
411
631
  case "list_landing_pages": {
412
632
  const data = await client.listTemplates();
413
633
  const landingPages = (data.templates || []).filter((t) => t.kind === "LANDING_PAGE");
@@ -469,8 +689,20 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
469
689
  ],
470
690
  };
471
691
  }
472
- default:
692
+ default: {
693
+ if (blogTools_js_1.BLOG_TOOL_NAMES.has(name)) {
694
+ const result = await (0, blogTools_js_1.handleBlogToolCall)(name, args || {}, client);
695
+ return {
696
+ content: [
697
+ {
698
+ type: "text",
699
+ text: JSON.stringify(result, null, 2),
700
+ },
701
+ ],
702
+ };
703
+ }
473
704
  throw new Error(`Unknown tool: ${name}`);
705
+ }
474
706
  }
475
707
  }
476
708
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charisol/plexo-mcp",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Model Context Protocol (MCP) Server for Plexo - Landing page generation, email templates, publishing, and analytics.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {