sbuilder-mcp 0.111.4 → 0.112.0

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/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ All notable changes to this project are documented in this file.
6
6
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
7
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.112.0] - 2026-11-20
10
+
11
+ ### Added
12
+ - `sb_store` adds `action: "tracking"`, which with no arguments lists every tracker (GA4, GTM, Meta/TikTok Pixel, ChatGPT Ads) with its ID, enabled state and problems, plus where visitors came from over the last 30 days.
13
+ - `sb_store` `action: "tracking"` accepts a pasted `text` snippet, recognises the provider, cleans the ID, and updates the existing tracker or creates a new one, defaulting to `dry_run`.
14
+ - `sb_store` `action: "tracking"` accepts `provider` and `enabled` to switch a single tracker on or off, and one provider's failure does not block the others.
15
+
16
+ ## [0.111.5] - 2026-11-20
17
+
18
+ ### Changed
19
+ - The element catalog is regenerated against web_builder v1.0.302, and the collection list guidance now says `collectionListType` `page_collections` lists a leaf collection's siblings (the parent's children).
20
+
9
21
  ## [0.111.4] - 2026-11-20
10
22
 
11
23
  ### Added
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,18 @@ Mọi thay đổi đáng chú ý của dự án được ghi lại trong file n
6
6
  Định dạng dựa trên [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7
7
  và dự án tuân theo [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [0.112.0] - 2026-11-20
10
+
11
+ ### Added
12
+ - `sb_store` có thêm `action: "tracking"`, khi không truyền tham số sẽ liệt kê mọi tracker (GA4, GTM, Meta/TikTok Pixel, ChatGPT Ads) cùng ID, trạng thái bật/tắt và vấn đề, kèm khách đến từ đâu trong 30 ngày qua.
13
+ - `sb_store` `action: "tracking"` nhận đoạn mã dán vào qua `text`, nhận diện nhà cung cấp, làm sạch ID, rồi cập nhật tracker đã có hoặc tạo mới, mặc định chạy `dry_run`.
14
+ - `sb_store` `action: "tracking"` nhận `provider` và `enabled` để bật/tắt một tracker, và lỗi của một nhà cung cấp không chặn các nhà cung cấp khác.
15
+
16
+ ## [0.111.5] - 2026-11-20
17
+
18
+ ### Changed
19
+ - Danh mục phần tử được tạo lại theo web_builder v1.0.302, và hướng dẫn về danh sách bộ sưu tập giờ nêu rõ `collectionListType` `page_collections` liệt kê các bộ sưu tập cùng cấp (con của bộ sưu tập cha) khi trang là một bộ sưu tập lá.
20
+
9
21
  ## [0.111.4] - 2026-11-20
10
22
 
11
23
  ### Added
@@ -1,6 +1,6 @@
1
1
  export const DEAD_KEY_SOURCE = {
2
- "files": 7056,
3
- "identifiers": 120692,
2
+ "files": 6536,
3
+ "identifiers": 119403,
4
4
  "seededKeys": 486,
5
5
  "dead": 0
6
6
  };
@@ -35802,7 +35802,7 @@ export const ELEMENTS = {
35802
35802
  "Product lists: config.collectionType \"page_collection\" renders THE COLLECTION THE PAGE IS (the one /collections/{slug} named) so a single collection template serves every collection, \"all_products\" renders the whole catalog and narrows to the page collection on a collection template, \"collection\" renders the one named by config.collectionId, \"related\" renders the PAGE PRODUCT's neighbours — the products sharing one of its collections, minus itself",
35803
35803
  "Article lists: config.articleSourceType \"page_category\" renders THE BLOG CATEGORY THE PAGE IS (the one /blog-categories/{slug} named) so a single blog template serves every category — off a blog template it shows every article; \"category\" filters by config.articleCategoryId (the \"all_articles\" sentinel means no filter, and on a blog template it narrows to the page category anyway); \"slot\" renders a curated shelf, the rows filed by hand under config.relationSlotKey",
35804
35804
  "Use \"related\" for a cross-sell shelf on a product page (\"Sản phẩm liên quan\" / \"You may also like\"). It reads no collectionId — its axis is whatever collections the page product is filed under — and it renders nothing on a page that names no product, so pair it with an emptyStateId if the section must never be blank",
35805
- "Collection lists: config.collectionListType \"page_collections\" renders THE SUB-COLLECTIONS OF THE COLLECTION THE PAGE IS (the one /collections/{slug} named), so a single collection template draws every collection's browse grid — off a collection template it shows every collection instead; \"all_collections\" renders every collection; \"custom_collections\" renders specials.collectionIds, in that order",
35805
+ "Collection lists: config.collectionListType \"page_collections\" renders THE SUB-COLLECTIONS OF THE COLLECTION THE PAGE IS (the one /collections/{slug} named), so a single collection template draws every collection's browse grid; on a LEAF collection it lists its siblings (the parent's children) — off a collection template it shows every collection instead; \"all_collections\" renders every collection; \"custom_collections\" renders specials.collectionIds, in that order",
35806
35806
  "config.quantity caps how many records render and, under a loadingMode, is the PAGE SIZE; it is BASE-only — one value for every breakpoint, never per-breakpoint. A Data list (datasetSource \"record\") pages at most 50 records per page. config.itemsPerRow is the row size (grid columns / slide page size) and style.gap is the space between cards — both are per-breakpoint",
35807
35807
  "A Data list (datasetSource \"record\") nested inside another Data list's row can show ONLY the child records pointing at that row: set config.recordRelationField to the field id (fld_<16hex>) of a \"reference\" field in the nested list's own collection (e.g. RoomType.hotel inside a Hotels list). BASE-only. Such a list is never paged (loadingMode is ignored), its card may also bind the enclosing row's fields, and outside a record-list row it shows its empty state, never all records",
35808
35808
  "A Data list can carry config.recordAggregates (BASE-only, ≤4): [{key, recordCollectionId (child collection), recordRelationField (child reference field → this collection), op \"min\"|\"max\"|\"count\", recordField (child number/integer field, \"\" for count), where: [{recordField, op:\"gte\", param, per?}], whenNone \"hide\"|\"show\"}]. Each row then binds record.agg.<key> / record.money.agg.<key> (e.g. a hotel's cheapest room that fits: min nightly price where capacity × rooms ≥ guests). Visitors send params as f.record.param.<name>=<int>, filter as f.record.agg.<key>=..3000000, sort as s.<node>=agg.<key>_asc. Not availability",
@@ -1,7 +1,7 @@
1
1
  // GENERATED by scripts/gen-catalog.ts — do not edit by hand.
2
2
  // The platform commit every other generated file here describes.
3
3
  export const PLATFORM_SOURCE = {
4
- "commit": "10464dae01c11e0d73072411648d81f1d0beb497",
5
- "committedAt": "2026-11-20T20:44:14+07:00",
4
+ "commit": "ae8d9595a401c8b0eb3d774bea3a459d43871342",
5
+ "committedAt": "2026-11-20T23:23:01+07:00",
6
6
  "dirty": false
7
7
  };
@@ -48,6 +48,7 @@ import { attachGlobal, buildChrome, detachGlobal, markSiteTemplate, promoteGloba
48
48
  import { bindMenu } from './menu.js';
49
49
  import { attachOverlay, ensureCartDrawer, relocalizeCartDrawer } from './overlay.js';
50
50
  import { installApp } from './app.js';
51
+ import { trackingFlow } from './tracking.js';
51
52
  import { BUILTIN_APP_KEYS } from '../catalog/appscaffolds.generated.js';
52
53
  import { ELEMENTS } from '../catalog/elements.generated.js';
53
54
  import { PAGE_TYPES } from '../catalog/storepages.generated.js';
@@ -570,7 +571,8 @@ export function registerStoreTools(server, ctx, session) {
570
571
  'leaves the page referencing it; action:"template_save" saves one as a section template ' +
571
572
  '(name; template_share sends one to the org\'s review). site_template offers the whole site as its org\'s ' +
572
573
  'template (org_id attaches first; site_template_remove withdraws). ' +
573
- 'Dry run returns the plan.',
574
+ 'action:"tracking": trackers + traffic sources; text installs a pasted snippet; provider+enabled ' +
575
+ 'switches one. Dry run returns the plan.',
574
576
  inputSchema: {
575
577
  action: z.enum([
576
578
  'checkout',
@@ -588,6 +590,7 @@ export function registerStoreTools(server, ctx, session) {
588
590
  'site_template',
589
591
  'site_template_remove',
590
592
  'template_share',
593
+ 'tracking',
591
594
  ]),
592
595
  site_id: z.string().optional(),
593
596
  language: z.enum(['vi', 'en']).optional().describe('Copy language, default vi'),
@@ -653,11 +656,20 @@ export function registerStoreTools(server, ctx, session) {
653
656
  .describe('action:"cart" — rewrite an EXISTING drawer\'s seed words that are in another language ' +
654
657
  'to the site locale\'s (edited text untouched), and turn a gallery line thumbnail into a ' +
655
658
  'single image; needs a page of the site open'),
659
+ text: z.string().optional(),
660
+ provider: z
661
+ .enum(['google_analytics', 'google_tag_manager', 'facebook_pixel', 'tiktok_pixel', 'openai_pixel'])
662
+ .optional(),
663
+ enabled: z.boolean().optional(),
656
664
  dry_run: z.boolean().optional(),
657
665
  },
658
666
  annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
659
- }, async ({ action, site_id: given, language, page_name, headline, template, name, footer, node_id, menu_id, kind, overlay_id, list_id, app_key, global_id, global_kind, template_id, description, categories, org_id, relocalize, settings, dry_run, }) => {
667
+ }, async ({ action, site_id: given, language, page_name, headline, template, name, footer, node_id, menu_id, kind, overlay_id, list_id, app_key, global_id, global_kind, template_id, description, categories, org_id, relocalize, settings, text: trackingText, provider, enabled, dry_run, }) => {
660
668
  const siteId = siteFor(ctx, given);
669
+ if (action === 'tracking') {
670
+ const dryRun = dry_run !== false;
671
+ return text(await trackingFlow(ctx, siteId, { text: trackingText, provider, enabled, dryRun }));
672
+ }
661
673
  if (action === 'global_attach' || action === 'global_detach') {
662
674
  // THE COMPOSED STAMP IS NEVER THE CALLER'S TO WRITE. A page references
663
675
  // a master with `specials.globalRef`; the server composes it in on read
@@ -0,0 +1,162 @@
1
+ /**
2
+ * `sb_store action:"tracking"` — A STORE'S MEASUREMENT, IN ONE CALL.
3
+ *
4
+ * Without it an agent had to find four routes (integrations list, detect,
5
+ * POST/PUT, channels) and know that a pasted snippet must be reduced to an id,
6
+ * that one row exists per provider, and that a stored row may carry a `problem`.
7
+ * web_builder answers all of that server-side; this only sequences it:
8
+ *
9
+ * - no `text`, no `provider` → STATUS: every tracker (connected or not, its id,
10
+ * on/off, and `problem` when a stored id installs no tag) plus where visitors
11
+ * came from over the last 30 days (GET /forms/submissions/channels). Read-only.
12
+ * - `text` → INSTALL whatever the text sets up: the server's detect names each
13
+ * provider and cleans its id; an existing row is UPDATED (its other config
14
+ * kept, switched on), a new one CREATED. Dry run by default: the plan.
15
+ * - `provider` + `enabled` → switch one tracker on or off.
16
+ *
17
+ * A failure on one provider does not stop the others; each reports its own
18
+ * result, and the server's own sentence (e.g. invalid_tracking_id naming the
19
+ * expected shape) is passed through untouched.
20
+ */
21
+ import { request } from '../transport/http.js';
22
+ import { siteToken } from './credentialpick.js';
23
+ /** web_builder's providers and the one config field each reads (integrations/providers.go). */
24
+ export const TRACKING_FIELDS = {
25
+ google_analytics: 'measurementId',
26
+ google_tag_manager: 'containerId',
27
+ facebook_pixel: 'pixelId',
28
+ tiktok_pixel: 'pixelId',
29
+ openai_pixel: 'pixelId',
30
+ };
31
+ export async function trackingFlow(ctx, siteId, args) {
32
+ const site = encodeURIComponent(siteId);
33
+ const base = `/api/sites/${site}/integrations`;
34
+ const send = async (method, path, body) => (await request({
35
+ base: ctx.base,
36
+ method,
37
+ path,
38
+ token: siteToken(ctx),
39
+ body,
40
+ fetchImpl: ctx.fetchImpl,
41
+ }));
42
+ const current = async () => (await send('GET', base)).integrations ?? [];
43
+ const idOf = (i) => i.config?.[TRACKING_FIELDS[i.provider] ?? ''] ?? '';
44
+ if (args.provider !== undefined || args.enabled !== undefined) {
45
+ if (!args.provider || args.enabled === undefined) {
46
+ throw new Error('sbuilder: action:"tracking" switches a tracker with BOTH provider and enabled.');
47
+ }
48
+ if (!(args.provider in TRACKING_FIELDS)) {
49
+ throw new Error(`sbuilder: provider must be one of ${Object.keys(TRACKING_FIELDS).join(', ')}.`);
50
+ }
51
+ const row = (await current()).find((i) => i.provider === args.provider);
52
+ if (!row?.id) {
53
+ throw new Error(`sbuilder: ${args.provider} is not connected — pass its snippet or id as text to install it.`);
54
+ }
55
+ const body = {
56
+ provider: row.provider,
57
+ enabled: args.enabled,
58
+ config: row.config,
59
+ };
60
+ if (args.dryRun) {
61
+ return {
62
+ dryRun: true,
63
+ plan: [
64
+ {
65
+ method: 'PUT',
66
+ path: `${base}/${encodeURIComponent(row.id)}`,
67
+ body,
68
+ },
69
+ ],
70
+ };
71
+ }
72
+ const saved = await send('PUT', `${base}/${encodeURIComponent(row.id)}`, body);
73
+ return {
74
+ provider: row.provider,
75
+ id: idOf(saved.integration),
76
+ enabled: saved.integration.enabled,
77
+ };
78
+ }
79
+ if (args.text !== undefined) {
80
+ if (!args.text.trim())
81
+ throw new Error('sbuilder: text is empty — paste the vendor snippet or the id.');
82
+ const found = (await send('POST', `${base}/detect`, {
83
+ text: args.text,
84
+ })).integrations ?? [];
85
+ if (!found.length) {
86
+ return {
87
+ recognised: [],
88
+ note: 'No tracker recognised. A bare TikTok or ChatGPT Ads id says nothing about whose it is: ' +
89
+ "paste the vendor's whole snippet, or POST /integrations with the provider named.",
90
+ };
91
+ }
92
+ const rows = await current();
93
+ const plan = found.map((d) => {
94
+ const existing = rows.find((r) => r.provider === d.provider);
95
+ const body = {
96
+ provider: d.provider,
97
+ enabled: true,
98
+ config: { ...existing?.config, ...d.config },
99
+ };
100
+ return existing?.id
101
+ ? {
102
+ provider: d.provider,
103
+ id: idOf(d),
104
+ replaces: idOf(existing),
105
+ method: 'PUT',
106
+ path: `${base}/${encodeURIComponent(existing.id)}`,
107
+ body,
108
+ }
109
+ : {
110
+ provider: d.provider,
111
+ id: idOf(d),
112
+ method: 'POST',
113
+ path: base,
114
+ body,
115
+ };
116
+ });
117
+ if (args.dryRun)
118
+ return { dry_run: true, plan };
119
+ const results = [];
120
+ for (const p of plan) {
121
+ try {
122
+ await send(p.method, p.path, p.body);
123
+ results.push({ provider: p.provider, id: p.id, ok: true });
124
+ }
125
+ catch (e) {
126
+ results.push({
127
+ provider: p.provider,
128
+ id: p.id,
129
+ ok: false,
130
+ error: e.message,
131
+ });
132
+ }
133
+ }
134
+ return {
135
+ results,
136
+ note: 'Tags are served at request time: live on the storefront now, no republish.',
137
+ };
138
+ }
139
+ const rows = await current();
140
+ let channels = null;
141
+ try {
142
+ channels =
143
+ (await send('GET', `/api/sites/${site}/forms/submissions/channels`)).channels ?? [];
144
+ }
145
+ catch (e) {
146
+ channels = { unavailable: e.message };
147
+ }
148
+ return {
149
+ trackers: Object.keys(TRACKING_FIELDS).map((provider) => {
150
+ const r = rows.find((x) => x.provider === provider);
151
+ if (!r)
152
+ return { provider, connected: false };
153
+ return {
154
+ provider,
155
+ id: idOf(r),
156
+ enabled: r.enabled,
157
+ ...(r.problem ? { problem: r.problem } : {}),
158
+ };
159
+ }),
160
+ channelsLast30Days: channels,
161
+ };
162
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.111.4",
3
+ "version": "0.112.0",
4
4
  "description": "MCP server that designs and operates a Store Builder site — pages, data, theme and publish — through the platform's own API and live-edit protocol.",
5
5
  "mcpName": "io.github.vuluu2k/sbuilder-mcp",
6
6
  "type": "module",