sbuilder-mcp 0.113.1 → 0.114.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,19 @@ 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.114.0] - 2026-11-25
10
+
11
+ ### Added
12
+ - `sb_form` lists a site's forms, creates a blank or custom form from a field list in one call, merges form settings with notify-address reporting, and reads submissions paged and filtered, with writes defaulting to `dry_run: true`.
13
+
14
+ ### Changed
15
+ - `sb_page_open`'s "no field document yet" error now also points at `sb_form` `action: "create"`.
16
+
17
+ ## [0.113.2] - 2026-11-25
18
+
19
+ ### Fixed
20
+ - `sb_duplicate` reconciles a cross-site paste with the account session instead of an API key, so a key for the target site no longer borrows its creator's standing on the source site.
21
+
9
22
  ## [0.113.1] - 2026-11-24
10
23
 
11
24
  ### Changed
package/CHANGELOG.vi.md CHANGED
@@ -6,6 +6,19 @@ 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.114.0] - 2026-11-25
10
+
11
+ ### Added
12
+ - `sb_form` liệt kê các form của site, tạo form trống hoặc tùy chỉnh từ danh sách trường trong một lần gọi, gộp cài đặt form kèm báo cáo địa chỉ nhận thông báo, và đọc các submission có phân trang và lọc, trong đó các thao tác ghi mặc định `dry_run: true`.
13
+
14
+ ### Changed
15
+ - Lỗi "no field document yet" của `sb_page_open` giờ cũng chỉ tới `sb_form` `action: "create"`.
16
+
17
+ ## [0.113.2] - 2026-11-25
18
+
19
+ ### Fixed
20
+ - `sb_duplicate` đối chiếu thao tác dán giữa các site bằng phiên tài khoản thay vì khóa API, nên khóa của site đích không còn mượn quyền của người tạo nó trên site nguồn.
21
+
9
22
  ## [0.113.1] - 2026-11-24
10
23
 
11
24
  ### Changed
package/README.md CHANGED
@@ -125,6 +125,7 @@ in this client: one would put the very key the platform exists to hold back into
125
125
  | `sb_code` | The site's custom code files (tracking pixels, analytics, chat widgets, site CSS; html/css/js/scss/ts injected, json/text served at `/_wb/code/<name>`) for every page or one — list, create, merge-update, remove; scss/ts compile on write and report `compile_error` |
126
126
  | `sb_function` | The site's backend functions — server-side TypeScript/JavaScript served at `/_wb/fn/<slug>` with the site's sealed secrets, collections and `fetch` (a `_` slug is an importable module) — list, read, create, merge-update, remove, test-run (counts toward the monthly quota), the run log, this month's usage, and write-only secrets; a failed build reports `compile_error` |
127
127
  | `sb_collection` | The site's data tables (collections) — create, rename, delete tables; add, edit, reorder and delete typed fields (text, number, integer, select, tags, reference, gallery…); list, read, add, merge-edit, delete, move and reorder records; CSV export and import; upsert by external id. An edit keeps the row's published flag and sends its `rev` |
128
+ | `sb_form` | The site's forms — list them; create a blank one or one from a field list (text, number, select, radio, checkbox, date, calendar, file, timeslot); merge settings (notify recipients, after-submit redirect, save into a data table), with a new recipient put on the verification ledger and reported as waiting; read responses with filters and paging |
128
129
  | `sb_publish` | Compile the draft into the live page (cascades to shared globals), report which revision went live, and with `verify` check the origin is serving it; lists other pages with unpublished drafts and never-published pages (`publish_drafts` publishes both) |
129
130
  | `sb_page_state` | Which of a page's three copies is which — the DRAFT the editor canvas shows, the PUBLISHED row the storefront serves, and this session's — plus whether the editor will render the canvas BLANK, and where the recovery points are |
130
131
  | `sb_page_repair` | Rename a page root that is not `ROOT` (left by older seeds) so every editor build draws it — one page or the whole site |
@@ -142,7 +143,7 @@ in this client: one would put the very key the platform exists to hold back into
142
143
  | `sb_store` | Run a store flow that must happen in a fixed order — `checkout` (the four writes that make a working one), `checkout_sync` (the store's current payment and delivery methods into every existing order form, checkout page republished), `form` (any of the platform's 17 templates with its own field document), `chrome` (one shared header or footer on a real site menu — site name linked home, desktop menu, mobile drawer, search, cart and account icons), `menu` (a menu node bound to the site's menu, its links resolved), `overlay_attach` (a pop-up or quick view on the open page), `cart` (the site's cart drawer, when it has none; `relocalize` puts an existing one in the site's language) and `app` (a built-in app plus the pages it needs), `global_attach` / `global_detach` (put an EXISTING shared section on the open page, or take it off), `global_promote` (make a section on the page a NEW shared section) and `template_save` (save a section as a reusable template) |
143
144
  | `sb_undo` | Undo / redo this session's writes — page and form edits and `sb_api_call` PUTs, each named by tool and target, the open page's by default (`all: true` for every page); a page is refused if someone else saved it since. The platform's versions and history (`sb_page_version`) outlive this process |
144
145
 
145
- Forty tools, **1013 API operations** (376 of the 467 writes carrying a body shape read
146
+ Forty-three tools, **1013 API operations** (376 of the 467 writes carrying a body shape read
146
147
  off the handler), 125 elements, 99 binding sources. `sb_api_find`
147
148
  is an index rather than a tool per endpoint, so the tool list stays short while everything
148
149
  the platform can do stays reachable — and operations added to the platform arrive with the
package/README.vi.md CHANGED
@@ -121,6 +121,7 @@ nhét ngược lại vào mọi bản cài.
121
121
  | `sb_code` | Các file mã tuỳ chỉnh của site (pixel theo dõi, analytics, widget chat, CSS toàn site; html/css/js/scss/ts được chèn, json/text phục vụ tại `/_wb/code/<name>`) cho mọi trang hoặc một trang — liệt kê, tạo, cập nhật gộp, xoá; scss/ts biên dịch lúc ghi và báo `compile_error` |
122
122
  | `sb_function` | Các backend function của site — TypeScript/JavaScript chạy phía server tại `/_wb/fn/<slug>` với secret đã niêm phong, collection và `fetch` của site (slug bắt đầu bằng `_` là module để import) — liệt kê, đọc, tạo, cập nhật gộp, xoá, chạy thử (tính vào hạn mức tháng), nhật ký chạy, lượng dùng tháng này, và secret chỉ-ghi; build lỗi thì báo `compile_error` |
123
123
  | `sb_collection` | Các bảng dữ liệu (collection) của site — tạo, đổi tên, xoá bảng; thêm, sửa, sắp xếp và xoá trường có kiểu (text, number, integer, select, tags, reference, gallery…); liệt kê, đọc, thêm, sửa gộp, xoá, di chuyển và sắp xếp bản ghi; xuất và nhập CSV; upsert theo external id. Lệnh sửa giữ nguyên trạng thái đăng và gửi kèm `rev` của bản ghi |
124
+ | `sb_form` | Các biểu mẫu của site — liệt kê; tạo biểu mẫu trống hoặc từ danh sách trường (text, number, select, radio, checkbox, date, calendar, file, timeslot); gộp cài đặt (người nhận thông báo, chuyển trang sau khi gửi, lưu vào bảng dữ liệu), người nhận mới được đưa vào danh sách xác minh và báo là đang chờ; đọc lượt gửi có lọc và phân trang |
124
125
  | `sb_publish` | Biên dịch bản nháp thành trang live (lan sang global dùng chung), báo bản nào đã lên live, và với `verify` kiểm origin đã phục vụ đúng bản đó chưa; liệt kê các trang khác còn nháp chưa publish và các trang chưa từng publish (`publish_drafts` publish luôn cả hai) |
125
126
  | `sb_page_state` | Ba bản sao của một trang, bản nào là bản nào — bản NHÁP canvas editor hiển thị, dòng PUBLISHED storefront phục vụ, và bản phiên này giữ — kèm dự báo editor có render canvas TRẮNG không, và các điểm phục hồi nằm ở đâu |
126
127
  | `sb_page_repair` | Đổi gốc trang khác `ROOT` (do seed cũ để lại) về `ROOT` để mọi bản editor vẽ được — một trang hoặc cả site |
@@ -138,7 +139,7 @@ nhét ngược lại vào mọi bản cài.
138
139
  | `sb_store` | Chạy một luồng cửa hàng bắt buộc đúng thứ tự — `checkout` (bốn lệnh ghi tạo nên trang thanh toán), `checkout_sync` (đưa phương thức thanh toán và giao hàng hiện tại vào mọi form đặt hàng đã có, publish lại trang thanh toán), `form` (một trong 17 template của nền tảng kèm field document của nó), `chrome` (một header hoặc footer dùng chung trên menu thật của site — tên site dẫn về trang chủ, menu desktop, drawer mobile, ô tìm kiếm, icon giỏ hàng và tài khoản), `menu` (một node menu bind vào menu của site, link đã phân giải), `overlay_attach` (một pop-up hay quick view trên trang đang mở), `cart` (ngăn giỏ hàng của site, khi chưa có; `relocalize` đưa ngăn giỏ đã có về ngôn ngữ của site), `app` (một app dựng sẵn kèm những trang nó cần), và `global_attach` / `global_detach` (đặt một section dùng chung ĐÃ CÓ lên trang đang mở, hoặc gỡ ra), `global_promote` (biến một section trên trang thành section dùng chung MỚI) và `template_save` (lưu một section làm mẫu dùng lại) |
139
140
  | `sb_undo` | Hoàn tác / làm lại các thao tác ghi trong phiên — chỉnh sửa trang, form và PUT qua `sb_api_call`, mỗi mục ghi tên tool và đối tượng, mặc định của trang đang mở (`all: true` cho mọi trang); trang bị từ chối nếu người khác đã lưu sau đó. Version và history của nền tảng (`sb_page_version`) sống lâu hơn process này |
140
141
 
141
- Bốn mươi tool, **1013 operation API** (376 trong 467 lệnh ghi có hình dạng body đọc thẳng
142
+ Bốn mươi ba tool, **1013 operation API** (376 trong 467 lệnh ghi có hình dạng body đọc thẳng
142
143
  từ handler), 125 element, 99 nguồn binding. `sb_api_find` là
143
144
  một chỉ mục chứ không phải mỗi endpoint một tool, nên danh sách tool vẫn ngắn trong khi mọi
144
145
  thứ nền tảng làm được vẫn với tới — và operation mới thêm bên nền tảng sẽ tự có sau lần
package/dist/server.js CHANGED
@@ -17,6 +17,7 @@ import { registerCodeTools } from './tools/code.js';
17
17
  import { registerComponentTools } from './tools/components.js';
18
18
  import { registerFunctionTools } from './tools/function.js';
19
19
  import { registerCollectionTools } from './tools/collection.js';
20
+ import { registerFormTools } from './tools/form.js';
20
21
  import { registerLiveTools } from './tools/live.js';
21
22
  import { registerStoreTools } from './tools/store.js';
22
23
  import { registerImportTools } from './tools/importpage.js';
@@ -70,6 +71,7 @@ const SESSION_FREE = new Set([
70
71
  'sb_components',
71
72
  'sb_function',
72
73
  'sb_collection',
74
+ 'sb_form',
73
75
  'sb_theme',
74
76
  'sb_catalog_search',
75
77
  'sb_traits_for',
@@ -126,6 +128,7 @@ export function createServer(ctx = buildContext()) {
126
128
  registerComponentTools(server, ctx);
127
129
  registerFunctionTools(server, ctx);
128
130
  registerCollectionTools(server, ctx);
131
+ registerFormTools(server, ctx);
129
132
  registerLiveTools(server, ctx, pageSession);
130
133
  registerStoreTools(server, ctx, pageSession);
131
134
  registerThemeTools(server, ctx);
@@ -0,0 +1,241 @@
1
+ import { z } from 'zod';
2
+ import { text } from '../mcp/response.js';
3
+ import { request, redact, ApiError } from '../transport/http.js';
4
+ import { siteToken } from './credentialpick.js';
5
+ import { siteFor } from './context.js';
6
+ import { createNode } from '../domains/site/node.js';
7
+ import { addSubtree } from '../domains/site/builder.js';
8
+ import { PageDoc } from '../domains/site/document.js';
9
+ import { validateForSave } from '../domains/site/validate.js';
10
+ import { nameFromLabel } from '../domains/site/formdoc.js';
11
+ import { unknownSettingKeys } from './store.js';
12
+ /**
13
+ * A site's FORMS as records (`server/internal/forms/rest`): list them, make one, change its
14
+ * settings, read its responses. The FIELD document is edited with the page tools
15
+ * (`sb_page_open form_id`); a template form with mapped fields is `sb_store action:"form"`.
16
+ *
17
+ * CREATE IS TWO WRITES, and the second can fail after the first landed: POST the record, then
18
+ * PUT its field document. A failed PUT deletes the form again — the store.ts precedent, because a
19
+ * form nobody can open is the orphan the obvious retry duplicates. A "blank" form still gets a
20
+ * document (the form root and its submit button): `sb_page_open form_id` refuses a form whose
21
+ * document was never saved, so a record alone would answer with a hint that does not work.
22
+ *
23
+ * SETTINGS IS A FULL REPLACE of the record (`forms.Form` decoded whole), so it reads, merges the
24
+ * given keys one level deep and sends the rest back untouched. A notify recipient receives mail
25
+ * only after clicking the link the platform mails it, so a new one is put on the site's
26
+ * notify-addresses ledger and reported as WAITING, never as delivered.
27
+ *
28
+ * SUBMISSIONS ARE VISITOR PII. Nothing here logs one or puts one in a notice.
29
+ */
30
+ /** Field types `fields` may name: the value-collecting ones with no order or address wiring. */
31
+ const FIELD_TYPES = ['form-text', 'form-number', 'form-select', 'form-radio', 'form-checkbox', 'form-date', 'form-calendar', 'form-file', 'form-timeslot'];
32
+ const CHOICE = new Set(['form-select', 'form-radio', 'form-checkbox']);
33
+ const PLACEHOLDER = new Set(['form-text', 'form-number', 'form-select', 'form-file']);
34
+ const plain = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
35
+ /** `patch` over `cur`, one level deep — `settings.notify` is a whole object on the wire too. */
36
+ const merge = (cur, patch) => {
37
+ const out = { ...cur };
38
+ for (const [k, v] of Object.entries(patch))
39
+ out[k] = plain(v) && plain(cur[k]) ? { ...cur[k], ...v } : v;
40
+ return out;
41
+ };
42
+ /** The field document, built the way sb_add builds a node: catalog defaults, then the spec. Throws before any request. */
43
+ export function formDocument(fields) {
44
+ const root = createNode('form');
45
+ const doc = PageDoc.from({ root_node_id: root.id, nodes: { [root.id]: root } });
46
+ const names = new Set();
47
+ const out = [];
48
+ for (const f of fields) {
49
+ const type = f.type.startsWith('form-') ? f.type : `form-${f.type}`;
50
+ if (!FIELD_TYPES.includes(type))
51
+ throw new Error(`sbuilder: field type "${f.type}" is not one sb_form makes — use ${FIELD_TYPES.join(', ')}. Others: sb_page_open form_id, then sb_add.`);
52
+ if (f.options && !CHOICE.has(type))
53
+ throw new Error(`sbuilder: options apply to form-select, form-radio and form-checkbox, not ${type}.`);
54
+ if (f.placeholder !== undefined && !PLACEHOLDER.has(type))
55
+ throw new Error(`sbuilder: ${type} has no placeholder.`);
56
+ // The posted name from the label, unique: answers read as {email: …}, not {form-text_x9: …}.
57
+ const stem = nameFromLabel(f.label) || 'field';
58
+ let name = stem;
59
+ for (let i = 2; names.has(name); i++)
60
+ name = `${stem}_${i}`;
61
+ names.add(name);
62
+ const specials = { name, label: f.label };
63
+ if (f.required !== undefined)
64
+ specials.required = f.required;
65
+ if (f.placeholder !== undefined)
66
+ specials.placeholder = f.placeholder;
67
+ if (f.options)
68
+ specials.options = f.options;
69
+ const { patches, ids } = addSubtree(doc, root.id, { type, specials });
70
+ doc.apply(patches);
71
+ out.push({ id: ids[0], type, name });
72
+ }
73
+ doc.apply(addSubtree(doc, root.id, { type: 'form-submit' }).patches);
74
+ const problems = validateForSave(doc);
75
+ if (problems.length)
76
+ throw new Error(`sbuilder: ${problems.join(' ')}`);
77
+ return { document: doc.doc, fields: out };
78
+ }
79
+ /** The refusal an agent acts on: a key without the forms permission is not an empty list. */
80
+ function explained(p, perm) {
81
+ return p.catch((e) => {
82
+ if (e instanceof ApiError && e.status === 403) {
83
+ e.message = `${e.message} — this credential lacks ${perm}; an API key needs the ${perm} permission (or use the account session).`;
84
+ }
85
+ throw e;
86
+ });
87
+ }
88
+ const submissionOut = ({ id, status, createdAt, readAt, values, files }) => ({
89
+ id,
90
+ at: createdAt,
91
+ status,
92
+ ...(readAt ? {} : { unread: true }),
93
+ values: Object.fromEntries((values ?? []).map((v) => [v.fieldName, v.text ?? v.number ?? v.bool ?? v.json ?? ''])),
94
+ ...(files?.length ? { files: files.length } : {}),
95
+ });
96
+ /**
97
+ * RFC 3339, which is all the platform parses — anything else is dropped there without a word.
98
+ * A date-only `to` means the END of that day: the platform filters `created_at < to`, so it is
99
+ * sent as the next day's start. A date-only `from` stays the start of its day.
100
+ */
101
+ function when(v, key) {
102
+ if (v === undefined)
103
+ return undefined;
104
+ const d = new Date(v);
105
+ if (Number.isNaN(d.getTime()))
106
+ throw new Error(`sbuilder: ${key} "${v}" is not a date — use 2026-11-01 or an RFC 3339 time.`);
107
+ if (key === 'to' && /^\d{4}-\d{2}-\d{2}$/.test(v.trim()))
108
+ d.setUTCDate(d.getUTCDate() + 1);
109
+ return d.toISOString();
110
+ }
111
+ export function registerFormTools(server, ctx) {
112
+ server.registerTool('sb_form', {
113
+ description: 'Forms: list; create (blank, or fields → custom form); settings (merged one level over the stored ones: notify, afterSubmit, collectionId…); ' +
114
+ 'submissions (paged responses). Fields of an existing form: sb_page_open form_id.',
115
+ inputSchema: {
116
+ action: z.enum(['list', 'create', 'settings', 'submissions']),
117
+ site_id: z.string().optional(),
118
+ form_id: z.string().optional(),
119
+ name: z.string().optional(),
120
+ fields: z
121
+ .array(z.object({ type: z.string(), label: z.string(), required: z.boolean().optional(), placeholder: z.string().optional(), options: z.array(z.string()).optional() }).strict())
122
+ .optional(),
123
+ settings: z.record(z.string(), z.unknown()).optional(),
124
+ limit: z.number().int().optional(),
125
+ offset: z.number().int().optional(),
126
+ status: z.string().optional(),
127
+ q: z.string().optional(),
128
+ from: z.string().optional(),
129
+ to: z.string().optional(),
130
+ field: z.string().optional(),
131
+ value: z.string().optional(),
132
+ unread: z.boolean().optional(),
133
+ dry_run: z.boolean().optional(),
134
+ },
135
+ // ONE tool, so one annotation set: create and settings write. Neither destroys —
136
+ // the only DELETE is create's rollback of the form it just made.
137
+ annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
138
+ }, async (a) => {
139
+ const site = encodeURIComponent(siteFor(ctx, a.site_id));
140
+ const base = `/api/sites/${site}/forms`;
141
+ const call = (method, path, body, query) => explained(request({ base: ctx.base, method, path, token: siteToken(ctx), body, query, fetchImpl: ctx.fetchImpl }), method === 'GET' ? 'forms.read' : 'forms.write');
142
+ const dry = a.dry_run !== false;
143
+ const formPath = () => {
144
+ if (!a.form_id)
145
+ throw new Error(`sbuilder: action:"${a.action}" needs form_id — action:"list" names them.`);
146
+ return `${base}/${encodeURIComponent(a.form_id)}`;
147
+ };
148
+ switch (a.action) {
149
+ case 'list': {
150
+ const got = await call('GET', base);
151
+ return text({
152
+ forms: (got.forms ?? []).map(({ id, name, type, submissionCount, unreadCount }) => ({
153
+ id, name, type, ...(submissionCount ? { submissions: submissionCount } : {}), ...(unreadCount ? { unread: unreadCount } : {}),
154
+ })),
155
+ });
156
+ }
157
+ case 'create': {
158
+ const { document, fields } = formDocument(a.fields ?? []);
159
+ const body = { name: a.name ?? 'Form' };
160
+ if (dry) {
161
+ return text({
162
+ dry_run: true,
163
+ would_send: redact([{ method: 'POST', path: base, body }, { method: 'PUT', path: `${base}/{formId}/document`, fields: fields.map(({ type, name }) => ({ type, name })) }]),
164
+ });
165
+ }
166
+ const form = (await call('POST', base, body)).form;
167
+ if (!form?.id)
168
+ throw new Error('sbuilder: the platform accepted the form create and returned no form');
169
+ const at = `${base}/${encodeURIComponent(form.id)}`;
170
+ try {
171
+ await call('PUT', `${at}/document`, { document });
172
+ }
173
+ catch (e) {
174
+ // A form nobody can open is the orphan a retry duplicates — and one we failed to delete is said, not hidden.
175
+ const undone = await call('DELETE', at).then(() => true, () => false);
176
+ if (!undone && e instanceof Error)
177
+ e.message += ` — rollback delete of ${form.id} also failed — delete it by hand`;
178
+ throw e;
179
+ }
180
+ return text({
181
+ created: { id: form.id, name: form.name },
182
+ fields,
183
+ next: `sb_page_open form_id:"${form.id}" edits its fields; place it with sb_add {type:"form", specials:{formId:"${form.id}"}}.`,
184
+ });
185
+ }
186
+ case 'settings': {
187
+ const path = formPath();
188
+ if (!a.settings || !Object.keys(a.settings).length)
189
+ throw new Error('sbuilder: action:"settings" needs settings — the keys to change, e.g. {notify:{enabled:true, recipients:["a@x.vn"]}}.');
190
+ const unknown = unknownSettingKeys(a.settings);
191
+ const warn = unknown.length ? { settings_unknown: { keys: unknown, note: 'Not in the platform\'s form Settings — the decoder drops them, so they are stored as nothing.' } } : {};
192
+ const recipients = a.settings.notify?.recipients;
193
+ const wanted = Array.isArray(recipients) ? recipients.filter((r) => typeof r === 'string').map((r) => r.trim().toLowerCase()).filter(Boolean) : [];
194
+ const ledger = wanted.length
195
+ ? ((await call('GET', `${base}/notify-addresses`)).addresses ?? [])
196
+ : [];
197
+ const known = new Map(ledger.map((l) => [l.email.toLowerCase(), !!l.verifiedAt]));
198
+ const toArm = wanted.filter((e) => !known.has(e));
199
+ const waiting = wanted.filter((e) => known.get(e) !== true);
200
+ // The PREVIEW carries only what the caller gave: the stored settings are read data.
201
+ if (dry) {
202
+ return text({
203
+ dry_run: true,
204
+ would_send: redact([
205
+ { method: 'PUT', path, body: { settings: a.settings }, note: 'merged one level over the stored settings; every other key is sent back unchanged' },
206
+ ...toArm.map((email) => ({ method: 'POST', path: `${base}/notify-addresses`, body: { email } })),
207
+ ]),
208
+ ...warn,
209
+ });
210
+ }
211
+ const cur = (await call('GET', path)).form;
212
+ const settings = merge(cur.settings ?? {}, a.settings);
213
+ // Settings first: each ledger POST mails a verification link, which a failed PUT would leave pointing at nothing.
214
+ const updated = (await call('PUT', path, { name: cur.name, type: cur.type, settings })).form;
215
+ for (const email of toArm)
216
+ await call('POST', `${base}/notify-addresses`, { email });
217
+ const off = a.settings.notify !== undefined && settings.notify?.enabled !== true;
218
+ return text({
219
+ updated: { id: updated?.id ?? cur.id, changed: Object.keys(a.settings) },
220
+ ...(waiting.length ? { waiting_verification: waiting, note: 'These receive no mail until they click the link the platform mailed them.' } : {}),
221
+ ...(off ? { notify_disabled: 'notify.enabled is false — no mail is sent until notify is enabled.' } : {}),
222
+ ...warn,
223
+ });
224
+ }
225
+ case 'submissions': {
226
+ const path = `${formPath()}/submissions`;
227
+ if ((a.field === undefined) !== (a.value === undefined))
228
+ throw new Error('sbuilder: field and value filter together — field is the posted name, value its answer.');
229
+ const offset = a.offset ?? 0;
230
+ const got = await call('GET', path, undefined, {
231
+ limit: a.limit ?? 20, offset, status: a.status, q: a.q, from: when(a.from, 'from'), to: when(a.to, 'to'),
232
+ field: a.field, value: a.value, unread: a.unread || undefined,
233
+ });
234
+ const rows = got.submissions ?? [];
235
+ const total = got.total ?? rows.length;
236
+ const next = offset + rows.length;
237
+ return text({ submissions: rows.map(submissionOut), total, ...(next < total && rows.length ? { next_offset: next } : {}) });
238
+ }
239
+ }
240
+ });
241
+ }
@@ -862,7 +862,7 @@ export class PageSession {
862
862
  fetchImpl: this.ctx.fetchImpl,
863
863
  }));
864
864
  if (!got?.document) {
865
- throw new Error(`sbuilder: form ${formId} has no field document yet — create forms with sb_store action:"form".`);
865
+ throw new Error(`sbuilder: form ${formId} has no field document yet — create one with sb_form action:"create" (a blank or custom form, with its document) or sb_store action:"form" (a template form).`);
866
866
  }
867
867
  // The RECORD's type decides which document rules apply (a booking form reads
868
868
  // its first two dates as the stay). Best-effort: a failed read only silences
@@ -2310,7 +2310,12 @@ export function registerPageTools(server, ctx) {
2310
2310
  base: ctx.base,
2311
2311
  method: 'POST',
2312
2312
  path: `/api/sites/${encodeURIComponent(toSite)}/clipboard/reconcile`,
2313
- token: siteToken(ctx),
2313
+ // THE ACCOUNT SESSION, never the key, even on the key's own site: the reconcile
2314
+ // reads the SOURCE site's assets, which only a person's membership vouches for.
2315
+ // The platform refuses a delegated (API-key) caller here (web_builder
2316
+ // sitecopy/rest, 2026-11-25); a key on the target used to pass because it
2317
+ // borrowed its creator's standing on every other site.
2318
+ token: ctx.session.loggedIn() ? ctx.session.token() : siteToken(ctx),
2314
2319
  body: { sourceSiteId: from.siteId, tree },
2315
2320
  fetchImpl: ctx.fetchImpl,
2316
2321
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sbuilder-mcp",
3
- "version": "0.113.1",
3
+ "version": "0.114.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",