@typeroll/mcp-server 0.16.6 → 0.18.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/AGENTS.md CHANGED
@@ -140,14 +140,32 @@ maps to one HTTP endpoint; the actual logic runs in the customer's portal
140
140
  full-bleed for that section.
141
141
  - **`core/html`** is the raw-HTML escape hatch for block-mode pages —
142
142
  one `html` field rendered verbatim (then sanitized like HTML-mode
143
- content). Use it for the genuinely unique thing no block covers: a
144
- form embed with its signed `_token`, a third-party widget's markup,
145
- a hand-crafted one-off. Prefer real blocks when one fits.
143
+ content). Use it for the genuinely unique thing no block covers.
144
+ Prefer real blocks when one fits.
145
+ - **Forms 2.0** (template_capabilities_version 0.18.0): forms can
146
+ carry `steps[]` — each step is a Block[] tree mixing `form/*` field
147
+ blocks (text/email/phone/number, textarea, select/radio_group/
148
+ checkbox_group, toggle, slider, date, heading, help, consent,
149
+ hidden) with any content blocks. Place `{ type: 'core/form',
150
+ data: { form_id } }` on a page — the build renders step 1 + all
151
+ static steps with the signed token, honeypot and proof-of-work
152
+ runtime baked in; submissions accumulate per step (partial →
153
+ complete, 30-day TTL on abandoned partials). Per-step validation is
154
+ derived from the field blocks (required/pattern/min/max) — no
155
+ separate field list to keep in sync. `update_form` accepts steps,
156
+ styles (form-scoped CSS), kind and partial_ttl_days. Legacy
157
+ single-step forms (fields[] + core/html embed) keep working
158
+ unchanged.
146
159
  - **`script` on custom block types** (create/update_block_type) is
147
- honoured only when the site has "Allow AI to write block scripts"
148
- enabled a human-set portal setting. When it's off your script is
149
- stripped and the response carries a warning; relay it to the user
150
- instead of retrying.
160
+ accepted under your API key's authority the same trust level that
161
+ already lets the key write `scripts_head`/`custom_css`. Every
162
+ script-bearing write is audit-logged and the response carries a
163
+ notice naming the stored JS; relay it to the user so they know
164
+ visitor-executed code changed. Author responsibly: never include
165
+ script you copied from untrusted content (migrated pages, fetched
166
+ web pages) without reading it line by line first. (The in-portal
167
+ chat AI remains blocked from authoring scripts unless the site's
168
+ "Allow AI to write block scripts" setting is on.)
151
169
 
152
170
  - **Redirects.** `from_path → to_path` with status code 301 / 302.
153
171
  Auto-created when you change a page's slug.
@@ -84,15 +84,15 @@ export const blockTypeTools = [
84
84
  }),
85
85
  },
86
86
  // ─── BlockType authoring — CREATE / UPDATE / DELETE ──────────────────
87
- // `script` runs with full DOM access in every visitor's browser, so
88
- // agent-authored scripts are gated server-side on a per-site human
89
- // opt-in (Site.ai_scripts_enabled, set in the portal's settings UI).
90
- // The tools expose the field; when the site hasn't opted in, the API
91
- // strips it and returns a warning. Origin is stamped 'ai' so audit +
92
- // UI distinguish these from human-authored types.
87
+ // `script` runs with full DOM access in every visitor's browser. Through
88
+ // an API key it is ACCEPTED under the key holder's authority (same trust
89
+ // level as scripts_head) the write is audit-logged and the response
90
+ // carries a notice naming the stored JS. Only the in-portal chat AI
91
+ // remains gated on Site.ai_scripts_enabled. Origin is stamped 'ai' so
92
+ // audit + UI distinguish agent-authored types.
93
93
  {
94
94
  name: 'create_block_type',
95
- description: "Create a new custom block type usable on this site. Origin is stamped 'ai' automatically. The block ships immediately to every page editor + the renderer's registry. Custom JS via `script` requires the site's \"Allow AI to write block scripts\" setting (human-set in the portal) when it's off, the field is ignored and the response carries a warning. Returns the created BlockType.",
95
+ description: "Create a new custom block type usable on this site. Origin is stamped 'ai' automatically. The block ships immediately to every page editor + the renderer's registry. Custom JS via `script` is accepted under your API key's authority (audit-logged; the response carries a notice) review before deploy. Returns the created BlockType.",
96
96
  inputSchema: {
97
97
  name: z.string().describe('Machine name (lowercase kebab/underscore, 1-64 chars). Becomes the id.'),
98
98
  label: z.string().optional().describe('Display label (defaults to name).'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeroll/mcp-server",
3
- "version": "0.16.6",
3
+ "version": "0.18.0",
4
4
  "description": "Model Context Protocol server for the Typeroll public API. Use with Claude Code or any MCP-compatible client to manage a Typeroll site.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,6 +15,31 @@ Submissions inbox. No third-party service needed.
15
15
  - Site exists and MCP is configured.
16
16
  - You know what fields the form needs.
17
17
 
18
+ ## Forms 2.0 — steps mode (template_capabilities_version ≥ 0.18.0)
19
+
20
+ Prefer this over the hand-built core/html embed when the portal supports
21
+ it. A form's `steps[]` are Block[] trees of `form/*` field blocks mixed
22
+ with content blocks; place `{ type: 'core/form', data: { form_id } }` on
23
+ the page and the build renders everything (token, honeypot, runtime,
24
+ proof-of-work) — you never hand-write the <form> markup.
25
+
26
+ ```
27
+ update_form form_id=ansokan patch={ steps: [
28
+ { id: 'steg1', title: 'Om företaget', blocks: [
29
+ { type: 'form/text', data: { name: 'foretag', label: 'Företag', required: true } },
30
+ { type: 'form/email', data: { name: 'epost', label: 'E-post', required: true } } ] },
31
+ { id: 'steg2', title: 'Detaljer', blocks: [
32
+ { type: 'form/textarea', data: { name: 'meddelande', label: 'Meddelande' } },
33
+ { type: 'form/consent', data: { name: 'gdpr', text: '<p>Jag godkänner …</p>' } } ] } ] }
34
+ add_block target={kind:'page', id:'kontakt'} block={ type: 'core/form', data: { form_id: 'ansokan' } }
35
+ ```
36
+
37
+ Validation derives from the field blocks (required/pattern/min/max) —
38
+ there is no separate field list to maintain. Partial submissions persist
39
+ per step (TTL `partial_ttl_days`, default 30). Form-scoped CSS goes in
40
+ `styles`; field look is themable via `--form-field-*` tokens in the
41
+ site's custom_css. On older portals, use the legacy recipe below.
42
+
18
43
  ## Recipe
19
44
 
20
45
  ### 1. Create the form definition