webcake-storefront-mcp 1.31.2 → 1.31.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/api.js +16 -12
- package/dist/changelog.json +14 -14
- package/dist/guides.js +15 -0
- package/dist/tools/collections.js +48 -22
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -353,25 +353,29 @@ export class WebcakeCmsApi {
|
|
|
353
353
|
const headers = await this.cmsApiHeader();
|
|
354
354
|
return this.request("GET", `/api/v1/dashboard/site/${this.siteId}/db_collections/collections/${tableName}/records`, { query, headers });
|
|
355
355
|
}
|
|
356
|
-
/**
|
|
357
|
-
|
|
356
|
+
/** Create a collection (TABLE). VERIFIED body: { name, table_name } — the table starts with
|
|
357
|
+
* only the system columns (id/inserted_at/updated_at/creator_id). Add custom columns after
|
|
358
|
+
* with updateCollectionSchema(). (Sending a schema in the create body 500s.) */
|
|
359
|
+
async createCollection(params) {
|
|
358
360
|
const headers = await this.cmsApiHeader();
|
|
359
|
-
return this.request("POST", `/api/v1/dashboard/site/${this.siteId}/db_collections
|
|
361
|
+
return this.request("POST", `/api/v1/dashboard/site/${this.siteId}/db_collections`, { body: params, headers, timeout: 60000 });
|
|
360
362
|
}
|
|
361
|
-
/**
|
|
362
|
-
async
|
|
363
|
+
/** Get one collection by id (includes its full `schema`). */
|
|
364
|
+
async getCollectionById(id) {
|
|
363
365
|
const headers = await this.cmsApiHeader();
|
|
364
|
-
return this.request("
|
|
366
|
+
return this.request("GET", `/api/v1/dashboard/site/${this.siteId}/db_collections/${id}`, { headers });
|
|
365
367
|
}
|
|
366
|
-
/**
|
|
367
|
-
|
|
368
|
+
/** Add/edit columns: PATCH the collection's FULL schema array. NOTE: this REPLACES the schema,
|
|
369
|
+
* so it MUST include the existing system columns + your custom ones. Each custom column =
|
|
370
|
+
* { name, type, display_name?, create_type:"custom", is_required?, is_unique? }. */
|
|
371
|
+
async updateCollectionSchema(id, schema) {
|
|
368
372
|
const headers = await this.cmsApiHeader();
|
|
369
|
-
return this.request("
|
|
373
|
+
return this.request("PATCH", `/api/v1/dashboard/site/${this.siteId}/db_collections/${id}`, { body: { schema }, headers, timeout: 60000 });
|
|
370
374
|
}
|
|
371
|
-
/**
|
|
372
|
-
async
|
|
375
|
+
/** Delete a collection (table) by id. */
|
|
376
|
+
async deleteCollection(id) {
|
|
373
377
|
const headers = await this.cmsApiHeader();
|
|
374
|
-
return this.request("
|
|
378
|
+
return this.request("DELETE", `/api/v1/dashboard/site/${this.siteId}/db_collections/${id}`, { headers });
|
|
375
379
|
}
|
|
376
380
|
// ── Blog Articles ──
|
|
377
381
|
listArticles(query) {
|
package/dist/changelog.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "1.31.4",
|
|
4
|
+
"d": "26/06/2026",
|
|
5
|
+
"type": "Added",
|
|
6
|
+
"en": "The guide returned by get_http_function and get_site_custom_code now includes a verified end-to-end \"Custom data TABLES (collections)\" section…",
|
|
7
|
+
"vi": "Hướng dẫn trả về bởi get_http_function và get_site_custom_code nay bổ sung phần \"Custom data TABLES (collections)\" đã được xác minh thực tế, ghi lại…"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"v": "1.31.3",
|
|
11
|
+
"d": "26/06/2026",
|
|
12
|
+
"type": "Added",
|
|
13
|
+
"en": "New update_collection_columns tool reads the current collection schema and PATCHes it with the system columns plus the provided custom columns,…",
|
|
14
|
+
"vi": "Tool mới update_collection_columns đọc schema hiện tại của collection rồi PATCH lại với các cột hệ thống cộng các cột tùy chỉnh được cung cấp, cho…"
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"v": "1.31.2",
|
|
4
18
|
"d": "26/06/2026",
|
|
@@ -26,19 +40,5 @@
|
|
|
26
40
|
"type": "Added",
|
|
27
41
|
"en": "New list_customers tool browses or searches the site's customer list; accepts page, limit, and term (name/phone/email keyword) and returns a compact…",
|
|
28
42
|
"vi": "Tool mới list_customers duyệt hoặc tìm kiếm danh sách khách hàng của site; nhận các tham số page, limit và term (từ khóa tên/điện thoại/email) và…"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"v": "1.29.0",
|
|
32
|
-
"d": "26/06/2026",
|
|
33
|
-
"type": "Added",
|
|
34
|
-
"en": "scaffold_global_sections now accepts a logo parameter (hosted image URL) that renders an image element in the header instead of the brand-name text…",
|
|
35
|
-
"vi": "scaffold_global_sections nay nhận thêm tham số logo (URL hình ảnh được host) để hiển thị phần tử image trong header thay vì node text tên thương hiệu."
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"v": "1.28.0",
|
|
39
|
-
"d": "26/06/2026",
|
|
40
|
-
"type": "Added",
|
|
41
|
-
"en": "New scaffold_popup tool builds and saves a designed newsletter/promo popup (heading + subtext + email subscribe form + close button, centred modal)…",
|
|
42
|
-
"vi": "Tool mới scaffold_popup xây dựng và lưu một popup newsletter/promo được thiết kế sẵn (tiêu đề + phụ đề + form đăng ký email + nút đóng, dạng modal…"
|
|
43
43
|
}
|
|
44
44
|
]
|
package/dist/guides.js
CHANGED
|
@@ -101,6 +101,21 @@ await Members.updateOne({ id: created.id }, { tien_con_lai: 100000 });
|
|
|
101
101
|
const userId = request.customer?.id ?? ""; if (!userId) return { mess: "NO_ACCOUNT_CALL" };
|
|
102
102
|
try { /* … */ return { mess: "OK", ...data }; } catch (err) { console.error(err?.message || err); return { mess: "SYSTEM_ERROR" }; }
|
|
103
103
|
|
|
104
|
+
## Custom data TABLES (collections) — end-to-end (VERIFIED flow)
|
|
105
|
+
A "collection" is a custom DB table. To stand one up and use it from a function:
|
|
106
|
+
1. Create the table + columns with the MCP tools: create_collection({ name, columns:[{name,type},…] })
|
|
107
|
+
then update_collection_columns to change them. (Types: string|text|integer|float|boolean|
|
|
108
|
+
naive_datetime|binary_id|map|array.) The table always has id/inserted_at/updated_at/creator_id.
|
|
109
|
+
2. READ rows directly with the MCP tool query_collection_records({ table_name, where, order_by }).
|
|
110
|
+
3. WRITE rows from an HTTP function via webcake-data — db.model(table) gives full CRUD on it:
|
|
111
|
+
const T = db.model("my_table");
|
|
112
|
+
const row = await T.create({ email: "a@b.com" }); // insert
|
|
113
|
+
await T.updateOne({ id: row.id }, { email: "c@d.com" }); // update
|
|
114
|
+
await T.deleteMany({ email: "a@b.com" }); // delete
|
|
115
|
+
const rows = await T.find({ … }).select([…]).limit(50); // query
|
|
116
|
+
(There is NO direct dashboard record-INSERT API — record writes MUST go through a function.
|
|
117
|
+
Deploy the function with the update_http_function MCP tool, then call it with run_function.)
|
|
118
|
+
|
|
104
119
|
## Built-in @webcake/* modules (first arg is always request; they auth via global.token — these run
|
|
105
120
|
## INSIDE the function sandbox, so they reach the /cms_function endpoints the dashboard JWT can't)
|
|
106
121
|
Thin wrappers over the backend's /cms_function/{site_id}/... endpoints. Pass request so
|
|
@@ -39,26 +39,52 @@ export function registerCollectionTools(server, api, handle) {
|
|
|
39
39
|
query.order_by = order_by;
|
|
40
40
|
return api.queryCollectionRecords(table_name, query);
|
|
41
41
|
}));
|
|
42
|
-
// ──
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
server.tool("
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
42
|
+
// ── Table-management tools (VERIFIED live: create table, edit columns, delete table). ──
|
|
43
|
+
// Field type ∈ string | text | integer | float | boolean | naive_datetime | binary_id | map | array.
|
|
44
|
+
const COLUMN = z.object({
|
|
45
|
+
name: z.string().describe("Column name (snake_case)."),
|
|
46
|
+
type: z.string().describe("string | text | integer | float | boolean | naive_datetime | binary_id | map | array"),
|
|
47
|
+
display_name: z.string().optional(),
|
|
48
|
+
is_required: z.boolean().optional(),
|
|
49
|
+
is_unique: z.boolean().optional(),
|
|
50
|
+
});
|
|
51
|
+
server.tool("create_collection", "Create a new collection (custom data TABLE). It starts with the system columns (id/inserted_at/updated_at/creator_id); pass `columns` to add custom fields. NOTE: to WRITE records into it, use an HTTP function (webcake-data: db.model(table).create({...})) — the dashboard has no direct record-insert API. See get_http_function for the SDK guide.", {
|
|
52
|
+
name: z.string().describe("Display name."),
|
|
53
|
+
table_name: z.string().optional().describe("Table name (snake_case, unique). Defaults to name."),
|
|
54
|
+
columns: z.array(COLUMN).optional().describe("Custom columns to add, e.g. [{name:'email',type:'string'},{name:'amount',type:'integer'}]."),
|
|
55
|
+
}, ({ name, table_name, columns }) => handle(async () => {
|
|
56
|
+
const tn = (table_name || name).trim();
|
|
57
|
+
const created = await api.createCollection({ name, table_name: tn });
|
|
58
|
+
const col = (created && (created.data || created)) || {};
|
|
59
|
+
const id = col.id;
|
|
60
|
+
if (!id)
|
|
61
|
+
return { error: "Collection created but no id returned.", raw: created };
|
|
62
|
+
let schema = col.schema || [];
|
|
63
|
+
if (columns && columns.length) {
|
|
64
|
+
// PATCH the FULL schema = existing system columns + the new custom ones.
|
|
65
|
+
const custom = columns.map((c) => ({ ...c, display_name: c.display_name || c.name, create_type: "custom" }));
|
|
66
|
+
const res = await api.updateCollectionSchema(id, [...schema, ...custom]);
|
|
67
|
+
schema = (res && (res.data || res) || {}).schema || [...schema, ...custom];
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
success: true,
|
|
71
|
+
collection_id: id,
|
|
72
|
+
table_name: col.table_name || tn,
|
|
73
|
+
columns: schema.map((f) => ({ name: f.name, type: f.type, kind: f.create_type || "system" })),
|
|
74
|
+
note: "Write rows via an HTTP function (db.model('" + (col.table_name || tn) + "').create({...})); query them with query_collection_records.",
|
|
75
|
+
};
|
|
76
|
+
}));
|
|
77
|
+
server.tool("update_collection_columns", "Add or change a collection's custom columns. Reads the current schema, then PATCHes it with the system columns + your custom columns (the PATCH replaces the whole schema, so omitting a column drops it).", {
|
|
78
|
+
collection_id: z.string().describe("Collection id (from list_collections / get_collection)."),
|
|
79
|
+
columns: z.array(COLUMN).describe("The FULL set of custom columns the table should have."),
|
|
80
|
+
}, ({ collection_id, columns }) => handle(async () => {
|
|
81
|
+
const cur = await api.getCollectionById(collection_id);
|
|
82
|
+
const schema = ((cur && (cur.data || cur)) || {}).schema || [];
|
|
83
|
+
const system = schema.filter((f) => (f.create_type || "system") === "system");
|
|
84
|
+
const custom = columns.map((c) => ({ ...c, display_name: c.display_name || c.name, create_type: "custom" }));
|
|
85
|
+
const res = await api.updateCollectionSchema(collection_id, [...system, ...custom]);
|
|
86
|
+
const newSchema = ((res && (res.data || res)) || {}).schema || [...system, ...custom];
|
|
87
|
+
return { success: true, collection_id, columns: newSchema.map((f) => ({ name: f.name, type: f.type, kind: f.create_type || "system" })) };
|
|
88
|
+
}));
|
|
89
|
+
server.tool("delete_collection", "Delete a collection (table) and all its records by id. Irreversible.", { collection_id: z.string().describe("Collection id.") }, ({ collection_id }) => handle(() => api.deleteCollection(collection_id)));
|
|
64
90
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcake-storefront-mcp",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.4",
|
|
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",
|