@typeroll/mcp-server 0.45.44 → 0.45.46

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.
@@ -66,4 +66,135 @@ export const extensionTools = [
66
66
  }
67
67
  }),
68
68
  },
69
+ {
70
+ name: 'install_extension',
71
+ description: 'Install an Extension release on this site, as the portal\'s install action does. Pass the Extension id and a published release (developer organizations may also install their own draft or review releases on their own sites). granted_scopes must be a subset of the manifest\'s requested permissions — grant only what the user approved. config must satisfy manifest.config_schema; secret values are encrypted and never returned. Does not deploy: trigger_deploy afterwards to publish provisioned components. Admin permission required.',
72
+ inputSchema: {
73
+ extension_id: z.string().min(1),
74
+ version: z.string().min(1).describe('Release version to install.'),
75
+ granted_scopes: z.array(z.string()).optional().describe('Approved scopes; defaults to none.'),
76
+ config: z.record(z.unknown()).optional(),
77
+ developer_org_id: z.string().optional().describe('Organization that publishes the Extension. Defaults to the key\'s own organization.'),
78
+ },
79
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
80
+ return ok(await client.post(siteId, 'extensions', args));
81
+ }),
82
+ },
83
+ {
84
+ name: 'set_extension_installation_status',
85
+ description: 'Enable or disable an installed Extension on this site. Disabling removes its components from the public snapshot and editor until re-enabled; page instances are kept. Changes apply immediately to previews; deploy to publish. Admin permission required.',
86
+ inputSchema: {
87
+ installation_id: z.string().min(1),
88
+ status: z.enum(['enabled', 'disabled']),
89
+ },
90
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
91
+ return ok(await client.patch(siteId, `extensions/${encodeURIComponent(args.installation_id)}`, { status: args.status }));
92
+ }),
93
+ },
94
+ {
95
+ name: 'uninstall_extension',
96
+ description: 'Uninstall an Extension from this site: revokes the installation and all its server credentials and removes its block definitions. Existing page blocks remain as unavailable placeholders. Not reversible except by installing again (a new installation id). Get explicit user approval. Admin permission required.',
97
+ inputSchema: { installation_id: z.string().min(1) },
98
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
99
+ return ok(await client.del(siteId, `extensions/${encodeURIComponent(args.installation_id)}`));
100
+ }),
101
+ },
102
+ {
103
+ name: 'pair_extension_issuer',
104
+ description: 'Pair this Typeroll instance\'s token issuer with the Extension provider (manifest auth.pairing_url), the portal\'s "secure connection" action. Contacts the provider. Returns the trusted issuer record. Admin permission required.',
105
+ inputSchema: { installation_id: z.string().min(1) },
106
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
107
+ return ok(await client.post(siteId, `extensions/${encodeURIComponent(args.installation_id)}/pair`));
108
+ }),
109
+ },
110
+ {
111
+ name: 'read_extension_diagnostics',
112
+ description: 'Read an installation\'s diagnostics: status, health, release resolution, credential metadata (no secrets), the latest audit events and lifecycle event deliveries, and declared URL context inputs. Admin permission required.',
113
+ inputSchema: { installation_id: z.string().min(1) },
114
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
115
+ return ok(await client.get(siteId, `extensions/${encodeURIComponent(args.installation_id)}/diagnostics`));
116
+ }),
117
+ },
118
+ {
119
+ name: 'launch_extension_admin_page',
120
+ description: 'Issue a single-use, short-lived launch grant for one of the Extension\'s admin pages (manifest admin.pages), as opening the page in the portal does. Returns { launch_url, method, form, expires_at }: a browser tool must POST the `form` fields to launch_url before expires_at. The provider sees the caller as api-key:{prefix}. Treat the code as a credential. For approved native pages prefer call_extension_admin. The page\'s minimum_permission applies.',
121
+ inputSchema: {
122
+ installation_id: z.string().min(1),
123
+ page_id: z.string().min(1).describe('Admin page id from the installation manifest.'),
124
+ },
125
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
126
+ return ok(await client.post(siteId, `extensions/${encodeURIComponent(args.installation_id)}/launch`, { page_id: args.page_id }));
127
+ }),
128
+ },
129
+ ];
130
+ const ext = (id) => `extensions/${encodeURIComponent(id)}`;
131
+ /** Extension developer tools — the `typeroll extension` CLI's API. They act on
132
+ * the key's own organization, not on a site, and need an
133
+ * organization-scoped key (a site key gets 403). */
134
+ export const developerExtensionTools = [
135
+ {
136
+ name: 'list_developer_extensions', noSite: true,
137
+ description: 'List Extensions registered by your organization (developer side). Requires an organization API key.',
138
+ handler: withErrorBoundary(async (_args, { client }) => ok(await client.developer('GET', 'extensions'))),
139
+ },
140
+ {
141
+ name: 'read_developer_extension', noSite: true,
142
+ description: 'Read one of your organization\'s Extensions with all saved releases and their status (draft, review, published, deprecated, revoked). Requires an organization API key.',
143
+ inputSchema: { extension_id: z.string().min(1) },
144
+ handler: withErrorBoundary(async (args, { client }) => ok(await client.developer('GET', ext(args.extension_id)))),
145
+ },
146
+ {
147
+ name: 'update_developer_extension', noSite: true,
148
+ description: 'Update an Extension\'s name, status (active/suspended), distribution (only while every release is a draft), trusted origins or private allow-lists. Requires an organization API key.',
149
+ inputSchema: {
150
+ extension_id: z.string().min(1),
151
+ name: z.string().optional(),
152
+ status: z.enum(['active', 'suspended']).optional(),
153
+ distribution: z.enum(['private', 'unlisted', 'public']).optional(),
154
+ trusted_origins: z.array(z.string()).optional(),
155
+ allowed_org_ids: z.array(z.string()).optional(),
156
+ allowed_site_ids: z.array(z.string()).optional(),
157
+ },
158
+ handler: withErrorBoundary(async (args, { client }) => {
159
+ const { extension_id, ...patch } = args;
160
+ return ok(await client.developer('PATCH', ext(extension_id), patch));
161
+ }),
162
+ },
163
+ {
164
+ name: 'save_extension_version', noSite: true,
165
+ description: 'Save (create or replace) a draft release from a full Extension manifest. Published releases are immutable; bump manifest.version instead. Validate locally with `typeroll extension validate` first. Requires an organization API key.',
166
+ inputSchema: {
167
+ extension_id: z.string().min(1),
168
+ manifest: z.record(z.unknown()).describe('Complete manifest; its id must equal extension_id.'),
169
+ },
170
+ handler: withErrorBoundary(async (args, { client }) => ok(await client.developer('POST', `${ext(args.extension_id)}/versions`, { manifest: args.manifest }))),
171
+ },
172
+ {
173
+ name: 'publish_extension_version', noSite: true,
174
+ description: 'Publish a saved release after verifying its asset digests. Private releases become installable for allowed organizations and sites; public releases enter review before catalog discovery. Installations follow compatible published releases automatically, so get user approval. Requires an organization API key.',
175
+ inputSchema: { extension_id: z.string().min(1), version: z.string().min(1) },
176
+ handler: withErrorBoundary(async (args, { client }) => ok(await client.developer('POST', `${ext(args.extension_id)}/versions/${encodeURIComponent(args.version)}/publish`))),
177
+ },
178
+ {
179
+ name: 'set_extension_version_lifecycle', noSite: true,
180
+ description: 'Deprecate or revoke a release. Revoking stops installations from resolving to it. Requires an organization API key.',
181
+ inputSchema: {
182
+ extension_id: z.string().min(1),
183
+ version: z.string().min(1),
184
+ status: z.enum(['deprecated', 'revoked']),
185
+ reason: z.string().optional(),
186
+ },
187
+ handler: withErrorBoundary(async (args, { client }) => {
188
+ const { extension_id, version, ...body } = args;
189
+ return ok(await client.developer('PATCH', `${ext(extension_id)}/versions/${encodeURIComponent(version)}`, body));
190
+ }),
191
+ },
192
+ {
193
+ name: 'list_developer_extension_installations', noSite: true,
194
+ description: 'List operational metadata (status, versions, health; never config) for your Extension\'s installations on one customer site. Requires an organization API key and the customer\'s organization and site ids.',
195
+ inputSchema: { extension_id: z.string().min(1), owner_org_id: z.string().min(1), site_id: z.string().min(1) },
196
+ handler: withErrorBoundary(async (args, { client }) => ok(await client.developer('GET', `${ext(args.extension_id)}/installations`, undefined, {
197
+ owner_org_id: args.owner_org_id, site_id: args.site_id,
198
+ }))),
199
+ },
69
200
  ];
@@ -39,11 +39,11 @@ const targetSchema = z.object({
39
39
  // Forms editor; admin permission required, as in the portal.
40
40
  const actionSchema = z.object({
41
41
  id: z.string().optional().describe('Keep an existing action\'s id to update it in place (webhooks keep their stored secret).'),
42
- type: z.string().describe('"email", "webhook", or an action type provided by an installed app.'),
42
+ type: z.string().describe('"email", "webhook", or an action type provided by an installed app (see get_form_capabilities).'),
43
43
  config: z.record(z.string(), z.unknown()).describe('email: { to, subject, body, cc?, bcc?, reply_to?, include_all?, format?: "html"|"text" } — to/subject/body may use {{field}} placeholders, e.g. to: "{{email}}" for a confirmation to the visitor. ' +
44
44
  'webhook: { url (https), fields: ["name","email"] (only these values are sent), secret (signing secret; send "••••••••" to keep the stored one) }.'),
45
45
  });
46
- const actionsDescription = 'The complete list of actions after a submission (replaces the current list): email notifications, webhooks, app actions. Read the form first and send back the actions you keep. Requires admin permission, like the portal.';
46
+ const actionsDescription = 'The complete list of actions after a submission (replaces the current list): email notifications, webhooks, app actions (get_form_capabilities lists the types and their config). Read the form first and send back the actions you keep. Emails send through the provider set with set_email_settings. Requires admin permission, like the portal.';
47
47
  export const formTools = [
48
48
  {
49
49
  name: 'list_forms',
@@ -53,6 +53,11 @@ export const formTools = [
53
53
  return ok(res);
54
54
  }),
55
55
  },
56
+ {
57
+ name: 'get_form_capabilities',
58
+ description: 'List the action types a form can run after a submission (core "email" and "webhook" plus types provided by installed apps) and the prefill sources, each with its config field schema — the same choices as the portal\'s Forms editor. Read this before writing `actions` with create_form/update_form. Admin permission required.',
59
+ handler: withErrorBoundary(async (_args, { client, siteId }) => ok(await client.get(siteId, 'form-capabilities'))),
60
+ },
56
61
  {
57
62
  name: 'read_form',
58
63
  description: 'Read one form by id, including fields/steps, submit_text, success_message and, for admins, its actions (email notifications and webhooks; secrets masked). Place it with a `core/form` block using data.form_id on a block-mode page, or `<x-form id="…" />` in HTML mode. Both references are expanded server-side with validation, signed token, initial state, and the shared runtime.',
@@ -119,7 +124,7 @@ export const formTools = [
119
124
  },
120
125
  {
121
126
  name: 'list_form_submissions',
122
- description: 'List submissions received for a form, newest first, cursor-paginated (cap 200 per page). Use this to help a customer triage inbound contact / lead submissions.',
127
+ description: 'List submissions received for a form, newest first, cursor-paginated (cap 200 per page). Admins also see each submission\'s webhook delivery status. Use this to help a customer triage inbound contact / lead submissions; read_form_submission reads one.',
123
128
  inputSchema: {
124
129
  form_id: z.string(),
125
130
  limit: z.number().int().min(1).max(200).optional(),
@@ -131,6 +136,18 @@ export const formTools = [
131
136
  return ok(res);
132
137
  }),
133
138
  },
139
+ {
140
+ name: 'read_form_submission',
141
+ description: 'Read one submission of a form by id (from list_form_submissions): the submitted values, status (partial or complete), step and timestamps. Admins also see its webhook delivery status, as in the portal.',
142
+ inputSchema: {
143
+ form_id: z.string(),
144
+ submission_id: z.string(),
145
+ },
146
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
147
+ const res = await client.get(siteId, `forms/${encodeURIComponent(args.form_id)}/submissions/${encodeURIComponent(args.submission_id)}`);
148
+ return ok(res);
149
+ }),
150
+ },
134
151
  {
135
152
  name: 'delete_form_submission',
136
153
  description: 'Delete a single submission from a form\'s inbox. Use this to remove individual entries (test submissions, spam) without touching the rest — delete_form with delete_submissions is the only way to bulk-delete. Get submission ids from list_form_submissions.',
@@ -18,6 +18,12 @@ export const mediaTools = [
18
18
  inputSchema: {},
19
19
  handler: withErrorBoundary(async (_args, { client, siteId }) => ok(await client.get(siteId, 'media/import'))),
20
20
  },
21
+ {
22
+ name: 'get_media_upload_status',
23
+ description: 'Pre-flight for uploads: whether media uploads can go through for this site right now (organization storage connected, or platform storage configured), with the reason and a settings_url when they cannot. Same check as the banner in the portal media library. Requires site read access.',
24
+ inputSchema: {},
25
+ handler: withErrorBoundary(async (_args, { client, siteId }) => ok(await client.get(siteId, 'media/upload-status'))),
26
+ },
21
27
  {
22
28
  name: 'read_private_media_url',
23
29
  description: 'Get a 60-second read URL for a private media original. Use it for authorized image inspection; never store it in page content or generated source. Use the stable media URL or ID in content.',
@@ -229,6 +235,12 @@ export const mediaTools = [
229
235
  return ok(res);
230
236
  }),
231
237
  },
238
+ {
239
+ name: 'purge_site_media',
240
+ description: 'Permanently delete every media object and record of an ARCHIVED site (archive_site first; an active site returns 409). Irreversible — the step before retiring a site for good, same as the portal action. Requires an admin key of the organization that owns the site; shared access is refused. Returns counts; HTTP 207 with `failed` lists objects that could not be removed (their records are kept) — call again to retry exactly those. Confirm with the user before calling.',
241
+ inputSchema: {},
242
+ handler: withErrorBoundary(async (_args, { client, siteId }) => ok(await client.post(siteId, 'media/purge'))),
243
+ },
232
244
  {
233
245
  name: 'delete_media',
234
246
  description: 'Delete a media item\'s metadata. (R2 object cleanup is a separate ops task.)',
@@ -287,7 +287,7 @@ export const pageTools = [
287
287
  // the block-tree mutation tools (add/update/move/remove/convert).
288
288
  {
289
289
  name: 'get_page_preview',
290
- description: "Get the WHOLE page rendered as one self-contained HTML document — header partial + block-rendered body + footer partial, with the site's settings CSS variables, global styles, and the tree-shaken block-CSS bundle all inlined, exactly as deployed. This is the single artifact for UNDERSTANDING what a page looks like and how its CSS actually cascades (get_page_blocks gives the editable block tree; this gives the rendered result). Returns { rendered_html, internal_links[] }. Pass annotate:true to tag every element with data-block-id + data-block-type so you can map the rendered HTML back to the block to edit. For a clickable preview URL use get_preview_link instead.",
290
+ description: "Get the WHOLE page rendered as one self-contained HTML document — header partial + block-rendered body + footer partial, with the site's settings CSS variables, global styles, the tree-shaken block-CSS bundle, block JavaScript, the Extension runtime and the cookie-consent banner all included, exactly as the portal Preview shows it. This is the single artifact for UNDERSTANDING what a page looks like and how its CSS actually cascades (get_page_blocks gives the editable block tree; this gives the rendered result). Returns { rendered_html, internal_links[] }. Pass annotate:true to tag every element with data-block-id + data-block-type so you can map the rendered HTML back to the block to edit. For a clickable preview URL use get_preview_link instead.",
291
291
  inputSchema: {
292
292
  page_id: z.string(),
293
293
  annotate: z
@@ -118,7 +118,7 @@ export const partialTools = [
118
118
  },
119
119
  {
120
120
  name: 'find_pages_using_block',
121
- description: 'Pages that embed a given block via <x-include name="…">. For partial_id "header" or "footer" returns the full page list (they are auto-injected on every page). Use this to know the blast radius before editing a shared block.',
121
+ description: 'What references a global block, saved or in a draft: `pages` (core/global_block or <x-include name="…">), `templates` (page templates) and `global_blocks` (header, footer and other global blocks that nest it; a header or footer means every page). For partial_id "header" or "footer" returns the full page list (they are auto-injected on every page). Use this to know the blast radius before editing a shared block.',
122
122
  inputSchema: {
123
123
  partial_id: z.string(),
124
124
  version: versionParam,
@@ -24,7 +24,7 @@ export const reusableBlockTools = [
24
24
  },
25
25
  {
26
26
  name: 'detach_global_block',
27
- description: 'Replace a core/global_block reference on a page with an editable copy of the global block\'s blocks. Later edits to the global block no longer reach this page. Writes the page draft.',
27
+ description: 'Replace a core/global_block reference on a page with an editable copy of the global block\'s blocks. Copies the global block\'s unsaved draft on this version when it has one (what the editors show), otherwise the saved global block; `copied_from` says which. Later edits to the global block no longer reach this page. Writes the page draft.',
28
28
  inputSchema: {
29
29
  page_id: z.string(),
30
30
  block_id: z.string().describe('The id of the core/global_block reference block.'),
@@ -1,10 +1,10 @@
1
- // Settings tools. scripts_head, scripts_body_end, and custom_css ARE
2
- // writable via the public API (as of mcp-server 0.4.x) — the v1 route
3
- // accepts them and they round-trip through read_site_settings. Same
4
- // trust model as user-authored block-type JS: a bearer-token caller
5
- // takes responsibility for what they ship. The portal chat AI still
6
- // doesn't expose these fields, so conversation-driven assistants can't
7
- // smuggle scripts in.
1
+ // Settings tools. update_site_settings accepts every field the portal
2
+ // Settings form does — including scripts_head, scripts_body_end,
3
+ // custom_css, cookie-consent scripts, default_og_image, twitter_handle,
4
+ // organization (JSON-LD) and staging_url — with the same admin permission
5
+ // the portal requires. A bearer-token caller takes responsibility for what
6
+ // it ships, exactly as a site admin in the portal does. (The in-portal chat
7
+ // assistant has its own, narrower settings tool; that is unrelated to MCP.)
8
8
  import { z } from 'zod';
9
9
  import { ok, withErrorBoundary, versionParam } from './helpers.js';
10
10
  function v(version) {
@@ -13,7 +13,7 @@ function v(version) {
13
13
  export const settingsTools = [
14
14
  {
15
15
  name: 'read_site_settings',
16
- description: "Read every site setting: name, tagline, logo, favicon/app icons, colors, fonts, contact info, social links, URL trailing-slash policy, iframe host allowlist, default SEO suffix/description, language, robots_txt, image_sizes_default, plus the scriptable surfaces scripts_head, scripts_body_end, and custom_css, and `render` (the site's platform render version, the latest version and what upgrading would change). Pass `version` to read a branch's settings (with copy-on-write chain-fallback to main for fields the branch hasn't overridden).",
16
+ description: "Read every site setting: name, tagline, logo, favicon/app icons, colors, fonts, contact info, social links, URL trailing-slash policy, iframe host allowlist, default SEO suffix/description, default_og_image, twitter_handle, organization (JSON-LD), language, robots_txt, image_sizes_default, cookie_consent, plus the scriptable surfaces scripts_head, scripts_body_end, and custom_css, `urls` (including `urls.staging`, the site's staging_url) and `render` (the site's platform render version, the latest version and what upgrading would change). Pass `version` to read a branch's settings (with copy-on-write chain-fallback to main for fields the branch hasn't overridden).",
17
17
  inputSchema: {
18
18
  version: versionParam,
19
19
  },
@@ -24,12 +24,14 @@ export const settingsTools = [
24
24
  },
25
25
  {
26
26
  name: 'update_site_settings',
27
- description: 'Patch site settings, including responsive breakpoints for block layouts and visibility. Only the fields you pass change. ' +
27
+ description: 'Patch site settings, including responsive breakpoints for block layouts and visibility. Accepts everything the portal Settings form does. Requires admin permission on the site, as in the portal. Only the fields you pass change. ' +
28
28
  'Pass fields at the TOP LEVEL of the object — do NOT wrap in a "settings" key. ' +
29
29
  'Example: {"site_name": "Acme", "colors": {"primary": "#ff0"}} not {"settings": {...}}. ' +
30
30
  'Nested objects (colors, fonts, contact, social) are shallow-merged into the existing value. ' +
31
31
  'Unknown top-level keys return a 400 error listing the valid fields. ' +
32
- 'scripts_head / scripts_body_end / custom_css ARE writable here — useful for a global stylesheet across all pages. ' +
32
+ 'scripts_head / scripts_body_end / custom_css and cookie_consent scripts ARE writable here — useful for a global stylesheet or analytics tag across all pages. ' +
33
+ 'Social sharing and structured data: default_og_image, twitter_handle, organization ({name, logo, same_as[]}, replaced as a whole; null clears). ' +
34
+ 'staging_url is stored on the Site (not per version), so it applies whichever `version` you pass. ' +
33
35
  'Pass `version` to scope the write to a branch (copy-on-write) instead of main — the right way to brand/recolor a site inside a redesign branch (colors, fonts, logo, custom_css) without touching the live settings. Omit it to write main.',
34
36
  inputSchema: {
35
37
  version: versionParam,
@@ -54,6 +56,14 @@ export const settingsTools = [
54
56
  scripts_head: z.string().optional().describe('Raw HTML injected into <head> on every page. Use for analytics, fonts, third-party CSS links.'),
55
57
  scripts_body_end: z.string().optional().describe('Raw HTML injected just before </body> on every page. Use for chat widgets, deferred analytics.'),
56
58
  custom_css: z.string().optional().describe('Global CSS in a <style> in <head>, after block CSS and before the page\'s own custom CSS and the template base stylesheet (reset + global). Base rules for :root tokens (spacing, radius, container widths), body font and line-height load after it, so override those with a more specific selector (for example html:root or body.page) rather than a bare :root/body rule. Preview uses the same order. Lets you define site-wide design tokens (CSS variables, @media queries, :hover states) without inlining on every element. Prefer named styles (create_style) for anything a style can express. Syntax errors (unbalanced braces, unclosed comments or strings, expression()/javascript:) refuse the write; selectors on platform markup ([data-block], .block-*) come back as warnings because they can change between render versions — target s-<style> classes or block custom_class instead.'),
59
+ default_og_image: z.string().optional().describe('Site-wide fallback og:image URL for pages without their own social image. Empty string clears.'),
60
+ twitter_handle: z.string().optional().describe('Twitter/X handle for twitter:site, with or without the leading @ (stored without it). Empty string clears.'),
61
+ organization: z.object({
62
+ name: z.string().optional(),
63
+ logo: z.string().optional().describe('Absolute logo URL for the Organization JSON-LD.'),
64
+ same_as: z.array(z.string()).max(50).optional().describe('Profile URLs (LinkedIn, X, Facebook, …) emitted as sameAs.'),
65
+ }).strict().nullable().optional().describe('Organization schema.org JSON-LD emitted on every page. Replaces the stored value as a whole; null (or all-empty) clears it.'),
66
+ staging_url: z.string().nullable().optional().describe('URL of a staging environment for this site, reported as urls.staging. Stored on the Site, not per version. Trailing slashes are dropped; empty string or null clears.'),
57
67
  render_version: z.number().int().min(1).optional().describe('Platform render version. Platform output changes ship as new versions so existing sites never change look on their own. Upgrade only after previewing (get_preview_link render_version) and with the user\'s approval; the tr-upgrade-rendering skill compares every page. Lowering it returns to an earlier version.'),
58
68
  colors: z.record(z.string()).optional(),
59
69
  fonts: z.record(z.unknown()).optional(),
@@ -1,4 +1,6 @@
1
- // Sites tools — discovery + Site-level identity edits.
1
+ // Sites tools — discovery, Site-level identity edits and the site lifecycle
2
+ // (archive / restore). Each maps to a v1 route with the same permission
3
+ // check as the corresponding portal action.
2
4
  import { z } from 'zod';
3
5
  import { ok, withErrorBoundary } from './helpers.js';
4
6
  export const siteTools = [
@@ -30,7 +32,7 @@ export const siteTools = [
30
32
  },
31
33
  {
32
34
  name: 'get_site',
33
- description: 'Read this site\'s metadata (id, name, slug, domain, active version) + a urls object covering the production / fallback / preview_base URLs. Useful as a first call to confirm the key is wired up and to learn what URLs the site is reachable at.',
35
+ description: 'Read this site\'s metadata (id, name, slug, domain, language, ai_scripts_enabled, lifecycle {status: active|archived}, active version) + a urls object covering the production / fallback / preview_base / staging URLs. Useful as a first call to confirm the key is wired up and to learn what URLs the site is reachable at.',
34
36
  handler: withErrorBoundary(async (_args, { client, siteId }) => {
35
37
  const res = await client.get(siteId, '');
36
38
  return ok(res);
@@ -65,16 +67,36 @@ export const siteTools = [
65
67
  },
66
68
  {
67
69
  name: 'update_site',
68
- description: 'Edit Site-level identity fields: name (display), slug (drives the {slug}.typeroll-fallback subdomain — kebab-case, 3-48 chars, unique across the org), domain (the customer\'s real hostname; pass "" to clear). For colors / fonts / contact info / tagline use update_site_settings instead.',
70
+ description: 'Edit Site-level fields: name (display), slug (drives the {slug}.typeroll-fallback subdomain — kebab-case, 3-48 chars, unique across the org), domain (the customer\'s real hostname; pass "" to clear), language, and ai_scripts_enabled (the portal\'s "Allow AI to write block scripts" toggle; requires admin permission, as in the portal). For colors / fonts / contact info / tagline / staging_url use update_site_settings instead.',
69
71
  inputSchema: {
70
72
  name: z.string().min(1).optional(),
71
73
  slug: z.string().optional().describe('Kebab-case identifier, 3-48 chars [a-z0-9-]. Empty string clears.'),
72
74
  domain: z.string().optional().describe('Bare hostname e.g. "example.com". Empty string clears.'),
73
75
  language: z.string().optional().describe('Default content language as a BCP-47 tag (e.g. "en", "sv", "en-GB"). Drives <html lang> and the default for alt-text generation. Empty string clears.'),
76
+ ai_scripts_enabled: z.boolean().optional().describe('"Allow AI to write block scripts": lets the in-portal chat assistant author block JavaScript for this site. API keys and MCP are not gated by it — they can always write block `script` and core/embed `js`. Requires admin permission.'),
74
77
  },
75
78
  handler: withErrorBoundary(async (args, { client, siteId }) => {
76
79
  const res = await client.patch(siteId, '', args);
77
80
  return ok(res);
78
81
  }),
79
82
  },
83
+ {
84
+ name: 'archive_site',
85
+ description: 'Archive (retire) this site, the same action as Settings → Archive site in the portal. An archived site stays readable but refuses every write and publish until restored; the last published output keeps serving. Refused with 409 while a custom domain is still live or verified — move or remove the domain first. Requires an admin key of the organization that OWNS the site (a site-scoped key or the owner organization\'s org key); a key that reaches the site through a share is refused. Idempotent. Confirm with the user before calling.',
86
+ inputSchema: {
87
+ reason: z.string().max(500).optional().describe('Why the site is retired; shown in the portal.'),
88
+ },
89
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
90
+ const res = await client.post(siteId, 'lifecycle', { action: 'archive', ...(args.reason ? { reason: args.reason } : {}) });
91
+ return ok(res);
92
+ }),
93
+ },
94
+ {
95
+ name: 'restore_site',
96
+ description: 'Restore an archived site so it accepts writes and publishing again, the same action as Restore in the portal. Same permission as archive_site (owner-organization admin). Idempotent: restoring an active site succeeds without change.',
97
+ handler: withErrorBoundary(async (_args, { client, siteId }) => {
98
+ const res = await client.post(siteId, 'lifecycle', { action: 'restore' });
99
+ return ok(res);
100
+ }),
101
+ },
80
102
  ];
@@ -12,7 +12,7 @@ export const versionTools = [
12
12
  },
13
13
  {
14
14
  name: 'create_branch',
15
- description: "Create a copy-on-write branch from main (or the version passed in `base`) — the RECOMMENDED first step for any larger or experimental change (redesigns, multi-page edits, trying a new design direction). Work lands on the branch, never on the live main version, until you merge_branch it. New branches default to robots_blocked:true (a half-finished design can't be indexed) and get their own stable deploy address for stakeholder review: after the branch's first trigger_deploy, read it from deploy_url in list_versions or read_version (the publishing setup decides the host: under a Hosting Group it is a v-… host under that group's site address base, otherwise the address the host reported; never construct it yourself). Pass the returned id as ?version= on every subsequent read/write. When in doubt, branch — it's cheap and keeps the live site safe. The tr-redesign-branch skill (read_skill) walks the full flow.",
15
+ description: "Create a copy-on-write branch from main (or the version passed in `base`) — the RECOMMENDED first step for any larger or experimental change (redesigns, multi-page edits, trying a new design direction). Work lands on the branch, never on the live main version, until you merge_branch it. New branches default to robots_blocked:true (a half-finished design can't be indexed) and get their own stable deploy address for stakeholder review: after the branch's first trigger_deploy, read it from deploy_url in list_versions or read_version (the publishing setup decides the host: under a Hosting Group it is a v-… host under that group's site address base, otherwise the address the host reported; never construct it yourself). Pass the returned id as ?version= on every subsequent read/write. When in doubt, branch — it's cheap and keeps the live site safe. The tr-redesign-branch skill (read_skill) walks the full flow. Admin permission on the site is required, as in the portal.",
16
16
  inputSchema: {
17
17
  name: z.string().min(1),
18
18
  base: z.string().optional().describe('Source version id; defaults to main.'),
@@ -33,16 +33,34 @@ export const versionTools = [
33
33
  },
34
34
  {
35
35
  name: 'delete_branch',
36
- description: 'Discard a branch (main cannot be deleted).',
36
+ description: 'Discard a branch with its overrides, tombstones and revision history (main cannot be deleted). Admin permission required.',
37
37
  inputSchema: { version_id: z.string() },
38
38
  handler: withErrorBoundary(async (args, { client, siteId }) => {
39
39
  const res = await client.del(siteId, `versions/${encodeURIComponent(args.version_id)}`);
40
40
  return ok(res);
41
41
  }),
42
42
  },
43
+ {
44
+ name: 'diff_version',
45
+ description: 'Read-only: what a branch changes relative to main, per collection (pages, partials, redirects, contentTypes, pageTemplates, blockTypes): ids it adds, modifies and deletes, plus whether it overrides site settings and totalChanges. This is exactly what merge_branch would land on main and what reset_version would discard. Use it to summarise a branch for review before asking for merge approval.',
46
+ inputSchema: { version_id: z.string().describe('Branch id (main has nothing to diff).') },
47
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
48
+ const res = await client.get(siteId, `versions/${encodeURIComponent(args.version_id)}/diff`);
49
+ return ok(res);
50
+ }),
51
+ },
52
+ {
53
+ name: 'reset_version',
54
+ description: 'Discard EVERY change on a branch (all overrides and deletions), so it reads straight through to main again. The branch itself, its deploy address and its revision history are kept. Destructive for the branch\'s work: run diff_version first and get explicit user approval. Returns { cleared } — the diff that was discarded. Admin permission required. Main cannot be reset.',
55
+ inputSchema: { version_id: z.string() },
56
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
57
+ const res = await client.post(siteId, `versions/${encodeURIComponent(args.version_id)}/reset`);
58
+ return ok(res);
59
+ }),
60
+ },
43
61
  {
44
62
  name: 'merge_branch',
45
- description: 'Promote a branch\'s overrides + tombstones onto main. The branch is left in place so you can keep iterating; delete_branch removes it when you\'re done.',
63
+ description: 'Promote a branch\'s overrides + tombstones onto main (diff_version shows exactly what will land). The branch is left in place so you can keep iterating; delete_branch removes it when you\'re done. Admin permission required.',
46
64
  inputSchema: { version_id: z.string() },
47
65
  handler: withErrorBoundary(async (args, { client, siteId }) => {
48
66
  const res = await client.post(siteId, `versions/${encodeURIComponent(args.version_id)}/merge`);
@@ -0,0 +1,61 @@
1
+ // Workflow tools — the portal's server-side workflows (WordPress migration,
2
+ // AI site planning, SEO / link / performance audits, content generation and
3
+ // improvement, schema markup, URL parity, rebuild & deploy) and creating a
4
+ // Site together with its first workflow.
5
+ import { z } from 'zod';
6
+ import { ok, versionParam, withErrorBoundary } from './helpers.js';
7
+ const WORKFLOW_TYPES = [
8
+ 'migration', 'site_planning', 'seo_audit', 'content_improvement', 'link_check',
9
+ 'performance_audit', 'content_generation', 'schema_markup', 'url_parity', 'rebuild_deploy',
10
+ ];
11
+ export const workflowTools = [
12
+ {
13
+ name: 'list_workflows',
14
+ description: 'List the workflow types this Site can run (label, description, steps, required_permission) and its most recent runs with status. Read only. Migration, site planning and URL parity pause for review; check get_workflow for paused_for_review.',
15
+ inputSchema: { limit: z.number().int().min(1).max(100).optional() },
16
+ handler: withErrorBoundary(async (args, { client, siteId }) => ok(await client.get(siteId, 'workflows', args.limit ? { limit: args.limit } : undefined))),
17
+ },
18
+ {
19
+ name: 'start_workflow',
20
+ description: 'Start a server-side workflow on this Site; it runs in the background and returns workflow_id. Poll get_workflow. Config per type (same fields as the portal form): migration { wp_url, helper_api_key? } (needs verified organization import storage); site_planning { business_description }; content_generation { topic, tone?, audience? }; content_improvement { limit? }; url_parity { target_origin?, source_origin?, check_source?, statuses? }; rebuild_deploy { environment: staging | production }; seo_audit, link_check, performance_audit and schema_markup take none. Needs write permission; rebuild_deploy publishes and needs admin. Workflows that change content write to the given version (default main) — get the user\'s agreement first.',
21
+ inputSchema: {
22
+ type: z.enum(WORKFLOW_TYPES),
23
+ config: z.record(z.unknown()).optional(),
24
+ version: versionParam,
25
+ },
26
+ handler: withErrorBoundary(async (args, { client, siteId }) => ok(await client.post(siteId, 'workflows', { type: args.type, config: args.config }, args.version ? { version: args.version } : undefined))),
27
+ },
28
+ {
29
+ name: 'get_workflow',
30
+ description: 'Read one workflow run: status (pending | running | paused_for_review | completed | failed), current step, progress, log, review_message/review_data when paused, results and failure_reason. Credential config is masked.',
31
+ inputSchema: { workflow_id: z.string() },
32
+ handler: withErrorBoundary(async (args, { client, siteId }) => ok(await client.get(siteId, `workflows/${encodeURIComponent(args.workflow_id)}`))),
33
+ },
34
+ {
35
+ name: 'approve_workflow',
36
+ description: 'Approve the review gate of a run that is paused_for_review; it resumes from the next step in the background. Show the user review_message and review_data from get_workflow and get their approval first — approval is theirs to give, not the tool\'s. Write permission; any other status returns 409.',
37
+ inputSchema: { workflow_id: z.string() },
38
+ handler: withErrorBoundary(async (args, { client, siteId }) => ok(await client.post(siteId, `workflows/${encodeURIComponent(args.workflow_id)}/approve`))),
39
+ },
40
+ {
41
+ name: 'create_site_and_migrate',
42
+ noSite: true,
43
+ description: 'Create a new Site in the Organization and start a WordPress migration into it, like "Migrate from WordPress" on the portal\'s New site page. Requires an organization API key and verified organization import storage (409 import_storage_required otherwise — nothing is created). Returns site and workflow ids; poll get_workflow with that site_id. Run get_migration_readiness on the new Site if you need the preflight first.',
44
+ inputSchema: {
45
+ name: z.string().min(1).describe('Site display name; slugified into the Site id.'),
46
+ wp_url: z.string().url().describe('Public WordPress address, e.g. https://oldsite.example.'),
47
+ helper_api_key: z.string().optional().describe('Typeroll Helper plugin key from the WordPress admin, if installed. Stored for the run and never returned.'),
48
+ },
49
+ handler: withErrorBoundary(async (args, { client }) => ok(await client.rootPost('sites/create-and-migrate', args))),
50
+ },
51
+ {
52
+ name: 'create_site_and_plan',
53
+ noSite: true,
54
+ description: 'Create a new Site in the Organization and start AI site planning from a business description, like "Plan a new site with AI" on the New site page. Requires an organization API key. The plan pauses for review: read it with get_workflow and approve_workflow only after the user agrees.',
55
+ inputSchema: {
56
+ name: z.string().min(1),
57
+ business_description: z.string().min(1).describe('What the business does, for whom, and what sets it apart.'),
58
+ },
59
+ handler: withErrorBoundary(async (args, { client }) => ok(await client.rootPost('sites/create-and-plan', args))),
60
+ },
61
+ ];
@@ -9,6 +9,8 @@
9
9
  // Save button)
10
10
  // discard_working_copy → throw the draft away
11
11
  // list/read/restore_page_revision → saved-state history (undo)
12
+ // preview_page_revision → render a saved state
13
+ // list/read/restore_partial_revision → the same for partials
12
14
  //
13
15
  // The portal editor shows any agent-written draft as "Unsaved changes", so
14
16
  // the human can also Save or Discard it from the UI.
@@ -118,4 +120,64 @@ export const workingCopyTools = [
118
120
  return ok(res);
119
121
  }),
120
122
  },
123
+ {
124
+ name: 'preview_page_revision',
125
+ description: 'Render one saved page revision as the whole preview document (header, body, footer, site CSS and block scripts), exactly what the editor\'s History panel shows before a restore. Read-only. The revision\'s fields are laid over the current page; the current header, footer and settings give context. Returns { page_id, revision_id, slug, title, rendered_html, internal_links }. Pass annotate:true to tag block roots with data-block-id + data-block-type. Compare with get_page_preview before restore_page_revision.',
126
+ inputSchema: {
127
+ page_id: z.string(),
128
+ revision_id: z.string(),
129
+ annotate: z.boolean().optional(),
130
+ version: versionParam,
131
+ },
132
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
133
+ const query = { ...(v(args.version) ?? {}) };
134
+ if (args.annotate)
135
+ query.annotate = 'true';
136
+ const res = await client.get(siteId, `pages/${encodeURIComponent(args.page_id)}/revisions/${encodeURIComponent(args.revision_id)}/preview`, query);
137
+ return ok(res);
138
+ }),
139
+ },
140
+ {
141
+ name: 'list_partial_revisions',
142
+ description: "Saved-state history of a partial (header, footer or global block) on this version, newest first. Every save snapshots the partial as it was BEFORE the save. Returns { revisions: [{ id, created_at, created_by, note, name, content_mode, date_updated }], total }. Use read_partial_revision for the full document and restore_partial_revision to undo.",
143
+ inputSchema: {
144
+ partial_id: z.string(),
145
+ limit: z.number().int().min(1).max(100).optional().describe('Newest N entries (default 50).'),
146
+ version: versionParam,
147
+ },
148
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
149
+ const query = { ...(v(args.version) ?? {}) };
150
+ if (args.limit)
151
+ query.limit = String(args.limit);
152
+ const res = await client.get(siteId, `partials/${encodeURIComponent(args.partial_id)}/revisions`, query);
153
+ return ok(res);
154
+ }),
155
+ },
156
+ {
157
+ name: 'read_partial_revision',
158
+ description: 'Read one partial revision with the full saved document (name, kind, html_content or blocks, status) — compare it with read_partial before restoring.',
159
+ inputSchema: {
160
+ partial_id: z.string(),
161
+ revision_id: z.string(),
162
+ version: versionParam,
163
+ },
164
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
165
+ const res = await client.get(siteId, `partials/${encodeURIComponent(args.partial_id)}/revisions/${encodeURIComponent(args.revision_id)}`, v(args.version));
166
+ return ok(res);
167
+ }),
168
+ },
169
+ {
170
+ name: 'restore_partial_revision',
171
+ description: "Restore a partial revision's name and content (HTML or block tree) into the partial's DRAFT, replacing the current draft. Pass save:true to save it at once; the save snapshots the current partial first, so the restore is itself undoable. Status and kind are kept. A revision from the other content mode is refused (409) — switch mode first. Returns { restored_revision, saved, has_unsaved_changes, staged_fields, sanitization_warnings }.",
172
+ inputSchema: {
173
+ partial_id: z.string(),
174
+ revision_id: z.string(),
175
+ save: z.boolean().optional().describe('Save immediately (default false: leave it as an unsaved draft to preview).'),
176
+ version: versionParam,
177
+ },
178
+ handler: withErrorBoundary(async (args, { client, siteId }) => {
179
+ const res = await client.post(siteId, `partials/${encodeURIComponent(args.partial_id)}/revisions/${encodeURIComponent(args.revision_id)}/restore`, { save: args.save === true }, v(args.version));
180
+ return ok(res);
181
+ }),
182
+ },
121
183
  ];
package/dist/version.js CHANGED
@@ -8,4 +8,4 @@
8
8
  //
9
9
  // Keep it in lockstep with package.json: tests/version.test.ts asserts
10
10
  // VERSION === package.json.version, so a bump that forgets this line fails CI.
11
- export const VERSION = '0.45.44';
11
+ export const VERSION = '0.45.46';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typeroll/mcp-server",
3
- "version": "0.45.44",
3
+ "version": "0.45.46",
4
4
  "description": "Typeroll CMS MCP server – connect AI agents to the REST API to manage content and publish static websites.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/skills/README.md CHANGED
@@ -43,6 +43,7 @@ instructions. Read the relevant recipe when the task calls for it.
43
43
  |---|---|---|
44
44
  | `tr-blog.md` | "add a blog", "set up news" | Articles are Pages of a content type, sharing a native template and Page listing. |
45
45
  | `tr-forms.md` | "contact form", "add a form", "booking form" | Form definition → embed HTML with signed token → inline JS feedback → deploy. |
46
+ | `tr-custom-blocks.md` | "make a block for…", "icon list", a section shape the core blocks lack | Starter or composition from core blocks with fields and bindings → validate → preview → create → place. |
46
47
  | `tr-page-template.md` | Reusable Page templates: audio players, chapter lists, guest cards, image galleries — anything needing loops/nested data | Compose native blocks around `template_content_slot`; bind Page metadata, structured fields and references. |
47
48
  | `tr-seo.md` | "SEO", "meta descriptions", "structured data" | Audit → fix titles/descriptions → OG images → JSON-LD → robots.txt → deploy. |
48
49