webcake-storefront-mcp 1.10.0 → 1.11.1

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/api.js CHANGED
@@ -76,6 +76,13 @@ export class WebcakeCmsApi {
76
76
  createSite(params) {
77
77
  return this.request("POST", `/api/v1/dashboard/site/create`, { body: params, timeout: 60000 });
78
78
  }
79
+ /** Create a NEW site from a marketplace TEMPLATE by its theme id — the dedicated
80
+ * "use this template" API. Clones the template's pages, global sections, cart, popups,
81
+ * styles and fonts into a fresh account-owned site. Body: { id: <theme_id>, name, slug }.
82
+ * Returns { data: { site: { id, ... } } }. (403 if the free 4-site quota is reached, prod.) */
83
+ importStoreToTheme(params) {
84
+ return this.request("POST", `/api/v1/dashboard/site/import_store_to_theme`, { body: params, timeout: 120000 });
85
+ }
79
86
  getSiteInfo() {
80
87
  return this.request("GET", `/api/v1/site/${this.siteId}/`);
81
88
  }
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "v": "1.11.1",
4
+ "d": "24/06/2026",
5
+ "type": "Fixed",
6
+ "en": "create_site_from_template now calls the dedicated import_store_to_theme API instead of the generic site-duplicate endpoint, correctly cloning the…",
7
+ "vi": "create_site_from_template nay gọi đúng API import_store_to_theme thay vì endpoint nhân bản site thông thường, giúp clone đầy đủ các trang, global…"
8
+ },
9
+ {
10
+ "v": "1.11.0",
11
+ "d": "24/06/2026",
12
+ "type": "Added",
13
+ "en": "New create_site_from_template tool clones a marketplace template (all its pages, page-sources, and settings) into a new account-owned site, switches…",
14
+ "vi": "Tool mới create_site_from_template nhân bản một template marketplace (toàn bộ trang, page-source và cài đặt) thành một site mới thuộc tài khoản hiện…"
15
+ },
2
16
  {
3
17
  "v": "1.10.0",
4
18
  "d": "24/06/2026",
@@ -26,19 +40,5 @@
26
40
  "type": "Changed",
27
41
  "en": "The web guide landing page (served via the serve command) is reframed to lead on full-storefront creation: the hero, meta description, \"What you…",
28
42
  "vi": "Trang web guide (phục vụ qua lệnh serve) được viết lại để làm nổi bật việc xây dựng toàn bộ cửa hàng: hero, meta description, thư viện \"Bạn dựng…"
29
- },
30
- {
31
- "v": "1.6.0",
32
- "d": "23/06/2026",
33
- "type": "Added",
34
- "en": "get_element now returns an attributes field with a curated per-element reference covering the meaningful specials, config, events, and bindings keys…",
35
- "vi": "get_element nay trả về trường attributes chứa tài liệu tham chiếu theo từng loại element, bao gồm các key có ý nghĩa của specials, config, events và…"
36
- },
37
- {
38
- "v": "1.5.1",
39
- "d": "23/06/2026",
40
- "type": "Fixed",
41
- "en": "build_page now passes the finalized page source to create_page in the initial create call (required by the backend), then sets slug and is_homepage…",
42
- "vi": "build_page nay truyền source trang đã hoàn thiện vào lời gọi create_page ban đầu (bắt buộc bởi backend), sau đó đặt slug và is_homepage qua một lời…"
43
43
  }
44
44
  ]
@@ -1,4 +1,6 @@
1
1
  import { z } from "zod";
2
+ import { setConfig } from "../db.js";
3
+ import { resolvePreviewUrl } from "../config.js";
2
4
  const TEMPLATE_THEMES_URL = "https://api.storecake.io/api/v1/templates/list_themes";
3
5
  const THEME_CATALOG_TTL_MS = 60 * 60 * 1000;
4
6
  const FETCH_TIMEOUT_MS = 15000;
@@ -152,6 +154,57 @@ export function registerSiteStyleTools(server, api, handle) {
152
154
  description_en: desc.description_en,
153
155
  };
154
156
  });
155
- return { query: q, count: matches.length, matches };
157
+ return {
158
+ query: q,
159
+ count: matches.length,
160
+ matches,
161
+ hint: "Pick one and call create_site_from_template with its theme_id (or template_site_id) to clone it into a new editable site.",
162
+ };
163
+ }));
164
+ server.tool("create_site_from_template", `Create a NEW site from a marketplace TEMPLATE (the dedicated "use this template" API).
165
+ Clones the template's pages, global sections, cart, popups, styles and fonts into a fresh
166
+ site. Pick a template with semantic_search_themes / list_template_themes, then pass its
167
+ theme_id here. Switches to the new site so you can immediately edit layout/content with
168
+ update_page_element(s), colours/fonts via the site-style tools, then publish_site.`, {
169
+ name: z.string().describe("Name for the new site"),
170
+ theme_id: z.string().describe("Marketplace theme id (from semantic_search_themes / list_template_themes)"),
171
+ slug: z.string().optional().describe("URL-safe slug for the new site (auto-generated if omitted)"),
172
+ switch_to: z.boolean().default(true).describe("Switch the session to the new site after creating it (saved for next session)"),
173
+ }, ({ name, theme_id, slug, switch_to }) => handle(async () => {
174
+ let res;
175
+ try {
176
+ res = await api.importStoreToTheme({ id: theme_id, name, ...(slug ? { slug } : {}) });
177
+ }
178
+ catch (e) {
179
+ const msg = e instanceof Error ? e.message : String(e);
180
+ if (msg.includes("403"))
181
+ throw new Error("Cannot create site: account site quota reached (free plan allows up to 4 sites).");
182
+ throw new Error(`Creating the site from the template failed: ${msg}. Check the theme_id exists (list_template_themes / semantic_search_themes).`);
183
+ }
184
+ const data = res?.data || res;
185
+ const newSite = data?.site || data?.new_site || data;
186
+ const newId = newSite?.id;
187
+ if (!newId)
188
+ throw new Error("Site created from template but no id was returned.");
189
+ let switched = false;
190
+ let previewUrl = null;
191
+ const previousSiteId = api.siteId;
192
+ if (switch_to) {
193
+ api.switchSite(newId);
194
+ setConfig("site_id", newId);
195
+ setConfig("site_name", newSite?.name || name);
196
+ switched = true;
197
+ previewUrl = await resolvePreviewUrl(api).catch(() => null);
198
+ }
199
+ return {
200
+ success: true,
201
+ site_id: newId,
202
+ name: newSite?.name || name,
203
+ from_template: theme_id,
204
+ switched,
205
+ ...(switched ? { current_site_id: api.siteId, previous_site_id: previousSiteId } : {}),
206
+ preview_url: previewUrl,
207
+ next_step: "Site created from the template (pages, sections, popups, styles, fonts). Edit content with search_page_elements + update_page_element(s), colours/fonts via list_themes/site-style, then publish_site.",
208
+ };
156
209
  }));
157
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcake-storefront-mcp",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "description": "MCP server for the WebCake/StoreCake storefront builder — page CRUD, page authoring, products, orders, and more",
5
5
  "mcpName": "io.github.vuluu2k/webcake-storefront-mcp",
6
6
  "license": "MIT",