webcake-landing-mcp 1.13.2 → 1.13.4
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/changelog.json +14 -14
- package/dist/persistence/rehost.js +16 -0
- package/dist/persistence/webcake-client.js +13 -4
- package/dist/smoke.js +8 -1
- package/dist/tools/generation.js +4 -4
- package/dist/tools/ingest.js +2 -2
- package/dist/tools/media.js +3 -3
- package/dist/tools/persistence.js +10 -7
- package/dist/tools/reference.js +4 -4
- package/package.json +2 -1
package/dist/changelog.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "1.13.4",
|
|
4
|
+
"d": "20/11/2026",
|
|
5
|
+
"type": "Changed",
|
|
6
|
+
"en": "All read-only tools (get_generation_guide, list_elements, get_element, get_page_schema, new_element, new_page_skeleton, validate_page,…",
|
|
7
|
+
"vi": "Tất cả tool chỉ-đọc (get_generation_guide, list_elements, get_element, get_page_schema, new_element, new_page_skeleton, validate_page,…"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"v": "1.13.3",
|
|
11
|
+
"d": "20/11/2026",
|
|
12
|
+
"type": "Fixed",
|
|
13
|
+
"en": "settings.thumbnail/settings.favicon no longer end up as a 404 sNaN resize URL after an MCP save followed by an editor publish: rehosting now skips…",
|
|
14
|
+
"vi": "settings.thumbnail/settings.favicon không còn bị thành URL resize sNaN lỗi 404 sau khi lưu qua MCP rồi publish lại từ editor: bước rehost nay bỏ qua…"
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"v": "1.13.2",
|
|
4
18
|
"d": "20/11/2026",
|
|
@@ -26,19 +40,5 @@
|
|
|
26
40
|
"type": "Added",
|
|
27
41
|
"en": "get_element/list_elements now return keys (one line per specials/config/styles key the published renderer actually reads, with meaning, value type,…",
|
|
28
42
|
"vi": "get_element/list_elements nay trả thêm keys (mỗi dòng là một key specials/config/styles mà renderer thật có đọc, kèm ý nghĩa, kiểu giá trị, enum,…"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"v": "1.11.0",
|
|
32
|
-
"d": "19/11/2026",
|
|
33
|
-
"type": "Added",
|
|
34
|
-
"en": "Three new tools, api_find, api_get, and api_call, expose the full landing_page_backend API surface the account's token can reach, beyond what the…",
|
|
35
|
-
"vi": "Ba tool mới api_find, api_get, api_call cho phép gọi toàn bộ API của landing_page_backend mà token của tài khoản có quyền truy cập, vượt ra ngoài…"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"v": "1.10.0",
|
|
39
|
-
"d": "19/11/2026",
|
|
40
|
-
"type": "Added",
|
|
41
|
-
"en": "A new clone_page tool clones any web page (including JavaScript-rendered React/Vue/Next sites) by measuring it in a real headless-Chrome browser at…",
|
|
42
|
-
"vi": "Tool mới clone_page clone bất kỳ trang web nào (kể cả trang render bằng JavaScript như React/Vue/Next) bằng cách đo trực tiếp trong trình duyệt…"
|
|
43
43
|
}
|
|
44
44
|
]
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
/** Hosts we never re-host: our own CDN + deliberate placeholders. */
|
|
25
25
|
const SKIP_HOSTS = [
|
|
26
26
|
"statics.pancake.vn",
|
|
27
|
+
// The editor's resize CDN (its publish writes settings.thumbnail/favicon as
|
|
28
|
+
// content.pancake.vn/<bucket>/s1200x650/…). Re-hosting it swapped a working
|
|
29
|
+
// editor URL for one without the -w:/-h: info the next editor publish needs (#5).
|
|
30
|
+
"content.pancake.vn",
|
|
27
31
|
"placehold.co",
|
|
28
32
|
"placeholder.com",
|
|
29
33
|
"via.placeholder.com",
|
|
@@ -192,6 +196,18 @@ export function rewriteImageUrls(source, map) {
|
|
|
192
196
|
};
|
|
193
197
|
return recur(source);
|
|
194
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Repair `content.pancake.vn/<bucket>/sNaNx<h>[/fwebp<q>]/…` URLs (always 404).
|
|
201
|
+
* The editor's publish resizes settings.thumbnail/favicon from the `-w:…-h:…`
|
|
202
|
+
* info in the file name; a URL without it (the public upload route mints those)
|
|
203
|
+
* gets width NaN, and the editor stores that broken link in the source (#5).
|
|
204
|
+
* Dropping the size segment leaves the original image, which the CDN serves.
|
|
205
|
+
*/
|
|
206
|
+
const NAN_RESIZE_RE = /(https:\/\/content\.pancake\.vn\/[^/"\s]+)\/sNaNx\d+(?:\/fwebp\d*)?\//g;
|
|
207
|
+
export function healBrokenResizeUrls(source) {
|
|
208
|
+
const json = JSON.stringify(source);
|
|
209
|
+
return json?.includes("/sNaNx") ? JSON.parse(json.replace(NAN_RESIZE_RE, "$1/")) : source;
|
|
210
|
+
}
|
|
195
211
|
/** Hard cap on uploads per save — a runaway-safety backstop, far above a real page's image count.
|
|
196
212
|
* The {original → hosted} dedup cache itself lives in ./rehost-cache.ts (Redis-or-memory),
|
|
197
213
|
* kept OUT of this module so rehost.ts stays PURE (no network/IO → no webcake-client cycle). */
|
|
@@ -565,7 +565,7 @@ function writeFailure(status, json, text) {
|
|
|
565
565
|
*/
|
|
566
566
|
export async function appendSection(config, pageId, sections, opts = {}) {
|
|
567
567
|
const url = `${config.base}${APPEND_ENDPOINT}`;
|
|
568
|
-
const { source: hostedSections, report: rehost } = await rehostSourceImages(config, sections);
|
|
568
|
+
const { source: hostedSections, report: rehost } = await rehostSourceImages(config, sections, pageId);
|
|
569
569
|
let res;
|
|
570
570
|
try {
|
|
571
571
|
res = await fetch(url, {
|
|
@@ -626,7 +626,7 @@ function fontWeightNotice(sections) {
|
|
|
626
626
|
/** Overwrite an existing page's source (source-only). */
|
|
627
627
|
export async function updatePageSource(config, pageId, source, opts = {}) {
|
|
628
628
|
let url = `${config.base}${UPDATE_ENDPOINT}`;
|
|
629
|
-
const { source: hostedSource, report: rehost } = await rehostSourceImages(config, withGoogleWeightLinks(source));
|
|
629
|
+
const { source: hostedSource, report: rehost } = await rehostSourceImages(config, withGoogleWeightLinks(source), pageId);
|
|
630
630
|
// Against a known version: send only the changed sections (patch_page_source) when that is smaller.
|
|
631
631
|
let body = JSON.stringify({ page_id: pageId, source: hostedSource, ...baseField(opts.base) });
|
|
632
632
|
let via = "update";
|
|
@@ -1253,7 +1253,7 @@ function rehostFilename(src, ext) {
|
|
|
1253
1253
|
* row is per-org, so a shared key would let org B reuse org A's URL and never get
|
|
1254
1254
|
* the image filed into its own collection.
|
|
1255
1255
|
*/
|
|
1256
|
-
export async function rehostSourceImages(config, source) {
|
|
1256
|
+
export async function rehostSourceImages(config, source, pageId) {
|
|
1257
1257
|
const candidates = collectExternalImageUrls(source);
|
|
1258
1258
|
if (candidates.length === 0)
|
|
1259
1259
|
return { source };
|
|
@@ -1265,7 +1265,16 @@ export async function rehostSourceImages(config, source) {
|
|
|
1265
1265
|
// collection. This never blocks the save: a page's images are not worth
|
|
1266
1266
|
// failing a write over, and create_page already refuses to save at all when
|
|
1267
1267
|
// the org is ambiguous, so by this point an org is normally settled.
|
|
1268
|
-
|
|
1268
|
+
let orgId = config.jwt ? await resolveCollectionOrgId(config) : undefined;
|
|
1269
|
+
// An edit (update/append) on a multi-org account: file into the PAGE's org.
|
|
1270
|
+
// The public fallback mints URLs without the -w:/-h: info, which the editor's
|
|
1271
|
+
// publish turns into a 404 `sNaN` thumbnail/favicon (#5).
|
|
1272
|
+
if (!orgId && config.jwt && pageId) {
|
|
1273
|
+
const found = await searchPages(config, { id: pageId, limit: 1 });
|
|
1274
|
+
const org = found.pages?.find((p) => `${p.id}` === `${pageId}`)?.organization_id;
|
|
1275
|
+
if (org != null && `${org}` !== "")
|
|
1276
|
+
orgId = `${org}`;
|
|
1277
|
+
}
|
|
1269
1278
|
if (orgId)
|
|
1270
1279
|
config = { ...config, orgId };
|
|
1271
1280
|
const scope = config.jwt && orgId ? `org:${orgId}` : "public";
|
package/dist/smoke.js
CHANGED
|
@@ -26,7 +26,7 @@ import { isLocalPath, resolveLocalPath, sniffMime, localContentType } from "./to
|
|
|
26
26
|
import { buildMicrolinkUrl } from "./persistence/screenshot-client.js";
|
|
27
27
|
import { isPrivateHost, isAllowedScreenshotUrl, acquireSlot, releaseSlot, slotStats } from "./persistence/screenshot-playwright.js";
|
|
28
28
|
import { iconifyCandidates } from "./persistence/icon-client.js";
|
|
29
|
-
import { collectExternalImageUrls, rewriteImageUrls, isRehostableImageUrl, isInlineBase64Image, parseInlineBase64Image } from "./persistence/rehost.js";
|
|
29
|
+
import { collectExternalImageUrls, rewriteImageUrls, isRehostableImageUrl, isInlineBase64Image, parseInlineBase64Image, healBrokenResizeUrls } from "./persistence/rehost.js";
|
|
30
30
|
import { key as rehostCacheKey } from "./persistence/rehost-cache.js";
|
|
31
31
|
import { sourceFingerprint, collectElementIds, decideOverwrite, rememberPageVersion, forgetPageVersion, lastKnownPageVersion, resetPageVersions, sourceCacheKey, cachePageSource, cachedPageSource, cachedPageSourceVersion, dropCachedPageSource, resetPageSourceCache, } from "./persistence/page-version.js";
|
|
32
32
|
let failures = 0;
|
|
@@ -2128,6 +2128,13 @@ console.log("== rehost: external-image URL collect + rewrite (pure, offline) =="
|
|
|
2128
2128
|
check("rehost: data: URI not rehostable", !isRehostableImageUrl("data:image/svg+xml;utf8,<svg>"));
|
|
2129
2129
|
check("rehost: extension-less URL not rehostable as a plain field", !isRehostableImageUrl("https://w.ladicdn.com/x/noext"));
|
|
2130
2130
|
check("rehost: .jpg URL rehostable", isRehostableImageUrl("https://w.ladicdn.com/x/p.jpg"));
|
|
2131
|
+
// #5: the editor's resize CDN is ours — never re-host it; heal its NaN-width (404) links.
|
|
2132
|
+
check("rehost: content.pancake.vn (editor resize CDN) not rehostable", !isRehostableImageUrl("https://content.pancake.vn/web-media-264/s1200x650/fwebp90/1a/67/x-w:1200-h:630.png"));
|
|
2133
|
+
{
|
|
2134
|
+
const ok = "https://content.pancake.vn/web-media-264/s50x50/fwebp/1a/67/x.png";
|
|
2135
|
+
const healed = healBrokenResizeUrls({ settings: { favicon: "https://content.pancake.vn/web-media-264/sNaNx50/fwebp/1a/67/x.png", thumbnail: "https://content.pancake.vn/web-media-264/sNaNx650/1a/67/y.png", ok } });
|
|
2136
|
+
check("heal: sNaN favicon/thumbnail → original image, valid resize URL untouched", healed.settings.favicon === "https://content.pancake.vn/web-media-264/1a/67/x.png" && healed.settings.thumbnail === "https://content.pancake.vn/web-media-264/1a/67/y.png" && healed.settings.ok === ok, healed);
|
|
2137
|
+
}
|
|
2131
2138
|
check("rehost: ?query after ext still rehostable", isRehostableImageUrl("https://cdn.x/p.png?v=2"));
|
|
2132
2139
|
// Stitch ↔ webcake bridge: Google Stitch images live on googleusercontent with
|
|
2133
2140
|
// NO extension — host-recognized so a Stitch clone's specials.src auto-hosts.
|
package/dist/tools/generation.js
CHANGED
|
@@ -12,7 +12,7 @@ export function registerGenerationTools(server, domain) {
|
|
|
12
12
|
server.tool("new_element", "Returns the node the Webcake editor drops for a type, in the sparse authoring shape: a fresh id, the editor default look (colours, font, border, size) and settings for both breakpoints, and its default children (a form with name + phone fields and a submit button, a carousel with slides, a grid with items). Images are sized placeholders to replace. properties, runtime, empty events and per-breakpoint config are omitted because the server fills them from factory defaults on validate and save.", {
|
|
13
13
|
type: z.string().describe("Element type to create."),
|
|
14
14
|
name: z.string().optional().describe("Optional properties.name override (layer label)."),
|
|
15
|
-
}, { title: "New Element Node", readOnlyHint: true, openWorldHint: false }, async ({ type, name }) => {
|
|
15
|
+
}, { title: "New Element Node", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ type, name }) => {
|
|
16
16
|
if (!domain.catalog[type]) {
|
|
17
17
|
return text({ error: `Unknown element type "${type}".`, valid_types: domain.elementTypes });
|
|
18
18
|
}
|
|
@@ -26,7 +26,7 @@ export function registerGenerationTools(server, domain) {
|
|
|
26
26
|
mobileOnly: z.boolean().optional().describe("true if the page renders mobile-only."),
|
|
27
27
|
desktopWidth: z.union([z.literal(960), z.literal(1200)]).optional().describe("Desktop canvas width (settings.width_section.desktop). 960 (default, simple/narrow) or 1200 (wide/multi-column/editorial, or cloning a >960 reference)."),
|
|
28
28
|
mobileWidth: z.union([z.literal(420), z.literal(360)]).optional().describe("Mobile canvas width (settings.width_section.mobile). 420 (default) or 360 (to match a ~360–390 mobile design)."),
|
|
29
|
-
}, { title: "New Page Skeleton", readOnlyHint: true, openWorldHint: false }, async ({ mobileOnly, desktopWidth, mobileWidth }) => text(domain.createPageSource({
|
|
29
|
+
}, { title: "New Page Skeleton", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ mobileOnly, desktopWidth, mobileWidth }) => text(domain.createPageSource({
|
|
30
30
|
mobileOnly: mobileOnly ?? false,
|
|
31
31
|
settings: desktopWidth || mobileWidth
|
|
32
32
|
? { width_section: { desktop: desktopWidth ?? 960, mobile: mobileWidth ?? 420 } }
|
|
@@ -36,7 +36,7 @@ export function registerGenerationTools(server, domain) {
|
|
|
36
36
|
server.tool("validate_page", "Validates a page source against the JSON schema and semantic rules: unique ids, dangling event targets, children only on container types, missing field_name, top-level types, and form-data bindings (duplicate field_name within one form; dangling promoId / connectedSurvey / connectedForm / set_field_value targets). Before validating it applies deterministic layout corrections (off-canvas boxes moved on-canvas, elements below wrapped text moved down) and lists them in auto_fixed. Returns errors (structural problems that block saving) and warnings (visible layout defects such as overlapping text, off-canvas bounds, or empty bands).", {
|
|
37
37
|
page: objectOrJson()
|
|
38
38
|
.describe("The page source object { page:[...], settings:{} } OR a JSON string of it."),
|
|
39
|
-
}, { title: "Validate Page Source", readOnlyHint: true, openWorldHint: false }, async ({ page }) => {
|
|
39
|
+
}, { title: "Validate Page Source", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ page }) => {
|
|
40
40
|
// Hydrate sparse nodes (the model may omit boilerplate) before validating,
|
|
41
41
|
// so what we check is the same full tree that create_page/add_section persist.
|
|
42
42
|
const expanded = domain.expand(page);
|
|
@@ -67,7 +67,7 @@ export function registerGenerationTools(server, domain) {
|
|
|
67
67
|
marginMobile: z.number().optional().describe("Mobile page margin / content inset. Default 20."),
|
|
68
68
|
align: z.enum(["center", "left", "right"]).optional().describe("Horizontal alignment of the block within the canvas. Default center."),
|
|
69
69
|
mobileItemWidth: z.number().optional().describe("Stacked-mobile item width (row/grid). Default = mobile content width."),
|
|
70
|
-
}, { title: "Compute Layout Coordinates", readOnlyHint: true, openWorldHint: false }, async (opts) => {
|
|
70
|
+
}, { title: "Compute Layout Coordinates", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async (opts) => {
|
|
71
71
|
if (!domain.computeLayout) {
|
|
72
72
|
return text({ error: "This domain does not provide layout coordinates." });
|
|
73
73
|
}
|
package/dist/tools/ingest.js
CHANGED
|
@@ -84,7 +84,7 @@ export function registerIngestTools(server, domain) {
|
|
|
84
84
|
.string()
|
|
85
85
|
.optional()
|
|
86
86
|
.describe("The page's original URL, when the HTML was saved or copied from a live site. Resolves relative font and image URLs and fetches the page's external stylesheets (+ @imports), so self-hosted fonts (`font_groups`) and computed type (`typography` / `text_styles`) defined outside the HTML are included."),
|
|
87
|
-
}, { title: "Ingest HTML Reference", readOnlyHint: true, openWorldHint: true }, async ({ html, intent, detail, sections, base_url }) => {
|
|
87
|
+
}, { title: "Ingest HTML Reference", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async ({ html, intent, detail, sections, base_url }) => {
|
|
88
88
|
const baseUrl = base_url && /^https?:\/\//i.test(base_url) ? base_url : undefined;
|
|
89
89
|
const extraCss = baseUrl ? await fetchStylesheets(html, baseUrl) : undefined;
|
|
90
90
|
return text({ intent: intent ?? "adapt", ...withCloneSource(domain, parseHtml(html, detail ?? "compact", { sections, baseUrl, extraCss })) });
|
|
@@ -97,7 +97,7 @@ export function registerIngestTools(server, domain) {
|
|
|
97
97
|
.describe("How the result will be used. 'adapt' (default): the reference provides layout and imagery while the text is rewritten for the user's brand. 'clone': text and images stay close to the original. Absolute-canvas exports return a clone `source` either way."),
|
|
98
98
|
detail: detailParam,
|
|
99
99
|
sections: sectionsParam,
|
|
100
|
-
}, { title: "Ingest URL Reference", readOnlyHint: true, openWorldHint: true }, async ({ url, intent, detail, sections }) => {
|
|
100
|
+
}, { title: "Ingest URL Reference", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async ({ url, intent, detail, sections }) => {
|
|
101
101
|
const fetched = await fetchHtml(url);
|
|
102
102
|
if (!fetched.ok) {
|
|
103
103
|
return text({
|
package/dist/tools/media.js
CHANGED
|
@@ -214,7 +214,7 @@ export function registerMediaTools(server, allowLocalFiles = true) {
|
|
|
214
214
|
size: z.enum(["large", "medium", "small"]).optional().describe("Minimum photo size to return (default any)."),
|
|
215
215
|
color: z.string().optional().describe("Optional color filter: a name (red, blue, …) or a hex like '6a8f3c'."),
|
|
216
216
|
page: z.number().int().min(1).optional().describe("Result page for pagination (default 1)."),
|
|
217
|
-
}, { title: "Search Stock Images", readOnlyHint: true, openWorldHint: true }, async ({ query, queries, per_page, pick, orientation, size, color, page }, extra) => {
|
|
217
|
+
}, { title: "Search Stock Images", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async ({ query, queries, per_page, pick, orientation, size, color, page }, extra) => {
|
|
218
218
|
const list = queries && queries.length ? queries : query ? [query] : [];
|
|
219
219
|
if (list.length === 0) {
|
|
220
220
|
return text({ ok: false, error: "Pass `query` or `queries`." });
|
|
@@ -267,7 +267,7 @@ export function registerMediaTools(server, allowLocalFiles = true) {
|
|
|
267
267
|
.min(1)
|
|
268
268
|
.max(40)
|
|
269
269
|
.describe("Icon references to resolve (1–40), e.g. [\"ms:verified\", \"ms:support_agent\", \"fa:chart-line\"] — typically the block.icon values from an ingest result."),
|
|
270
|
-
}, { title: "Resolve Icon SVGs", readOnlyHint: true, openWorldHint: true }, async ({ icons }) => {
|
|
270
|
+
}, { title: "Resolve Icon SVGs", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async ({ icons }) => {
|
|
271
271
|
const unique = [...new Set(icons)];
|
|
272
272
|
const results = await Promise.all(unique.map(async (ref) => [ref, await resolveIconSvg(ref)]));
|
|
273
273
|
const out = {};
|
|
@@ -297,7 +297,7 @@ export function registerMediaTools(server, allowLocalFiles = true) {
|
|
|
297
297
|
full_page: z.boolean().optional().describe("Capture the whole scrollable page (default true) vs just the viewport."),
|
|
298
298
|
width: z.number().int().min(320).max(2560).optional().describe("Viewport width in px (default 1280; ~960 or 1200 matches the desktop page canvas, ~420 the mobile one)."),
|
|
299
299
|
tiles: z.boolean().optional().describe("Tall pages: return the page as MULTIPLE top→bottom band images (each readable in detail) instead of one squished full-page image. Requires a Playwright host (RENDER_SCREENSHOT_BASE); without one it falls back to a single image."),
|
|
300
|
-
}, { title: "Render Preview Screenshot", readOnlyHint: true, openWorldHint: true }, async ({ page_id, url, full_page, width, tiles }, extra) => {
|
|
300
|
+
}, { title: "Render Preview Screenshot", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async ({ page_id, url, full_page, width, tiles }, extra) => {
|
|
301
301
|
const headers = extra?.requestInfo?.headers;
|
|
302
302
|
let target = url?.trim();
|
|
303
303
|
if (!target && page_id) {
|
|
@@ -15,6 +15,7 @@ import { objectOrJson, objectsOrJson } from "../mcp/params.js";
|
|
|
15
15
|
import { readConfig, configFromHeaders } from "../persistence/config.js";
|
|
16
16
|
import { applyOps, buildRequestRedacted, buildUpdateRequestRedacted, buildAppendRequestRedacted, buildPublishRequestRedacted, buildPageApp, createPage, listOrganizations, listPages, searchPages, listVerifiedDomains, getPageSource, getPageVersion, updatePageSource, appendSection, publishPage, toPreviewUrl, } from "../persistence/webcake-client.js";
|
|
17
17
|
import { matchAccountDomain, normalizeDomain } from "../persistence/domain-match.js";
|
|
18
|
+
import { healBrokenResizeUrls } from "../persistence/rehost.js";
|
|
18
19
|
import { putDraft, getDraft, updateDraft, deleteDraft } from "../persistence/draft-cache.js";
|
|
19
20
|
import { sourceFingerprint, decideOverwrite, rememberPageVersion, forgetPageVersion, lastKnownPageVersion, sourceCacheKey, cachePageSource, cachedPageSource, cachedPageSourceVersion, dropCachedPageSource, } from "../persistence/page-version.js";
|
|
20
21
|
import { locate as locateNode, outline as pageOutline, selectIds, matchProblem, dropStaleMeasure, dropStaleAgainst, moveNode, duplicateNode, refsTo, subtreeIds, } from "../domains/landing/tree.js";
|
|
@@ -273,7 +274,7 @@ export function registerPersistenceTools(server, domain) {
|
|
|
273
274
|
};
|
|
274
275
|
};
|
|
275
276
|
// 8) List organizations -----------------------------------------------------
|
|
276
|
-
server.tool("list_organizations", "Returns the account's Webcake organizations (id, name, is_default). The default org (type===1, usually the personal workspace) is where pages normally go. Needs WEBCAKE_API_BASE + WEBCAKE_JWT.", {}, { title: "List Webcake Organizations", readOnlyHint: true, openWorldHint: true }, async (_args, extra) => {
|
|
277
|
+
server.tool("list_organizations", "Returns the account's Webcake organizations (id, name, is_default). The default org (type===1, usually the personal workspace) is where pages normally go. Needs WEBCAKE_API_BASE + WEBCAKE_JWT.", {}, { title: "List Webcake Organizations", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async (_args, extra) => {
|
|
277
278
|
const { config, missing } = cfgFor(extra);
|
|
278
279
|
if (!config) {
|
|
279
280
|
return text({
|
|
@@ -545,7 +546,7 @@ export function registerPersistenceTools(server, domain) {
|
|
|
545
546
|
});
|
|
546
547
|
});
|
|
547
548
|
// 10) List pages ------------------------------------------------------------
|
|
548
|
-
server.tool("list_pages", "Lists the pages owned by the account (id, name, organization_id, updated_at), most-recent first. Needs WEBCAKE_API_BASE + WEBCAKE_JWT.", {}, { title: "List Webcake Pages", readOnlyHint: true, openWorldHint: true }, async (_args, extra) => {
|
|
549
|
+
server.tool("list_pages", "Lists the pages owned by the account (id, name, organization_id, updated_at), most-recent first. Needs WEBCAKE_API_BASE + WEBCAKE_JWT.", {}, { title: "List Webcake Pages", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async (_args, extra) => {
|
|
549
550
|
const { config, missing } = cfgFor(extra);
|
|
550
551
|
if (!config)
|
|
551
552
|
return text({ ok: false, reason: "missing_env", missing_env: missing });
|
|
@@ -569,7 +570,7 @@ export function registerPersistenceTools(server, domain) {
|
|
|
569
570
|
.describe("Case-insensitive substring of the page's domain (matches custom_domain OR default_domain)."),
|
|
570
571
|
page_id: z.string().optional().describe("Exact page id — narrows to that single page (useful to confirm it exists/owned)."),
|
|
571
572
|
limit: z.number().int().positive().max(100).optional().describe("Max results (default 50, capped at 100)."),
|
|
572
|
-
}, { title: "Find Webcake Pages", readOnlyHint: true, openWorldHint: true }, async ({ name, domain, page_id, limit }, extra) => {
|
|
573
|
+
}, { title: "Find Webcake Pages", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async ({ name, domain, page_id, limit }, extra) => {
|
|
573
574
|
const { config, missing } = cfgFor(extra);
|
|
574
575
|
if (!config)
|
|
575
576
|
return text({ ok: false, reason: "missing_env", missing_env: missing });
|
|
@@ -607,7 +608,7 @@ export function registerPersistenceTools(server, domain) {
|
|
|
607
608
|
.boolean()
|
|
608
609
|
.optional()
|
|
609
610
|
.describe("Default TRUE — strip factory-default boilerplate from every element (sparse shape, far fewer tokens). false returns the raw stored tree."),
|
|
610
|
-
}, { title: "Get Webcake Page Source", readOnlyHint: true, openWorldHint: true }, async ({ page_id, draft_id, outline, element_id, compact }, extra) => {
|
|
611
|
+
}, { title: "Get Webcake Page Source", readOnlyHint: true, destructiveHint: false, openWorldHint: true }, async ({ page_id, draft_id, outline, element_id, compact }, extra) => {
|
|
611
612
|
// Outline / one element / a draft: a narrow read of the same tree.
|
|
612
613
|
const narrow = (src, meta) => {
|
|
613
614
|
if (typeof src === "string")
|
|
@@ -1699,6 +1700,8 @@ export function registerPersistenceTools(server, domain) {
|
|
|
1699
1700
|
if (!res.ok || res.source == null) {
|
|
1700
1701
|
return text({ published: false, reason: "page_not_found", status: res.status, error: res.error ?? "No source on this page." });
|
|
1701
1702
|
}
|
|
1703
|
+
// An editor publish may have stored a 404 `sNaN` thumbnail/favicon — don't republish it (#5).
|
|
1704
|
+
const source = healBrokenResizeUrls(res.source);
|
|
1702
1705
|
// Resolve the domain to publish to the way the editor's publish modal does:
|
|
1703
1706
|
// an explicit arg wins, otherwise reuse the page's CURRENTLY-ATTACHED domain
|
|
1704
1707
|
// so a plain publish_page({ page_id }) keeps the page live at the same URL
|
|
@@ -1780,7 +1783,7 @@ export function registerPersistenceTools(server, domain) {
|
|
|
1780
1783
|
: { would_run: false, note: "No build host configured — publish will fall back to the LEGACY source-only route (nothing goes live). Set WEBCAKE_BUILD_BASE env or x-webcake-build-base header (prod preset: https://build.webcake.io) to publish for real." },
|
|
1781
1784
|
...(previewExpiryNote ? { note: previewExpiryNote } : {}),
|
|
1782
1785
|
...(domainNote ? { domain_note: domainNote } : {}),
|
|
1783
|
-
request: buildPublishRequestRedacted(config, page_id,
|
|
1786
|
+
request: buildPublishRequestRedacted(config, page_id, source, opts, !!buildBase),
|
|
1784
1787
|
hint: "Re-run with dry_run=false to actually publish.",
|
|
1785
1788
|
});
|
|
1786
1789
|
}
|
|
@@ -1793,7 +1796,7 @@ export function registerPersistenceTools(server, domain) {
|
|
|
1793
1796
|
let buildWarning;
|
|
1794
1797
|
if (buildBase) {
|
|
1795
1798
|
console.error(`[publish_page] calling build host ${buildBase} for page ${page_id}`);
|
|
1796
|
-
const buildResult = await buildPageApp(buildBase, page_id,
|
|
1799
|
+
const buildResult = await buildPageApp(buildBase, page_id, source);
|
|
1797
1800
|
if (buildResult.ok) {
|
|
1798
1801
|
app = buildResult.app;
|
|
1799
1802
|
app_css = buildResult.app_css;
|
|
@@ -1809,7 +1812,7 @@ export function registerPersistenceTools(server, domain) {
|
|
|
1809
1812
|
buildWarning = "No build host configured (WEBCAKE_BUILD_BASE env / x-webcake-build-base header; prod preset has https://build.webcake.io automatically). Fell back to the legacy source-only publish: a version was saved but NOTHING WENT LIVE (the live publish_html route needs the rendered app).";
|
|
1810
1813
|
}
|
|
1811
1814
|
const publishOpts = { ...opts, app, app_css };
|
|
1812
|
-
const outcome = await publishPage(config, page_id,
|
|
1815
|
+
const outcome = await publishPage(config, page_id, source, publishOpts);
|
|
1813
1816
|
return text({
|
|
1814
1817
|
published: outcome.ok,
|
|
1815
1818
|
// live = the PagePublishedV2 record public serving reads was written
|
package/dist/tools/reference.js
CHANGED
|
@@ -9,9 +9,9 @@ import { text } from "../mcp/response.js";
|
|
|
9
9
|
const SPARSE_NOTE = "Skeletons and examples are in the SPARSE authoring shape — emit elements exactly like this (id, type, BOTH breakpoints' styles, specials, real events). OMIT properties/runtime/empty events+children/config: the server hydrates them from factory defaults on validate/persist. A skeleton is what the Webcake editor drops for the type (its colours, font, border, default children) — keep its style keys: the hydration defaults carry no paint.";
|
|
10
10
|
export function registerReferenceTools(server, domain) {
|
|
11
11
|
// 1) Generation guide -------------------------------------------------------
|
|
12
|
-
server.tool("get_generation_guide", "Returns the page-building conventions reference: output shape, the absolute-positioning coordinate system, event vocabulary, and the recommended workflow.", { title: "Get Generation Guide", readOnlyHint: true, openWorldHint: false }, async () => text(domain.guide));
|
|
12
|
+
server.tool("get_generation_guide", "Returns the page-building conventions reference: output shape, the absolute-positioning coordinate system, event vocabulary, and the recommended workflow.", { title: "Get Generation Guide", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async () => text(domain.guide));
|
|
13
13
|
// 2) List elements ----------------------------------------------------------
|
|
14
|
-
server.tool("list_elements", "List every supported element type, grouped by category, with a one-line summary and whether it is a container (can hold children).", { title: "List Element Types", readOnlyHint: true, openWorldHint: false }, async () => {
|
|
14
|
+
server.tool("list_elements", "List every supported element type, grouped by category, with a one-line summary and whether it is a container (can hold children).", { title: "List Element Types", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async () => {
|
|
15
15
|
const byCategory = {};
|
|
16
16
|
for (const t of domain.elementTypes) {
|
|
17
17
|
const d = domain.catalog[t];
|
|
@@ -31,7 +31,7 @@ export function registerReferenceTools(server, domain) {
|
|
|
31
31
|
.array(z.string())
|
|
32
32
|
.optional()
|
|
33
33
|
.describe("Several element types fetched in one call, e.g. ['section','text-block','button','form','input']."),
|
|
34
|
-
}, { title: "Get Element Details", readOnlyHint: true, openWorldHint: false }, async ({ type, types }) => {
|
|
34
|
+
}, { title: "Get Element Details", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async ({ type, types }) => {
|
|
35
35
|
const list = types && types.length ? types : type ? [type] : [];
|
|
36
36
|
if (list.length === 0) {
|
|
37
37
|
return text({ error: "Pass `type` (single) or `types` (non-empty array).", valid_types: domain.elementTypes });
|
|
@@ -70,5 +70,5 @@ export function registerReferenceTools(server, domain) {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
// 4) Page schema ------------------------------------------------------------
|
|
73
|
-
server.tool("get_page_schema", "Returns the full JSON Schema (Draft 2020-12) of a Webcake page source object { page: [...], settings: {...} } for structural reference and validation.", { title: "Get Page JSON Schema", readOnlyHint: true, openWorldHint: false }, async () => text(domain.schema));
|
|
73
|
+
server.tool("get_page_schema", "Returns the full JSON Schema (Draft 2020-12) of a Webcake page source object { page: [...], settings: {...} } for structural reference and validation.", { title: "Get Page JSON Schema", readOnlyHint: true, destructiveHint: false, openWorldHint: false }, async () => text(domain.schema));
|
|
74
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcake-landing-mcp",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.4",
|
|
4
4
|
"description": "MCP server exposing Webcake landing-page element schemas + AI usage hints, and persisting LLM-generated page sources to a Webcake backend.",
|
|
5
5
|
"mcpName": "io.github.vuluu2k/webcake-landing-mcp",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"smoke": "node dist/smoke.js",
|
|
33
33
|
"inspect": "npm run build && npx -y @modelcontextprotocol/inspector node dist/index.js",
|
|
34
34
|
"pack:mcpb": "node scripts/pack-mcpb.mjs",
|
|
35
|
+
"pack:plugin": "node scripts/pack-plugin.mjs",
|
|
35
36
|
"prepare": "npm run build",
|
|
36
37
|
"prepublishOnly": "npm run build && npm run smoke",
|
|
37
38
|
"release": "node scripts/release.js",
|