webcake-storefront-mcp 1.0.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/README.md +1166 -0
- package/dist/api.js +346 -0
- package/dist/auth/login.js +87 -0
- package/dist/builder/catalog.js +186 -0
- package/dist/builder/factory.js +1677 -0
- package/dist/builder/guide.js +64 -0
- package/dist/builder/page.js +149 -0
- package/dist/config.js +97 -0
- package/dist/db.js +96 -0
- package/dist/guides.js +93 -0
- package/dist/http.js +120 -0
- package/dist/index.js +73 -0
- package/dist/install.js +140 -0
- package/dist/mongo.js +102 -0
- package/dist/server.js +63 -0
- package/dist/smoke.js +81 -0
- package/dist/tools/apps.js +7 -0
- package/dist/tools/articles.js +53 -0
- package/dist/tools/automation.js +8 -0
- package/dist/tools/builder-extras.js +165 -0
- package/dist/tools/builder.js +124 -0
- package/dist/tools/cms-files.js +255 -0
- package/dist/tools/collections.js +31 -0
- package/dist/tools/combos.js +72 -0
- package/dist/tools/context.js +158 -0
- package/dist/tools/customers.js +13 -0
- package/dist/tools/global-sources.js +662 -0
- package/dist/tools/images.js +875 -0
- package/dist/tools/orders.js +32 -0
- package/dist/tools/pages.js +621 -0
- package/dist/tools/products.js +38 -0
- package/dist/tools/promotions.js +131 -0
- package/dist/tools/site-style.js +157 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,1166 @@
|
|
|
1
|
+
**π [TiαΊΏng Viα»t](README_VI.md)** | English
|
|
2
|
+
|
|
3
|
+
# WebCake Storefront MCP Server
|
|
4
|
+
|
|
5
|
+
MCP server for the WebCake/StoreCake storefront builder β lets AI agents read your site data and build pages.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Published to npm, so there is nothing to clone β everything runs through `npx`.
|
|
10
|
+
|
|
11
|
+
### Configure your IDE automatically (recommended)
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx -y webcake-storefront-mcp install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Interactive: pick your IDE(s) and paste your credentials. Or non-interactive:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx -y webcake-storefront-mcp install \
|
|
21
|
+
--ide all \
|
|
22
|
+
--token YOUR_TOKEN \
|
|
23
|
+
--session YOUR_SESSION_ID \
|
|
24
|
+
--site YOUR_SITE_ID
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Supported IDEs: `claude-desktop`, `claude-code`, `cursor`, `windsurf`, `vscode`, or `all`.
|
|
28
|
+
Uninstall with `npx -y webcake-storefront-mcp uninstall`.
|
|
29
|
+
|
|
30
|
+
### Or connect via the browser (no token copy/paste)
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npx -y webcake-storefront-mcp login
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This opens the builder's connect page; approve it and your token + session are saved to a local config db and picked up automatically.
|
|
37
|
+
|
|
38
|
+
### Manual config (`.mcp.json`)
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"webcake-storefront": {
|
|
44
|
+
"command": "npx",
|
|
45
|
+
"args": ["-y", "webcake-storefront-mcp"],
|
|
46
|
+
"env": {
|
|
47
|
+
"WEBCAKE_TOKEN": "<your-token>",
|
|
48
|
+
"WEBCAKE_SESSION_ID": "<your-session-id>",
|
|
49
|
+
"WEBCAKE_SITE_ID": "<your-site-id>"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Remote server (Streamable-HTTP)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx -y webcake-storefront-mcp serve --port 8787
|
|
60
|
+
# MCP endpoint: http://localhost:8787/mcp?jwt=<token>&site_id=<id>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Environment Variables
|
|
64
|
+
|
|
65
|
+
Required: `WEBCAKE_TOKEN` (Bearer JWT), `WEBCAKE_SESSION_ID` (sent as `x-session-id`), `WEBCAKE_SITE_ID`.
|
|
66
|
+
|
|
67
|
+
Endpoints come from a named environment, so you don't set base URLs by hand:
|
|
68
|
+
|
|
69
|
+
| `WEBCAKE_ENV` / `--env` | api | app (login) | preview |
|
|
70
|
+
|---|---|---|---|
|
|
71
|
+
| `local` | `http://localhost:24679` | `http://localhost:5173` | `demo.localhost:24679/<siteId>` |
|
|
72
|
+
| `staging` | `https://api.staging.storecake.io` | `https://staging.webcake.io` | `staging2.webcake.me/<siteId>` |
|
|
73
|
+
| `prod` (default) | `https://api.storefront.webcake.io` | `https://webcake.io` | `<site_slug>.webcake.me` |
|
|
74
|
+
|
|
75
|
+
Override a preset with `WEBCAKE_API_URL` / `WEBCAKE_APP_URL`. Optional, configured server-side (e.g. on the VPS running `serve`): `PEXELS_API_KEY` (search_images), `MONGO_URI` / `MONGO_DB` / `MONGO_COLLECTION` (image-alt cache).
|
|
76
|
+
|
|
77
|
+
Token / session / site can also be set later from chat via the `update_auth` and `switch_site` tools β values are saved to a local SQLite db at `~/.webcake-storefront-mcp/` and restored next session. The CMS admin token + CMS API key (needed for HTTP-function tools) are fetched automatically.
|
|
78
|
+
|
|
79
|
+
### How to get `WEBCAKE_TOKEN` and `WEBCAKE_SESSION_ID`
|
|
80
|
+
|
|
81
|
+
1. Open the WebCake builder and log in.
|
|
82
|
+
2. Open DevTools (`F12`), go to the **Network** tab, and click any API request.
|
|
83
|
+
3. In **Request Headers**: `Authorization: Bearer ...` β `WEBCAKE_TOKEN`; `x-session-id: ...` β `WEBCAKE_SESSION_ID`.
|
|
84
|
+
4. `WEBCAKE_SITE_ID` is in the builder URL, or use the `list_my_sites` tool to list your sites.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Usage Examples
|
|
89
|
+
|
|
90
|
+
### Example 1: Write backend HTTP function + frontend integration
|
|
91
|
+
|
|
92
|
+
**Prompt:**
|
|
93
|
+
```
|
|
94
|
+
Create a newsletter subscription feature. Backend saves email to "subscribers" collection,
|
|
95
|
+
frontend calls the backend function.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**AI agent will automatically:**
|
|
99
|
+
|
|
100
|
+
**Step 1** β Call `get_http_function` to read current code
|
|
101
|
+
|
|
102
|
+
**Step 2** β Call `update_http_function` to add new functions:
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
import { DBConnection } from 'webcake-data';
|
|
106
|
+
const db = new DBConnection();
|
|
107
|
+
const Subscriber = db.model('subscribers');
|
|
108
|
+
|
|
109
|
+
export const post_Subscribe = async (request) => {
|
|
110
|
+
const { email } = request.params;
|
|
111
|
+
if (!email) return { error: 'Email is required' };
|
|
112
|
+
|
|
113
|
+
const exists = await Subscriber.exists({ email });
|
|
114
|
+
if (exists) return { error: 'Already subscribed' };
|
|
115
|
+
|
|
116
|
+
await Subscriber.create({ email, subscribed_at: new Date() });
|
|
117
|
+
return { success: true, message: 'Subscribed successfully!' };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const get_Subscribers = async (request) => {
|
|
121
|
+
const { page = 1, limit = 20 } = request.params;
|
|
122
|
+
const data = await Subscriber.find()
|
|
123
|
+
.sort({ subscribed_at: -1 })
|
|
124
|
+
.limit(limit)
|
|
125
|
+
.skip((page - 1) * limit)
|
|
126
|
+
.exec();
|
|
127
|
+
const total = await Subscriber.countDocuments();
|
|
128
|
+
return { data, total, page };
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Step 3** β Call `update_site_custom_code` to add frontend code:
|
|
133
|
+
|
|
134
|
+
`code_before_head`:
|
|
135
|
+
```html
|
|
136
|
+
<script src="https://cdn.jsdelivr.net/npm/webcake-fn/dist/webcake-fn.umd.min.js"></script>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`code_custom_javascript`:
|
|
140
|
+
```javascript
|
|
141
|
+
document.getElementById('newsletter-form')?.addEventListener('submit', async (e) => {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
const email = document.getElementById('newsletter-email').value;
|
|
144
|
+
try {
|
|
145
|
+
const result = await api.post_Subscribe({ email });
|
|
146
|
+
if (result.success) {
|
|
147
|
+
window.useNotification('success', { title: result.message });
|
|
148
|
+
} else {
|
|
149
|
+
window.useNotification('error', { title: result.error });
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
window.useNotification('error', { title: 'Error', message: err.message });
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### Example 2: Batch create blog articles
|
|
160
|
+
|
|
161
|
+
**Prompt:**
|
|
162
|
+
```
|
|
163
|
+
Write 3 blog posts about summer skincare, each 300 words, with SEO-friendly slugs.
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**AI agent calls `create_article` 3 times:**
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
create_article({
|
|
170
|
+
name: "5 Steps for Summer Skincare",
|
|
171
|
+
slug: "5-steps-summer-skincare",
|
|
172
|
+
content: "<h2>...</h2><p>...</p>",
|
|
173
|
+
tags: ["skincare", "summer"]
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
create_article({
|
|
177
|
+
name: "Sun Protection Done Right",
|
|
178
|
+
slug: "sun-protection-done-right",
|
|
179
|
+
content: "<h2>...</h2><p>...</p>",
|
|
180
|
+
tags: ["skincare", "sunscreen"]
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
create_article({
|
|
184
|
+
name: "Moisturizing Oily Skin",
|
|
185
|
+
slug: "moisturizing-oily-skin",
|
|
186
|
+
content: "<h2>...</h2><p>...</p>",
|
|
187
|
+
tags: ["skincare", "moisturizer"]
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### Example 3: Debug and test a function
|
|
194
|
+
|
|
195
|
+
**Prompt:**
|
|
196
|
+
```
|
|
197
|
+
Test the get_Subscribers function to see if it works
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**AI agent calls:**
|
|
201
|
+
```
|
|
202
|
+
run_function({
|
|
203
|
+
function_name: "Subscribers",
|
|
204
|
+
method: "GET",
|
|
205
|
+
params: { page: 1, limit: 5 }
|
|
206
|
+
})
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Returns the result or error, AI agent reads and explains to the developer.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### Example 4: Add custom CSS
|
|
214
|
+
|
|
215
|
+
**Prompt:**
|
|
216
|
+
```
|
|
217
|
+
Add hover effect to all product cards: slight lift with drop shadow.
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**AI agent calls `update_site_custom_code`:**
|
|
221
|
+
|
|
222
|
+
`code_custom_css`:
|
|
223
|
+
```css
|
|
224
|
+
.product-card {
|
|
225
|
+
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.product-card:hover {
|
|
229
|
+
transform: translateY(-4px);
|
|
230
|
+
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### Example 5: Find customer and send email
|
|
237
|
+
|
|
238
|
+
**Prompt:**
|
|
239
|
+
```
|
|
240
|
+
Find the customer with email john@example.com and send a thank-you email.
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**AI agent calls 2 tools:**
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
find_customer({ by: "email", value: "john@example.com" })
|
|
247
|
+
β Found: { name: "John Doe", email: "john@example.com" }
|
|
248
|
+
|
|
249
|
+
send_mail({
|
|
250
|
+
to: "john@example.com",
|
|
251
|
+
subject: "Thank you for your purchase!",
|
|
252
|
+
body: "<h2>Hi John Doe,</h2><p>Thank you for shopping with us...</p>"
|
|
253
|
+
})
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
### Example 6: Find and update page elements
|
|
259
|
+
|
|
260
|
+
**Prompt:**
|
|
261
|
+
```
|
|
262
|
+
Change the hero title color to red and update the CTA button text to "Buy Now"
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**AI agent calls 3 tools:**
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
# Step 1: Find the hero title
|
|
269
|
+
search_page_elements({ page_id: "page_1", custom_class: "hero-title" })
|
|
270
|
+
β { matched: 1, elements: [{ id: "TEXT-3", type: "text", ... }] }
|
|
271
|
+
|
|
272
|
+
# Step 2: Find the CTA button
|
|
273
|
+
search_page_elements({ page_id: "page_1", custom_class: "cta" })
|
|
274
|
+
β { matched: 1, elements: [{ id: "BUTTON-1", type: "button", ... }] }
|
|
275
|
+
|
|
276
|
+
# Step 3: Update both elements at once
|
|
277
|
+
update_page_elements({
|
|
278
|
+
page_id: "page_1",
|
|
279
|
+
updates: [
|
|
280
|
+
{ element_id: "TEXT-3", style: { "color": "#ff0000" } },
|
|
281
|
+
{ element_id: "BUTTON-1", specials: { "text": "Buy Now" } }
|
|
282
|
+
]
|
|
283
|
+
})
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Detailed Tool Usage Guide
|
|
289
|
+
|
|
290
|
+
All tools are designed with **token optimization** in mind β list tools return lightweight metadata, detail tools return full data, and guides are loaded on-demand. This section explains the optimal workflow for each tool group.
|
|
291
|
+
|
|
292
|
+
### CMS Files & HTTP Functions
|
|
293
|
+
|
|
294
|
+
#### Step 1: Get overview β `get_http_function` (default: overview mode)
|
|
295
|
+
|
|
296
|
+
By default, returns **only function names and line ranges** β no code body. Very token-efficient for large files.
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
# First time β overview + guide + schemas
|
|
300
|
+
get_http_function({ include_guide: true })
|
|
301
|
+
β {
|
|
302
|
+
file_id: "file_123",
|
|
303
|
+
total_lines: 250,
|
|
304
|
+
imports: "import { DBConnection } from 'webcake-data';",
|
|
305
|
+
functions: [
|
|
306
|
+
{ name: "get_Products", method: "get", function_name: "Products", start_line: 5, end_line: 35, lines: 31 },
|
|
307
|
+
{ name: "post_CreateOrder", method: "post", function_name: "CreateOrder", start_line: 37, end_line: 120, lines: 84 },
|
|
308
|
+
...
|
|
309
|
+
],
|
|
310
|
+
collections: [...],
|
|
311
|
+
guide: "..."
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
# Subsequent calls β overview only
|
|
315
|
+
get_http_function({})
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
To get the full file (when really needed): `get_http_function({ overview: false })`
|
|
319
|
+
|
|
320
|
+
#### Step 2: Read specific functions β `get_http_function_snippet`
|
|
321
|
+
|
|
322
|
+
Read only the function(s) you need β saves 80-95% tokens vs reading the full file.
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
get_http_function_snippet({ function_names: ["get_Products"] })
|
|
326
|
+
β {
|
|
327
|
+
functions: [{
|
|
328
|
+
name: "get_Products", method: "get", function_name: "Products",
|
|
329
|
+
start_line: 5, end_line: 35,
|
|
330
|
+
code: "export const get_Products = (request) => {\n ..."
|
|
331
|
+
}]
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
#### Step 3: Edit by function name β `edit_http_function`
|
|
336
|
+
|
|
337
|
+
Edit functions by **name** β server finds function boundaries automatically. No fragile string matching.
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
# Replace entire function by name (server finds where it starts/ends)
|
|
341
|
+
edit_http_function({
|
|
342
|
+
action: "replace_function",
|
|
343
|
+
function_name: "get_Products",
|
|
344
|
+
code: "export const get_Products = (request) => {\n const db = new DBConnection();\n return db.model('products').find().limit(20).exec();\n}"
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
# Add a new function at end of file
|
|
348
|
+
edit_http_function({
|
|
349
|
+
action: "add",
|
|
350
|
+
code: "export const get_Stats = (request) => {\n return { count: 42 };\n}"
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
# Remove a function by name
|
|
354
|
+
edit_http_function({ action: "remove", function_name: "get_OldFunction" })
|
|
355
|
+
|
|
356
|
+
# Update import block
|
|
357
|
+
edit_http_function({
|
|
358
|
+
action: "update_imports",
|
|
359
|
+
code: "import { DBConnection } from 'webcake-data';\nimport { findArticle } from '@webcake/article';"
|
|
360
|
+
})
|
|
361
|
+
β { success: true, total_lines: 245, functions: [...] }
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
#### Full rewrite (when needed) β `update_http_function`
|
|
365
|
+
|
|
366
|
+
Send full file content. Use `edit_http_function` for targeted changes instead.
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
update_http_function({ content: "import { DBConnection } from 'webcake-data';\n..." })
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### Testing β `debug_function` vs `run_function`
|
|
373
|
+
|
|
374
|
+
| Tool | When to use |
|
|
375
|
+
|------|-------------|
|
|
376
|
+
| `debug_function` | Test code **before deploying** β send code directly, get result + logs |
|
|
377
|
+
| `run_function` | Call an **already deployed** function β like calling a REST API |
|
|
378
|
+
|
|
379
|
+
```
|
|
380
|
+
# Debug: test code without saving
|
|
381
|
+
debug_function({
|
|
382
|
+
content: "export const get_Test = (request) => { return { hello: 'world' }; }",
|
|
383
|
+
function_name: "Test",
|
|
384
|
+
params: {}
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
# Run: call deployed function (note: function_name excludes method prefix)
|
|
388
|
+
run_function({ function_name: "Products", method: "GET", params: { page: 1 } })
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
#### Version management β `save_file_version` / `get_file_versions`
|
|
392
|
+
|
|
393
|
+
Save a snapshot before major changes for rollback capability:
|
|
394
|
+
|
|
395
|
+
```
|
|
396
|
+
save_file_version({ cms_file_id: "file_123", content: "...", is_public: false })
|
|
397
|
+
get_file_versions({ cms_file_id: "file_123" })
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
### Pages & Custom Code
|
|
403
|
+
|
|
404
|
+
#### Step 1: List pages β `list_pages`
|
|
405
|
+
|
|
406
|
+
Returns **metadata only** (no source data) β id, name, slug, type, is_homepage, updated_at.
|
|
407
|
+
|
|
408
|
+
```
|
|
409
|
+
list_pages({})
|
|
410
|
+
β [{ id: "page_1", name: "Home", slug: "/", type: "page", is_homepage: true, ... }, ...]
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### Step 2: Get page overview β `get_page_source`
|
|
414
|
+
|
|
415
|
+
Returns a **lightweight overview** of the page structure β section count, element type counts, and all custom CSS classes used. Does NOT return full source data.
|
|
416
|
+
|
|
417
|
+
```
|
|
418
|
+
get_page_source({ page_id: "page_1" })
|
|
419
|
+
β {
|
|
420
|
+
page: { id, name, slug, type },
|
|
421
|
+
custom_code: { ... },
|
|
422
|
+
overview: {
|
|
423
|
+
sections_count: 5,
|
|
424
|
+
total_elements: 47,
|
|
425
|
+
element_types: { section: 5, container: 12, text: 15, image: 8, button: 7 },
|
|
426
|
+
custom_classes: ["hero-title", "product-card", "cta-button", ...]
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
#### Step 3: Search specific elements β `search_page_elements`
|
|
432
|
+
|
|
433
|
+
Query elements by various filters. Returns **full detail** for each matched element (style, config, specials, events, bindings, responsive breakpoints).
|
|
434
|
+
|
|
435
|
+
```
|
|
436
|
+
# Find all buttons
|
|
437
|
+
search_page_elements({ page_id: "page_1", type: "button" })
|
|
438
|
+
|
|
439
|
+
# Find elements with a specific CSS class
|
|
440
|
+
search_page_elements({ page_id: "page_1", custom_class: "hero" })
|
|
441
|
+
|
|
442
|
+
# Find text containing "subscribe"
|
|
443
|
+
search_page_elements({ page_id: "page_1", text: "subscribe" })
|
|
444
|
+
|
|
445
|
+
# Find all data-bound elements (product, category, blog bindings)
|
|
446
|
+
search_page_elements({ page_id: "page_1", has_bind: true })
|
|
447
|
+
|
|
448
|
+
# Find all elements with click/submit events
|
|
449
|
+
search_page_elements({ page_id: "page_1", has_events: true })
|
|
450
|
+
|
|
451
|
+
# Find all elements that have custom CSS classes
|
|
452
|
+
search_page_elements({ page_id: "page_1", has_custom_class: true })
|
|
453
|
+
|
|
454
|
+
# Combine filters
|
|
455
|
+
search_page_elements({ page_id: "page_1", type: "text", custom_class: "hero", limit: 10 })
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
Each matched element returns:
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"id": "TEXT-3",
|
|
463
|
+
"type": "text",
|
|
464
|
+
"style": { "color": "#333", "font-size": "18px", ... },
|
|
465
|
+
"config": { ... },
|
|
466
|
+
"specials": { "text": "Subscribe now", "custom_class": "cta-text", "custom_css": "..." },
|
|
467
|
+
"events": [{ "eventName": "click", "action": "open_page", ... }],
|
|
468
|
+
"bindings": [{ "name": "product", "target": "title", ... }],
|
|
469
|
+
"responsive": {
|
|
470
|
+
"bp_320_768": { "style": { "font-size": "14px" } },
|
|
471
|
+
"bp_768_1024": { "style": { "font-size": "16px" } }
|
|
472
|
+
},
|
|
473
|
+
"children_count": 3
|
|
474
|
+
}
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**CSS targeting**: Sections render as `<section id="SECTION-1" class="x-section {custom_class}">`, elements as `<div id="TEXT-3" class="x-element {custom_class}">`. Target via `#TEXT-3` (by ID) or `.cta-text` (by custom class).
|
|
478
|
+
|
|
479
|
+
#### Custom code β `get_site_custom_code` / `append_site_custom_code`
|
|
480
|
+
|
|
481
|
+
**Read specific fields only** to save tokens when code is large:
|
|
482
|
+
|
|
483
|
+
```
|
|
484
|
+
# Read only CSS (skip large JS)
|
|
485
|
+
get_site_custom_code({ fields: ["code_custom_css"] })
|
|
486
|
+
β { code_custom_css: ".hero { color: #333; ... }" }
|
|
487
|
+
|
|
488
|
+
# Read all β _sizes shows character count per field
|
|
489
|
+
get_site_custom_code({ include_guide: true })
|
|
490
|
+
β { ..., _sizes: { code_custom_css: 3500, code_custom_javascript: 8200, ... }, guide: "..." }
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
**Add new code** β append/prepend without reading existing content:
|
|
494
|
+
|
|
495
|
+
```
|
|
496
|
+
# Append new CSS rules
|
|
497
|
+
append_site_custom_code({ field: "code_custom_css", code: ".new-section { padding: 20px; }" })
|
|
498
|
+
|
|
499
|
+
# Prepend a script tag to head
|
|
500
|
+
append_site_custom_code({ field: "code_before_head", position: "prepend",
|
|
501
|
+
code: "<script src='https://cdn.example.com/lib.js'></script>" })
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
**Full update** β read first, then rewrite entire field:
|
|
505
|
+
```
|
|
506
|
+
get_site_custom_code({ fields: ["code_custom_css"] }) # read only CSS
|
|
507
|
+
update_site_custom_code({ code_custom_css: ".hero { ... }\n.new-style { ... }" })
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
| Field | Where it's injected | Use for |
|
|
511
|
+
|-------|-------------------|---------|
|
|
512
|
+
| `code_before_head` | Before `</head>` | External scripts, meta tags |
|
|
513
|
+
| `code_before_body` | Before `</body>` | Tracking scripts, chat widgets |
|
|
514
|
+
| `code_custom_css` | Auto-wrapped in `<style>` | Custom CSS styles |
|
|
515
|
+
| `code_custom_javascript` | As inline `<script>` | Custom JavaScript |
|
|
516
|
+
|
|
517
|
+
#### Step 4: Update elements β `update_page_element` / `update_page_elements`
|
|
518
|
+
|
|
519
|
+
After finding elements via search, update their properties directly in the page source.
|
|
520
|
+
|
|
521
|
+
**Single element update:**
|
|
522
|
+
```
|
|
523
|
+
# Change text and style of a specific element
|
|
524
|
+
update_page_element({
|
|
525
|
+
page_id: "page_1",
|
|
526
|
+
element_id: "TEXT-3",
|
|
527
|
+
style: { "color": "#ff0000", "font-size": "24px" },
|
|
528
|
+
specials: { "text": "New heading text", "custom_class": "hero-title,bold" }
|
|
529
|
+
})
|
|
530
|
+
|
|
531
|
+
# Add events to a button
|
|
532
|
+
update_page_element({
|
|
533
|
+
page_id: "page_1",
|
|
534
|
+
element_id: "BUTTON-1",
|
|
535
|
+
events: [{ "eventName": "click", "action": "open_page", "open_page_id": "page_2" }]
|
|
536
|
+
})
|
|
537
|
+
|
|
538
|
+
# Update responsive styles
|
|
539
|
+
update_page_element({
|
|
540
|
+
page_id: "page_1",
|
|
541
|
+
element_id: "TEXT-3",
|
|
542
|
+
responsive: {
|
|
543
|
+
"bp_320_768": { "style": { "font-size": "14px" } },
|
|
544
|
+
"bp_768_1024": { "style": { "font-size": "18px" } }
|
|
545
|
+
}
|
|
546
|
+
})
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
**Batch update multiple elements at once:**
|
|
550
|
+
```
|
|
551
|
+
update_page_elements({
|
|
552
|
+
page_id: "page_1",
|
|
553
|
+
updates: [
|
|
554
|
+
{ element_id: "TEXT-1", specials: { "text": "Welcome" } },
|
|
555
|
+
{ element_id: "TEXT-2", style: { "color": "#333" } },
|
|
556
|
+
{ element_id: "BUTTON-1", specials: { "custom_class": "cta-primary" } }
|
|
557
|
+
]
|
|
558
|
+
})
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
**Merge rules:**
|
|
562
|
+
| Property | Behavior | Example |
|
|
563
|
+
|----------|----------|---------|
|
|
564
|
+
| `style` | Shallow merge | Only changed CSS properties are updated, others kept |
|
|
565
|
+
| `config` | Shallow merge | Same as style |
|
|
566
|
+
| `specials` | Shallow merge | Update `text`, `custom_class`, `custom_css` individually |
|
|
567
|
+
| `events` | Replace | Entire events array is replaced (get current first) |
|
|
568
|
+
| `bindings` | Replace | Entire bindings array is replaced |
|
|
569
|
+
| `responsive` | Merge by breakpoint | Each `bp_*` key is set/replaced individually |
|
|
570
|
+
|
|
571
|
+
#### Get single element detail β `get_page_element`
|
|
572
|
+
|
|
573
|
+
Get full detail of one element by its ID, including children IDs for tree navigation.
|
|
574
|
+
|
|
575
|
+
```
|
|
576
|
+
get_page_element({ page_id: "page_1", element_id: "SECTION-1" })
|
|
577
|
+
β { id: "SECTION-1", type: "section", style: {...}, specials: {...},
|
|
578
|
+
children: [{ id: "CONTAINER-1", type: "container" }, { id: "TEXT-1", type: "text" }] }
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
#### Custom code β `get_site_custom_code` / `update_site_custom_code`
|
|
582
|
+
|
|
583
|
+
**Always read before writing** to avoid overwriting existing code.
|
|
584
|
+
|
|
585
|
+
On the **first call**, set `include_guide=true` to get the coding guide (~400 tokens). Omit on subsequent calls.
|
|
586
|
+
|
|
587
|
+
```
|
|
588
|
+
# First time β read current code + guide
|
|
589
|
+
get_site_custom_code({ include_guide: true })
|
|
590
|
+
β {
|
|
591
|
+
code_before_head: "<script src='...'>",
|
|
592
|
+
code_before_body: "",
|
|
593
|
+
code_custom_css: ".hero { ... }",
|
|
594
|
+
code_custom_javascript: "document.addEventListener(...)",
|
|
595
|
+
guide: "..."
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
# Update β only send the fields you want to change
|
|
599
|
+
update_site_custom_code({ code_custom_css: ".hero { ... }\n.new-style { ... }" })
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
| Field | Where it's injected | Use for |
|
|
603
|
+
|-------|-------------------|---------|
|
|
604
|
+
| `code_before_head` | Before `</head>` | External scripts, meta tags |
|
|
605
|
+
| `code_before_body` | Before `</body>` | Tracking scripts, chat widgets |
|
|
606
|
+
| `code_custom_css` | Auto-wrapped in `<style>` | Custom CSS styles |
|
|
607
|
+
| `code_custom_javascript` | As inline `<script>` | Custom JavaScript |
|
|
608
|
+
|
|
609
|
+
#### Recommended workflows
|
|
610
|
+
|
|
611
|
+
**CSS/JS tasks:**
|
|
612
|
+
```
|
|
613
|
+
1. list_pages() β find the target page
|
|
614
|
+
2. get_page_source({ page_id }) β understand page structure
|
|
615
|
+
3. search_page_elements({ page_id, ... }) β find specific elements to style
|
|
616
|
+
4. get_site_custom_code({ include_guide: true }) β read existing code
|
|
617
|
+
5. update_site_custom_code({ ... }) β write new code (merged with existing)
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
**Direct element modification:**
|
|
621
|
+
```
|
|
622
|
+
1. list_pages() β find the target page
|
|
623
|
+
2. get_page_source({ page_id }) β overview of elements
|
|
624
|
+
3. search_page_elements({ page_id, ... }) β find elements to modify
|
|
625
|
+
4. update_page_element({ page_id, element_id, ... }) β update properties
|
|
626
|
+
or update_page_elements({ page_id, updates: [...] }) β batch update
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
---
|
|
630
|
+
|
|
631
|
+
### Collections (Database)
|
|
632
|
+
|
|
633
|
+
#### List collections β `list_collections`
|
|
634
|
+
|
|
635
|
+
Returns **summary only** β name, table_name, field count. Does NOT include full schema definitions.
|
|
636
|
+
|
|
637
|
+
```
|
|
638
|
+
list_collections({})
|
|
639
|
+
β {
|
|
640
|
+
data: [
|
|
641
|
+
{ id: "col_1", name: "Subscribers", table_name: "subscribers", fields_count: 5 },
|
|
642
|
+
{ id: "col_2", name: "Orders", table_name: "custom_orders", fields_count: 12 },
|
|
643
|
+
...
|
|
644
|
+
],
|
|
645
|
+
total: 8
|
|
646
|
+
}
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
#### Get full schema β `get_collection`
|
|
650
|
+
|
|
651
|
+
Use this to get complete field definitions (name, type, constraints, references) when you need to write queries.
|
|
652
|
+
|
|
653
|
+
```
|
|
654
|
+
get_collection({ id: "col_1" })
|
|
655
|
+
β { name: "Subscribers", table_name: "subscribers", schema: [
|
|
656
|
+
{ name: "email", type: "string", is_required: true },
|
|
657
|
+
{ name: "subscribed_at", type: "datetime", is_required: false },
|
|
658
|
+
...
|
|
659
|
+
]}
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
#### Query records β `query_collection_records`
|
|
663
|
+
|
|
664
|
+
Inspect existing data using the **table_name** (not collection ID).
|
|
665
|
+
|
|
666
|
+
```
|
|
667
|
+
query_collection_records({ table_name: "subscribers", page: 1, limit: 10 })
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
---
|
|
671
|
+
|
|
672
|
+
### Blog Articles
|
|
673
|
+
|
|
674
|
+
#### List articles β `list_articles`
|
|
675
|
+
|
|
676
|
+
Returns **metadata only** β no HTML content. Saves significant tokens for sites with many articles.
|
|
677
|
+
|
|
678
|
+
```
|
|
679
|
+
list_articles({ page: 1, limit: 20 })
|
|
680
|
+
β {
|
|
681
|
+
data: [
|
|
682
|
+
{ id: "art_1", name: "Getting Started", slug: "getting-started", summary: "...",
|
|
683
|
+
tags: ["tutorial"], category_id: "cat_1", created_at: "...", updated_at: "..." },
|
|
684
|
+
...
|
|
685
|
+
],
|
|
686
|
+
total: 45
|
|
687
|
+
}
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
#### Get full article β `get_article`
|
|
691
|
+
|
|
692
|
+
Use this when you need the full HTML content of a specific article.
|
|
693
|
+
|
|
694
|
+
```
|
|
695
|
+
get_article({ id: "art_1" })
|
|
696
|
+
β { id: "art_1", name: "...", content: "<h2>...</h2><p>Full HTML content...</p>", ... }
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
---
|
|
700
|
+
|
|
701
|
+
### Products
|
|
702
|
+
|
|
703
|
+
#### List products β `list_products`
|
|
704
|
+
|
|
705
|
+
Returns **metadata only** β id, name, slug, price, image, status. No full description or variations.
|
|
706
|
+
|
|
707
|
+
```
|
|
708
|
+
list_products({ page: 1, limit: 20, term: "shirt" })
|
|
709
|
+
β {
|
|
710
|
+
data: [
|
|
711
|
+
{ id: "prod_1", name: "Blue Shirt", slug: "blue-shirt", price: 29.99,
|
|
712
|
+
image: "https://...", is_published: true, total_sold: 150, ... },
|
|
713
|
+
...
|
|
714
|
+
],
|
|
715
|
+
total: 42
|
|
716
|
+
}
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
#### Get full product β `get_product`
|
|
720
|
+
|
|
721
|
+
Returns complete product data: description, variations (sizes/colors/prices), attributes, images, SEO meta.
|
|
722
|
+
|
|
723
|
+
```
|
|
724
|
+
get_product({ id: "prod_1" })
|
|
725
|
+
β { id: "prod_1", name: "Blue Shirt", description: "<p>...</p>",
|
|
726
|
+
variations: [...], product_attributes: [...], meta_tags: [...], ... }
|
|
727
|
+
```
|
|
728
|
+
|
|
729
|
+
#### Search products β `search_products`
|
|
730
|
+
|
|
731
|
+
Quick keyword search across product names.
|
|
732
|
+
|
|
733
|
+
```
|
|
734
|
+
search_products({ term: "summer dress", limit: 10 })
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
#### Product categories β `list_categories`
|
|
738
|
+
|
|
739
|
+
List all product categories of the site.
|
|
740
|
+
|
|
741
|
+
```
|
|
742
|
+
list_categories({})
|
|
743
|
+
β [{ id: "cat_1", name: "Shirts", slug: "shirts", ... }, ...]
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
748
|
+
### Orders
|
|
749
|
+
|
|
750
|
+
#### List orders β `list_orders`
|
|
751
|
+
|
|
752
|
+
Returns order **metadata only** β customer name, status, total value. No item details.
|
|
753
|
+
|
|
754
|
+
```
|
|
755
|
+
list_orders({ page: 1, limit: 20, status: 50 })
|
|
756
|
+
β {
|
|
757
|
+
data: [
|
|
758
|
+
{ id: "ord_1", bill_full_name: "John Doe", status: 50,
|
|
759
|
+
invoice_value: 99.99, items_count: 3, created_at: "..." },
|
|
760
|
+
...
|
|
761
|
+
],
|
|
762
|
+
total: 128
|
|
763
|
+
}
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
**Status codes:** 0=pending, 50=confirmed, 100=shipping, 150=delivered, -1=cancelled
|
|
767
|
+
|
|
768
|
+
#### Get full order β `get_order`
|
|
769
|
+
|
|
770
|
+
Returns complete order: items with product details, customer info, payment, shipping, discounts.
|
|
771
|
+
|
|
772
|
+
```
|
|
773
|
+
get_order({ id: "ord_1" })
|
|
774
|
+
β { id: "ord_1", bill_full_name: "John Doe", items: [...], shipping_address: {...}, ... }
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
#### Order statistics β `count_orders_by_status`
|
|
778
|
+
|
|
779
|
+
Get order count grouped by status for dashboard overview.
|
|
780
|
+
|
|
781
|
+
```
|
|
782
|
+
count_orders_by_status({})
|
|
783
|
+
β { pending: 5, confirmed: 12, shipping: 3, delivered: 108, cancelled: 2 }
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
---
|
|
787
|
+
|
|
788
|
+
### Promotions & Discounts
|
|
789
|
+
|
|
790
|
+
#### List promotions β `list_promotions`
|
|
791
|
+
|
|
792
|
+
Returns promotion **metadata only** β name, type, status, schedule. Use `include_guide=true` for promotion type reference.
|
|
793
|
+
|
|
794
|
+
```
|
|
795
|
+
list_promotions({ page: 1, limit: 20, include_guide: true })
|
|
796
|
+
β {
|
|
797
|
+
data: [
|
|
798
|
+
{ id: "promo_1", name: "Summer Sale 30%", type: "normal",
|
|
799
|
+
is_activated: true, start_time: "2025-06-01", end_time: "2025-06-30",
|
|
800
|
+
priority_level: 1, used_count: 45 },
|
|
801
|
+
{ id: "promo_2", name: "WELCOME10", type: "coupon",
|
|
802
|
+
is_activated: true, coupon_info: { code: "WELCOME10", max_uses: 100 } },
|
|
803
|
+
...
|
|
804
|
+
],
|
|
805
|
+
total: 8,
|
|
806
|
+
guide: "## Promotion Types..."
|
|
807
|
+
}
|
|
808
|
+
```
|
|
809
|
+
|
|
810
|
+
#### Get full promotion β `get_promotion`
|
|
811
|
+
|
|
812
|
+
Returns complete promotion: discount rules, coupon settings, items, bonus products, customer levels.
|
|
813
|
+
|
|
814
|
+
```
|
|
815
|
+
get_promotion({ id: "promo_1" })
|
|
816
|
+
β { id: "promo_1", name: "Summer Sale 30%", type: "normal", items: [...],
|
|
817
|
+
bonus_items: [...], customer_levels: [...], ... }
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
#### Get promotion items β `get_promotion_items`
|
|
821
|
+
|
|
822
|
+
Returns products/variations/categories attached to a promotion with detailed discount info.
|
|
823
|
+
|
|
824
|
+
```
|
|
825
|
+
get_promotion_items({ id: "promo_1", page: 1, limit: 20 })
|
|
826
|
+
β { items: [{ id: "item_1", product: { name: "..." }, fixed_prices: 299000,
|
|
827
|
+
level_info: [...] }], total_items: 15 }
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
#### Active promotions β `get_active_promotions`
|
|
831
|
+
|
|
832
|
+
Get all currently active promotions (activated and within schedule).
|
|
833
|
+
|
|
834
|
+
```
|
|
835
|
+
get_active_promotions({})
|
|
836
|
+
β { data: [{ id: "promo_1", name: "Summer Sale", type: "normal", is_activated: true, ... }], total: 3 }
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
#### Search/filter promotions β `search_promotions`
|
|
840
|
+
|
|
841
|
+
Filter by type, time status, keyword, active state.
|
|
842
|
+
|
|
843
|
+
```
|
|
844
|
+
search_promotions({ type: "coupon", status: 2, is_activated: true })
|
|
845
|
+
β { promotions: [...], total: 5 }
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
**Status filter:** 1=coming_soon, 2=in_progress, 3=finished
|
|
849
|
+
|
|
850
|
+
---
|
|
851
|
+
|
|
852
|
+
### Combo / Bundle Products
|
|
853
|
+
|
|
854
|
+
#### List combos β `list_combos`
|
|
855
|
+
|
|
856
|
+
Returns combo **metadata** β name, discount type, schedule. Use `include_guide=true` for combo type reference.
|
|
857
|
+
|
|
858
|
+
```
|
|
859
|
+
list_combos({ page: 1, limit: 20, include_guide: true })
|
|
860
|
+
β {
|
|
861
|
+
data: [
|
|
862
|
+
{ id: "combo_1", name: "Summer Bundle", is_activated: true,
|
|
863
|
+
is_variation: false, discount_amount: 50000,
|
|
864
|
+
start_time: "2025-06-01", end_time: "2025-06-30" },
|
|
865
|
+
{ id: "combo_2", name: "Buy 3 Get 1 Free", is_activated: true,
|
|
866
|
+
is_categories: true, is_use_percent: true, discount_by_percent: 25 },
|
|
867
|
+
],
|
|
868
|
+
total: 4,
|
|
869
|
+
guide: "## Combo Product Types..."
|
|
870
|
+
}
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
**Combo types:**
|
|
874
|
+
- `is_variation=true` β Variation-based: requires specific product variations
|
|
875
|
+
- `is_variation=false` β Product-based: requires specific products (any variation)
|
|
876
|
+
- `is_categories=true` β Category-based: requires items from categories with quantities
|
|
877
|
+
|
|
878
|
+
**Discount types:**
|
|
879
|
+
- `discount_amount` β Fixed amount off
|
|
880
|
+
- `is_use_percent=true` + `discount_by_percent` β Percentage off (capped by `max_discount_by_percent`)
|
|
881
|
+
- `is_value_combo=true` + `value_combo` β Fixed total price for combo
|
|
882
|
+
- `is_free_shipping=true` β Free shipping included
|
|
883
|
+
|
|
884
|
+
#### Get combo items β `get_combo_items`
|
|
885
|
+
|
|
886
|
+
Returns the products/variations that compose the combo and any bonus/gift products.
|
|
887
|
+
|
|
888
|
+
```
|
|
889
|
+
get_combo_items({ combo_product_id: "combo_1" })
|
|
890
|
+
β {
|
|
891
|
+
combo_items: [
|
|
892
|
+
{ id: "item_1", product: { name: "T-Shirt" }, count: 2 },
|
|
893
|
+
{ id: "item_2", product: { name: "Shorts" }, count: 1 },
|
|
894
|
+
],
|
|
895
|
+
bonus_items: [
|
|
896
|
+
{ id: "bonus_1", product: { name: "Free Socks" }, quantity: 1 }
|
|
897
|
+
]
|
|
898
|
+
}
|
|
899
|
+
```
|
|
900
|
+
|
|
901
|
+
---
|
|
902
|
+
|
|
903
|
+
### Site Style & Theme
|
|
904
|
+
|
|
905
|
+
#### Site info β `get_site_info`
|
|
906
|
+
|
|
907
|
+
Get full site configuration: name, domain, logo, and **all settings** (colors, typography, layout, language, payment methods, etc.).
|
|
908
|
+
|
|
909
|
+
```
|
|
910
|
+
get_site_info({})
|
|
911
|
+
β { id: "site_1", name: "My Store", domain: "mystore.storecake.io",
|
|
912
|
+
settings: { primary_colors: [...], typography: {...}, layout_mode: "...", ... } }
|
|
913
|
+
```
|
|
914
|
+
|
|
915
|
+
#### Themes β `list_themes`
|
|
916
|
+
|
|
917
|
+
List all custom themes: colors, typographies, transitions, and which is currently active.
|
|
918
|
+
|
|
919
|
+
```
|
|
920
|
+
list_themes({})
|
|
921
|
+
β [{ id: "theme_1", name: "Modern", colors: {...}, typographies: {...}, is_selected: true }, ...]
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
---
|
|
925
|
+
|
|
926
|
+
### Applications
|
|
927
|
+
|
|
928
|
+
#### Installed apps β `list_apps`
|
|
929
|
+
|
|
930
|
+
List all installed applications/subscriptions with their settings and status.
|
|
931
|
+
|
|
932
|
+
```
|
|
933
|
+
list_apps({})
|
|
934
|
+
β [{ id: "app_1", type: 1, is_active: true, settings: {...} }, ...]
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
**Common app types:** 1=CMS, 2=Product Design, 10=Multilingual
|
|
938
|
+
|
|
939
|
+
#### Get app detail β `get_app`
|
|
940
|
+
|
|
941
|
+
Get a specific app by its type ID.
|
|
942
|
+
|
|
943
|
+
```
|
|
944
|
+
get_app({ type: "1" })
|
|
945
|
+
β { id: "app_1", type: 1, is_active: true, settings: {...} }
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
---
|
|
949
|
+
|
|
950
|
+
### Custom Knowledge (Training)
|
|
951
|
+
|
|
952
|
+
Add your own knowledge files so AI agents have custom context about your business, coding standards, or workflows.
|
|
953
|
+
|
|
954
|
+
Knowledge supports two sources: **local files** and **GitHub repo**. Both can be used together β local files take priority if names conflict.
|
|
955
|
+
|
|
956
|
+
#### Source 1: Local files
|
|
957
|
+
|
|
958
|
+
Drop `.md` or `.txt` files into the `knowledge/` directory (next to `index.js`):
|
|
959
|
+
|
|
960
|
+
```
|
|
961
|
+
knowledge/
|
|
962
|
+
business-rules.md
|
|
963
|
+
coding-standards.md
|
|
964
|
+
api-docs.md
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
Or set a custom directory:
|
|
968
|
+
```json
|
|
969
|
+
{ "env": { "WEBCAKE_KNOWLEDGE_DIR": "/path/to/my/knowledge" } }
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
#### Source 2: GitHub repo
|
|
973
|
+
|
|
974
|
+
Point to a GitHub repo containing knowledge files. The AI agent will fetch and read them automatically.
|
|
975
|
+
|
|
976
|
+
```json
|
|
977
|
+
{
|
|
978
|
+
"env": {
|
|
979
|
+
"WEBCAKE_KNOWLEDGE_REPO": "your-org/my-knowledge"
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
**Supported formats:**
|
|
985
|
+
|
|
986
|
+
| Format | Example |
|
|
987
|
+
|--------|---------|
|
|
988
|
+
| `owner/repo` | `acme/knowledge-base` |
|
|
989
|
+
| `owner/repo/subdir` | `acme/docs/ai-guides` |
|
|
990
|
+
| Full URL | `https://github.com/acme/knowledge-base` |
|
|
991
|
+
| URL with branch + path | `https://github.com/acme/docs/tree/main/ai-guides` |
|
|
992
|
+
|
|
993
|
+
**Private repos** β add a GitHub personal access token:
|
|
994
|
+
```json
|
|
995
|
+
{
|
|
996
|
+
"env": {
|
|
997
|
+
"WEBCAKE_KNOWLEDGE_REPO": "your-org/private-knowledge",
|
|
998
|
+
"WEBCAKE_KNOWLEDGE_TOKEN": "ghp_xxxxxxxxxxxx"
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
Files are cached for 5 minutes to avoid GitHub API rate limits.
|
|
1004
|
+
|
|
1005
|
+
#### File format
|
|
1006
|
+
|
|
1007
|
+
Files support optional frontmatter for name and description:
|
|
1008
|
+
|
|
1009
|
+
```markdown
|
|
1010
|
+
---
|
|
1011
|
+
name: Business Rules
|
|
1012
|
+
description: E-commerce shipping and return policies
|
|
1013
|
+
tags: business, policy
|
|
1014
|
+
---
|
|
1015
|
+
|
|
1016
|
+
## Shipping Policy
|
|
1017
|
+
- Free shipping for orders over $50
|
|
1018
|
+
- Express shipping: 2-3 business days
|
|
1019
|
+
...
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
#### Usage
|
|
1023
|
+
|
|
1024
|
+
```
|
|
1025
|
+
# List available knowledge files
|
|
1026
|
+
list_knowledge({})
|
|
1027
|
+
β { files: [
|
|
1028
|
+
{ file: "business-rules", name: "Business Rules", description: "E-commerce shipping..." },
|
|
1029
|
+
{ file: "coding-standards", name: "Coding Standards", description: "..." }
|
|
1030
|
+
]}
|
|
1031
|
+
|
|
1032
|
+
# Read a specific file
|
|
1033
|
+
get_knowledge({ file: "business-rules" })
|
|
1034
|
+
β { file: "business-rules.md", name: "Business Rules", content: "## Shipping Policy\n..." }
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
AI agents will use this knowledge as context when helping with tasks. For example, if you have shipping rules documented, the AI will reference them when writing order-related code.
|
|
1038
|
+
|
|
1039
|
+
---
|
|
1040
|
+
|
|
1041
|
+
### Token Optimization Summary
|
|
1042
|
+
|
|
1043
|
+
| Pattern | Tokens saved | How |
|
|
1044
|
+
|---------|-------------|-----|
|
|
1045
|
+
| Lazy guides (`include_guide`) | ~600-1000 per call | Only load guide on first call |
|
|
1046
|
+
| List = metadata only | 50-90% per list call | HTML content, source JSON, full schemas stripped from list responses |
|
|
1047
|
+
| Overview + Search (pages) | ~85-90% | Overview gives structure, search gives only matched elements |
|
|
1048
|
+
| HTTP function overview + snippet | ~80-95% per read | Overview shows function list only, snippet reads just the needed function |
|
|
1049
|
+
| `edit_http_function` | ~70-90% per edit | Replace/add/remove by function name, not full file |
|
|
1050
|
+
| Custom code field filter | ~50-80% per read | Read only CSS or JS instead of all 4 fields |
|
|
1051
|
+
| `append_site_custom_code` | ~100% on add | Append/prepend without reading existing content |
|
|
1052
|
+
| Compact JSON | ~30% per response | No pretty-printing in responses |
|
|
1053
|
+
|
|
1054
|
+
---
|
|
1055
|
+
|
|
1056
|
+
## Available Tools
|
|
1057
|
+
|
|
1058
|
+
### CMS Files (12 tools)
|
|
1059
|
+
| Tool | Description |
|
|
1060
|
+
|------|-------------|
|
|
1061
|
+
| `list_cms_files` | List all CMS files |
|
|
1062
|
+
| `create_cms_file` | Create HTTP function / cron job / default file |
|
|
1063
|
+
| `update_cms_file` | Update file content |
|
|
1064
|
+
| `get_http_function` | **Default**: full code + schemas. **overview=true**: function list only (for browsing). `include_guide=true` for coding guide |
|
|
1065
|
+
| `get_http_function_snippet` | Read specific function(s) by name β much more token-efficient than full file |
|
|
1066
|
+
| `edit_http_function` | Edit by function name: replace_function/add/remove/update_imports β no string matching needed |
|
|
1067
|
+
| `update_http_function` | Full file write β best for new features, major refactors. `edit_http_function` for small fixes |
|
|
1068
|
+
| `run_function` | Execute a deployed function |
|
|
1069
|
+
| `debug_function` | Run code in debug mode (without deploying) |
|
|
1070
|
+
| `save_file_version` | Save version snapshot for rollback |
|
|
1071
|
+
| `get_file_versions` | Get version history |
|
|
1072
|
+
| `toggle_debug_render` | Toggle debug render mode |
|
|
1073
|
+
|
|
1074
|
+
### Pages (16 tools)
|
|
1075
|
+
| Tool | Description |
|
|
1076
|
+
|------|-------------|
|
|
1077
|
+
| `list_pages` | List all pages (metadata only, no source) |
|
|
1078
|
+
| `get_page_source` | Get page overview: section count, element types, custom classes |
|
|
1079
|
+
| `search_page_elements` | Search elements by type, id, class, text, bind, events (returns full detail) |
|
|
1080
|
+
| `get_page_element` | Get full detail of a single element by ID (includes children IDs) |
|
|
1081
|
+
| `update_page_element` | Update element properties: style, config, specials, events, bindings, responsive |
|
|
1082
|
+
| `update_page_elements` | Batch update multiple elements in one call |
|
|
1083
|
+
| `create_page` | Create a new page |
|
|
1084
|
+
| `update_page` | Update page properties |
|
|
1085
|
+
| `get_site_custom_code` | Read CSS/JS. Use `fields` to read only specific fields. `include_guide=true` for guide |
|
|
1086
|
+
| `update_site_custom_code` | Write full CSS/JS custom code (only specified fields are updated) |
|
|
1087
|
+
| `append_site_custom_code` | Append/prepend CSS/JS code without reading first β for adding new rules |
|
|
1088
|
+
| `delete_page` | Delete a page |
|
|
1089
|
+
| `get_page_versions` | Page version history |
|
|
1090
|
+
| `list_page_contents` | Multi-language contents |
|
|
1091
|
+
| `update_page_content` | Update content for a language |
|
|
1092
|
+
| `list_global_sections` | List reusable global sections |
|
|
1093
|
+
|
|
1094
|
+
### Collections β Database (3 tools)
|
|
1095
|
+
| Tool | Description |
|
|
1096
|
+
|------|-------------|
|
|
1097
|
+
| `list_collections` | List collections (name, table_name, field count only) |
|
|
1098
|
+
| `get_collection` | Get full schema: field names, types, constraints, references |
|
|
1099
|
+
| `query_collection_records` | Query records by table_name |
|
|
1100
|
+
|
|
1101
|
+
### Blog Articles (5 tools)
|
|
1102
|
+
| Tool | Description |
|
|
1103
|
+
|------|-------------|
|
|
1104
|
+
| `list_articles` | List articles (metadata only, no HTML content) |
|
|
1105
|
+
| `get_article` | Get full article with HTML content |
|
|
1106
|
+
| `create_article` | Create article |
|
|
1107
|
+
| `update_article` | Update article |
|
|
1108
|
+
| `delete_article` | Delete article |
|
|
1109
|
+
|
|
1110
|
+
### Products (4 tools)
|
|
1111
|
+
| Tool | Description |
|
|
1112
|
+
|------|-------------|
|
|
1113
|
+
| `list_products` | List products (metadata: name, slug, price, image, status) |
|
|
1114
|
+
| `get_product` | Get full product: description, variations, attributes, images, SEO |
|
|
1115
|
+
| `search_products` | Search products by keyword |
|
|
1116
|
+
| `list_categories` | List all product categories |
|
|
1117
|
+
|
|
1118
|
+
### Orders (3 tools)
|
|
1119
|
+
| Tool | Description |
|
|
1120
|
+
|------|-------------|
|
|
1121
|
+
| `list_orders` | List orders (metadata: customer, status, total, items count) |
|
|
1122
|
+
| `get_order` | Get full order: items, payment, shipping, discounts |
|
|
1123
|
+
| `count_orders_by_status` | Order count grouped by status |
|
|
1124
|
+
|
|
1125
|
+
### Promotions & Discounts (5 tools)
|
|
1126
|
+
| Tool | Description |
|
|
1127
|
+
|------|-------------|
|
|
1128
|
+
| `list_promotions` | List all promotions (metadata: name, type, status, schedule). `include_guide=true` for type reference |
|
|
1129
|
+
| `get_promotion` | Get full promotion details: discount rules, coupon settings, items, bonus products |
|
|
1130
|
+
| `get_promotion_items` | Get products/variations/categories attached to a promotion with discount details |
|
|
1131
|
+
| `get_active_promotions` | Get all currently active promotions |
|
|
1132
|
+
| `search_promotions` | Search/filter by type, status (coming_soon/in_progress/finished), keyword |
|
|
1133
|
+
|
|
1134
|
+
### Combo Products (2 tools)
|
|
1135
|
+
| Tool | Description |
|
|
1136
|
+
|------|-------------|
|
|
1137
|
+
| `list_combos` | List all combo/bundle products (name, discount, schedule, type). `include_guide=true` for type reference |
|
|
1138
|
+
| `get_combo_items` | Get combo composition: required items (with quantities) and bonus/gift products |
|
|
1139
|
+
|
|
1140
|
+
### Site Style & Theme (2 tools)
|
|
1141
|
+
| Tool | Description |
|
|
1142
|
+
|------|-------------|
|
|
1143
|
+
| `get_site_info` | Get site name, domain, logo, and all design settings |
|
|
1144
|
+
| `list_themes` | List custom themes: colors, typography, transitions |
|
|
1145
|
+
|
|
1146
|
+
### Applications (2 tools)
|
|
1147
|
+
| Tool | Description |
|
|
1148
|
+
|------|-------------|
|
|
1149
|
+
| `list_apps` | List installed apps with settings and status |
|
|
1150
|
+
| `get_app` | Get specific app by type ID |
|
|
1151
|
+
|
|
1152
|
+
### Custom Knowledge (2 tools)
|
|
1153
|
+
| Tool | Description |
|
|
1154
|
+
|------|-------------|
|
|
1155
|
+
| `list_knowledge` | List all custom knowledge/guide files |
|
|
1156
|
+
| `get_knowledge` | Read a specific knowledge file |
|
|
1157
|
+
|
|
1158
|
+
### Customers (1 tool)
|
|
1159
|
+
| Tool | Description |
|
|
1160
|
+
|------|-------------|
|
|
1161
|
+
| `find_customer` | Find by ID, phone, or email |
|
|
1162
|
+
|
|
1163
|
+
### Automation (1 tool)
|
|
1164
|
+
| Tool | Description |
|
|
1165
|
+
|------|-------------|
|
|
1166
|
+
| `send_mail` | Send email via CMS automation |
|