@typeroll/mcp-server 0.45.120 → 0.45.122

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.
@@ -0,0 +1,118 @@
1
+ // Live snippets: small pieces of content a site keeps outside its
2
+ // publication. A save is written at once as a public file the live site
3
+ // reads, so it changes without publishing. They belong to the site, not to a
4
+ // version, so these tools take no `version`.
5
+ import { z } from 'zod';
6
+ import { ApiError } from '../client.js';
7
+ import { fail, ok } from './helpers.js';
8
+ const SNIPPET_MODEL = 'A live snippet is content outside the build: saving it updates the live site within about a minute, without a publication or a rebuild, so use it for content that changes often (today\'s lunch, a notice, the current waiting time). ' +
9
+ 'Snippets belong to the site (not to a branch), at most 100 per site and 64 KB each. Shape: { id, name, kind, format?, content?, entries?, fallback? }. ' +
10
+ 'kind "html": content is HTML, sanitized like page content when saved. kind "text": content is plain text, escaped when shown. ' +
11
+ 'kind "dated": entries keyed by date or weekday, and the page shows today\'s entry in the site\'s time zone (read_site_settings → time_zone), chosen in the visitor\'s browser: ' +
12
+ '{ kind: "dated", format: "html" | "text", entries: [{ weekday: "monday", content: "…" }, …, { date: "2026-12-24", content: "Closed" }], fallback: "No lunch today" }. ' +
13
+ 'A date entry wins over a weekday entry; fallback shows on a day without one. For "today\'s lunch", write the whole week once (one entry per weekday, plus dated exceptions) instead of saving every day; the file stays unchanged between writes. ' +
14
+ 'To show a snippet on a page, place a `core/snippet` block with data { snippet: "<snippet id>" } where it should appear: the page carries the value of the latest publication (for search engines and without script) and the browser then shows the newest. ' +
15
+ 'Placing or moving the block is a page edit that needs a publication; changing the snippet afterwards does not. ' +
16
+ 'A site field defined with `live: true` (define_site_fields) works the same way for a single value: the `core/site_field` block shows its newest value without publishing. ' +
17
+ 'Every save answers `live`: { published: true, url } when the public file was written, or { published: false, reason } when the site has no media host that can serve it (the snippet is still saved and shows at the next publication).';
18
+ /** A refused save carries every problem with its path; show them plainly. */
19
+ function snippetFailure(error) {
20
+ if (error instanceof ApiError && error.status === 400) {
21
+ const errors = error.body?.details?.errors;
22
+ if (Array.isArray(errors) && errors.length) {
23
+ return {
24
+ content: [{ type: 'text', text: JSON.stringify({
25
+ error: 'The snippet was not saved: it is not valid.', status: 400, errors,
26
+ hint: 'Fix each path (for example entries[2].weekday) and send the whole snippet again.',
27
+ }, null, 2) }],
28
+ isError: true,
29
+ };
30
+ }
31
+ }
32
+ if (error instanceof ApiError && error.status === 409) {
33
+ return {
34
+ content: [{ type: 'text', text: JSON.stringify({
35
+ error: error.message, status: 409,
36
+ hint: 'Someone saved the snippet after you read it (or the id is taken, or the site has 100 snippets). read_snippet again and reapply your change with the new updated_at.',
37
+ }, null, 2) }],
38
+ isError: true,
39
+ };
40
+ }
41
+ return fail(error);
42
+ }
43
+ const idParam = z.string().describe('The snippet id: lowercase letters, digits, - and _ (for example "lunch").');
44
+ const entryShape = z.object({
45
+ date: z.string().optional().describe('A calendar date, 2026-11-09. Wins over a weekday entry.'),
46
+ weekday: z.enum(['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']).optional(),
47
+ content: z.string().describe('HTML or plain text, as the snippet\'s format.'),
48
+ });
49
+ export const snippetTools = [
50
+ {
51
+ name: 'list_snippets',
52
+ description: 'List the site\'s live snippets with their content and updated_at, and `live.base_url`: where their public files are served (null with a reason when the site has no media host, so snippets only change at publication). ' + SNIPPET_MODEL,
53
+ inputSchema: {},
54
+ handler: async (_args, { client, siteId }) => {
55
+ try {
56
+ return ok(await client.get(siteId, 'snippets'));
57
+ }
58
+ catch (error) {
59
+ return fail(error);
60
+ }
61
+ },
62
+ },
63
+ {
64
+ name: 'read_snippet',
65
+ description: 'Read one live snippet, its updated_at (pass it to update_snippet as expected_updated_at) and live_url, the public file the live site reads. For the model, see list_snippets.',
66
+ inputSchema: { snippet_id: idParam },
67
+ handler: async (args, { client, siteId }) => {
68
+ try {
69
+ return ok(await client.get(siteId, `snippets/${encodeURIComponent(args.snippet_id)}`));
70
+ }
71
+ catch (error) {
72
+ return fail(error);
73
+ }
74
+ },
75
+ },
76
+ {
77
+ name: 'update_snippet',
78
+ description: 'Create or replace a whole live snippet; it is live within about a minute, without publishing. Send every field you keep: what is left out is removed. ' +
79
+ 'Pass the updated_at from read_snippet as expected_updated_at (or "" to create one that must not exist yet); a save made in between is refused with 409. ' +
80
+ 'Example (the week\'s lunch): { snippet_id: "lunch", name: "Lunch", kind: "dated", format: "html", entries: [{ weekday: "monday", content: "<p>Pea soup and pancakes</p>" }, …], fallback: "<p>No lunch served today</p>" }. ' +
81
+ 'Then show it with a `core/snippet` block { snippet: "lunch" } if no page shows it yet. ' + SNIPPET_MODEL,
82
+ inputSchema: {
83
+ snippet_id: idParam,
84
+ name: z.string().describe('The name editors see, for example "Today\'s lunch".'),
85
+ kind: z.enum(['html', 'text', 'dated']),
86
+ format: z.enum(['html', 'text']).optional().describe('dated snippets: whether entries are HTML (default) or plain text.'),
87
+ content: z.string().optional().describe('html and text snippets: the content.'),
88
+ entries: z.array(entryShape).optional().describe('dated snippets: entries by weekday or date, at most 400.'),
89
+ fallback: z.string().optional().describe('dated snippets: shown on a day without an entry.'),
90
+ expected_updated_at: z.string().nullable().optional().describe('The updated_at you read; "" or null for a new snippet.'),
91
+ },
92
+ handler: async (args, { client, siteId }) => {
93
+ const { snippet_id: id, expected_updated_at: expected, ...snippet } = args;
94
+ try {
95
+ return ok(await client.put(siteId, `snippets/${encodeURIComponent(id)}`, { ...snippet, ...(expected !== undefined ? { expected_updated_at: expected } : {}) }));
96
+ }
97
+ catch (error) {
98
+ return snippetFailure(error);
99
+ }
100
+ },
101
+ },
102
+ {
103
+ name: 'delete_snippet',
104
+ description: 'Delete a live snippet and its public file. A `core/snippet` block that still shows it keeps the value of the latest publication until the page is published again; remove the block too. Pass expected_updated_at to refuse deleting a snippet changed since you read it.',
105
+ inputSchema: {
106
+ snippet_id: idParam,
107
+ expected_updated_at: z.string().optional().describe('The updated_at you read.'),
108
+ },
109
+ handler: async (args, { client, siteId }) => {
110
+ try {
111
+ return ok(await client.del(siteId, `snippets/${encodeURIComponent(args.snippet_id)}`, args.expected_updated_at !== undefined ? { expected_updated_at: args.expected_updated_at } : undefined));
112
+ }
113
+ catch (error) {
114
+ return snippetFailure(error);
115
+ }
116
+ },
117
+ },
118
+ ];
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.120';
11
+ export const VERSION = '0.45.122';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@typeroll/mcp-server",
3
3
  "mcpName": "io.github.Typeroll/typeroll",
4
- "version": "0.45.120",
4
+ "version": "0.45.122",
5
5
  "description": "Typeroll CMS MCP server \u2013 connect AI agents to the REST API to manage content and publish static websites.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -22,8 +22,10 @@ use `color-mix(in srgb, var(--color-surface) 92%, var(--color-primary))`.
22
22
  For an additional role not in the native palette, define a named site style
23
23
  or a site CSS variable derived from existing palette variables, and document it.
24
24
 
25
- Choose `heading`, `body` or `mono` for fonts. Font families belong only in the
26
- site's `fonts` settings. Use type-size steps `xs`, `sm`, `md`, `lg`, `xl`, `2xl`,
25
+ Choose a font role for fonts: `heading`, `body`, `mono`, and from render
26
+ version 15 `display` (large headings and heroes) and `accent` (eyebrows and
27
+ quotes). Font families belong only in the site's `fonts` settings, set with
28
+ `set_site_fonts`; styles and blocks choose a role, never a family. Use type-size steps `xs`, `sm`, `md`, `lg`, `xl`, `2xl`,
27
29
  `3xl`; spacing `none`, `xs`, `sm`, `md`, `lg`, `xl`; line height `tight`, `snug`,
28
30
  `normal`, `relaxed`, `loose`. Presentation fields accept responsive maps of these
29
31
  names, for example `font_size_px: {mobile: "md", desktop: "lg"}`. Read the field
@@ -128,7 +130,19 @@ instead (light grey on white = bad; dark grey on white = fine).
128
130
 
129
131
  ## Step 3 — Choose typefaces
130
132
 
131
- Pick from high-quality Google Fonts pairings:
133
+ Check every family with `search_fonts` before you choose it: it lists the
134
+ catalog families with their weights, italics and variable axis, and the
135
+ site's own uploaded and service families (`library`, `services`). Filter with
136
+ `category`, `variable`, `italic` and `latin_ext` (Polish, Czech, Turkish…;
137
+ Nordic and German letters are in every family).
138
+
139
+ If the brand already has fonts, use them: an uploaded font file
140
+ (`upload_font`, only after the user confirms the licence allows use on the
141
+ website) or a font service in `set_site_fonts` `services` (an Adobe Fonts kit,
142
+ which always loads from Adobe because its licence forbids self-hosting, or a
143
+ Bunny Fonts or Fontshare stylesheet). Mention a service's CDN to the owner:
144
+ the visitor's browser contacts it. Otherwise pick from high-quality Google
145
+ Fonts pairings:
132
146
 
133
147
  | Heading | Body | Mood |
134
148
  |---|---|---|
@@ -141,12 +155,18 @@ Pick from high-quality Google Fonts pairings:
141
155
  | Libre Baskerville | Libre Franklin | Traditional, trustworthy |
142
156
 
143
157
  Same font for heading and body is fine if it has enough weight variation
144
- (Inter at 700 + 400 works well).
158
+ (Inter at 700 + 400 works well). A third voice for heroes or quotes goes in
159
+ the `display` or `accent` role (render version 15), not in custom CSS.
145
160
 
146
161
  Use the exact Google Fonts family name ("Plus Jakarta Sans", not "plus
147
162
  jakarta"). Fonts are self-hosted by default (`fonts.delivery: "self_hosted"`,
148
163
  Core 0.2.130+): when a publication is frozen, Typeroll copies the Google Fonts
149
- CSS and woff2 files (weights 400–700) into the build. The site serves
164
+ CSS and woff2 files into the build. From render version 15 it copies only the
165
+ weights and italics the site uses (styles, block weights, bold and italic
166
+ text) and one file for a variable family; before that, 400–700. Do not list
167
+ weights for normal use: add `load` (for example
168
+ `{ "heading": { "weights": [800] } }`) only for weights nothing in the site
169
+ uses, such as a weight in custom CSS. The site serves
150
170
  `/_typeroll/fonts/fonts.css` and the files under `/_typeroll/fonts/`; visitors
151
171
  never contact `fonts.googleapis.com` or `fonts.gstatic.com`, before or after
152
172
  consent. A family Google does not serve is skipped without an error and the
@@ -160,15 +180,19 @@ sites; 15 for dense dashboards.
160
180
 
161
181
  ## Step 4 — Apply to the site
162
182
 
163
- One call sets everything:
183
+ Set the fonts, then the colours and base size:
164
184
 
165
185
  ```
186
+ set_site_fonts { "heading": "...", "body": "...", "display": "..." }
166
187
  update_site_settings {
167
188
  "colors": { ...all 7 tokens },
168
- "fonts": { "heading": "...", "body": "...", "size_base": 16 }
189
+ "fonts": { "size_base": 16 }
169
190
  }
170
191
  ```
171
192
 
193
+ `set_site_fonts` answers with `warnings` for a family that is not in the
194
+ catalog, the Fonts library or a font service: fix the name before going on.
195
+
172
196
  The brand lives in three places that editors can see and change: the
173
197
  `colors` and `fonts` settings, the design scales, and named Styles (Step 5b).
174
198
  Font families are set only in `fonts`; the platform loads each family once.
@@ -178,7 +202,8 @@ Never load a font again through `custom_css` (`@import`, `@font-face`) or
178
202
  Read back to confirm: `read_site_settings`.
179
203
 
180
204
  **Inside a redesign branch, scope the brand to the branch** — pass
181
- `version="<branch>"` on `update_site_settings` (and `read_site_settings`).
205
+ `version="<branch>"` on `set_site_fonts`, `update_site_settings` (and
206
+ `read_site_settings`). Uploaded font files belong to the site, not the branch.
182
207
  Colors / fonts / logo / custom_css then live on the branch (copy-on-write,
183
208
  chain-fallback to main for anything you don't override) and don't touch the
184
209
  live site until you `merge_branch`. This is the correct way to rebrand on a
@@ -365,10 +390,12 @@ Open in browser. Check:
365
390
  The preview loads fonts from Google inside a sandbox, so it proves nothing
366
391
  about font delivery. After an authorized publish, check the published
367
392
  temporary/test address:
368
- - `/_typeroll/fonts/fonts.css` has `@font-face` rules for every chosen family.
369
- A comment instead of rules means Google did not serve that name: fix it.
393
+ - `/_typeroll/fonts/fonts.css` has `@font-face` rules for every chosen Google
394
+ or uploaded family. A comment instead of rules means Google did not serve
395
+ that name: fix it. A service family loads from its CDN stylesheet instead.
370
396
  - Every font file `url(...)` in it returns 200.
371
- - No request goes to `fonts.googleapis.com` or `fonts.gstatic.com`.
397
+ - No request goes to `fonts.googleapis.com` or `fonts.gstatic.com` (requests
398
+ to a configured font service's CDN are expected).
372
399
  - After `await document.fonts.ready`, `[...document.fonts]` has a `loaded`
373
400
  face for each family, and headings/body compute to that family.
374
401
 
@@ -10,6 +10,16 @@ for the current native header tree: `template/site_logo`, `core/navigation_menu`
10
10
  and `core/navigation_links`. Use the menu's dialog/drawer rather than an inline
11
11
  mobile expansion that moves the logo. Existing `core/navigation` remains supported.
12
12
 
13
+ The links come from the site's **menus** (`list_menus`), not from the header.
14
+ A `core/navigation_links` block with `source: "menu"` and
15
+ `menu: "location:primary"` shows the menu in the `primary` location; the
16
+ footer shows `location:footer`. Page items link by `page_id`, so renames and
17
+ moves follow, and items with `children` get submenus. A new site has a
18
+ `primary` menu (Home, `auto_add_pages` on) and a `footer` menu. Menu-sourced
19
+ blocks need render version 15: read `read_site_settings` → `render.version`
20
+ and raise it with `tr-upgrade-rendering` if it is lower. Below 15, or for a
21
+ one-off link list, use inline `links` instead.
22
+
13
23
  ## Preconditions
14
24
 
15
25
  1. Read `get_site_capabilities`, `read_site_settings`, `list_partials`, and
@@ -20,6 +30,21 @@ mobile expansion that moves the logo. Existing `core/navigation` remains support
20
30
  3. Read the existing header/footer before replacing anything. Work in a branch
21
31
  for redesigns and preview at desktop, 390 px, keyboard-only, and 200% zoom.
22
32
 
33
+ ## Menus first
34
+
35
+ 1. `list_menus`. Make sure one menu fills `primary` and one fills `footer`;
36
+ create missing ones with `update_menu` (`locations: ["primary"]`).
37
+ 2. Build the link tree with `update_menu` (read it first and pass
38
+ `expected_updated_at`) or `add_menu_item`: `type: "page"` with the
39
+ `page_id` from `list_pages` for every Page, `type: "children"` with a
40
+ label for an automatic submenu of a Page's children, `type: "url"` only for
41
+ external addresses or anchors, and `type: "heading"` for a column title in
42
+ a wide submenu. At most 3 levels; keep the top level to a handful of items.
43
+ 3. Keep `auto_add_pages` on while the site is being built if every new
44
+ top-level Page belongs in the header; turn it off once the menu is curated.
45
+ 4. Use labels in the site's language. A Page item's label is the Page title
46
+ unless the item sets `label`.
47
+
23
48
  ## Header tree
24
49
 
25
50
  Stage this tree with `update_partial partial_id="header" patch={blocks:[...]}
@@ -65,21 +90,9 @@ read it back. Localize both accessible labels and every link label.
65
90
  {
66
91
  "type": "core/navigation_links",
67
92
  "data": {
68
- "direction": "row",
69
- "links": [
70
- {
71
- "label": "Home",
72
- "href": "/"
73
- },
74
- {
75
- "label": "About",
76
- "href": "/about/"
77
- },
78
- {
79
- "label": "Contact",
80
- "href": "/contact/"
81
- }
82
- ]
93
+ "source": "menu",
94
+ "menu": "location:primary",
95
+ "direction": "row"
83
96
  }
84
97
  }
85
98
  ],
@@ -87,21 +100,9 @@ read it back. Localize both accessible labels and every link label.
87
100
  {
88
101
  "type": "core/navigation_links",
89
102
  "data": {
90
- "direction": "column",
91
- "links": [
92
- {
93
- "label": "Home",
94
- "href": "/"
95
- },
96
- {
97
- "label": "About",
98
- "href": "/about/"
99
- },
100
- {
101
- "label": "Contact",
102
- "href": "/contact/"
103
- }
104
- ]
103
+ "source": "menu",
104
+ "menu": "location:primary",
105
+ "direction": "column"
105
106
  }
106
107
  }
107
108
  ]
@@ -115,6 +116,12 @@ read it back. Localize both accessible labels and every link label.
115
116
  ```
116
117
 
117
118
  The first slot is desktop; the second is the optional mobile composition.
119
+ Both show the same `primary` menu; a separate `location:mobile` menu is only
120
+ for a site whose mobile navigation really differs. `submenus` defaults to
121
+ `auto`: a dropdown in the desktop row, an accordion in the mobile column. Set
122
+ `dropdown`, `accordion`, `expanded` or `none` to override it. Verify that
123
+ submenu buttons open with Enter/Space, close with Escape and return focus, and
124
+ that dropdown panels do not overflow the viewport at 1024 px.
118
125
  The default is drawer below 1024 px and inline from 1024 px. For responsive
119
126
  link fields use matching `responsive_breakpoints` (tablet 768, laptop 1024,
120
127
  desktop 1280, wide 1536); do not independently hide all links at the menu boundary.
@@ -142,8 +149,10 @@ so a partner banner built from tabs can mark its links the same way.
142
149
 
143
150
  ## Footer tree and consent
144
151
 
145
- Use an accessible footer navigation landmark and `core/navigation_links`, not
146
- a second header drawer. If the footer has running about text, give it a separate,
152
+ Use an accessible footer navigation landmark and `core/navigation_links` with
153
+ `source: "menu"`, `menu: "location:footer"` and `submenus: "expanded"` (or one
154
+ block per footer column, each showing its own menu by id), not a second header
155
+ drawer. If the footer has running about text, give it a separate,
147
156
  wider column beside a nested link grid. An equal four-column grid is rarely a
148
157
  good fit for one dense paragraph and three short link lists. Start with
149
158
  `core/columns` ratio `1-2`, put flow containers inside the slots, and tune the
@@ -196,6 +205,8 @@ report, not a reason to let the block silently disappear.
196
205
  - Header and footer landmarks exist exactly once around their content.
197
206
  - Logo is fully visible, keeps its aspect ratio, has useful alt text, and links home.
198
207
  - Current-page state and localized navigation labels are correct.
208
+ - Navigation links come from menus (`source: "menu"`); every Page item uses
209
+ `page_id`, and the publication reports no menu warnings.
199
210
  - Mobile disclosure is keyboard accessible and does not trap focus.
200
211
  - No tenant CSS is required for spacing, focus, wrapping, or the narrow layout.
201
212
  - Preview and a hosted static build match before promotion.
@@ -228,6 +228,17 @@ composition. The server-rendered landmark, current-page state, no-JS links,
228
228
  mobile disclosure, focus treatment, and responsive behavior are Core
229
229
  contracts rather than tenant CSS/JavaScript.
230
230
 
231
+ **Navigation links live in menus.** A new site already has a `primary` menu
232
+ (Home, `auto_add_pages` on, so new top-level published Pages join it) and a
233
+ `footer` menu; check with `list_menus`. Point the header's
234
+ `core/navigation_links` at `source: "menu"`, `menu: "location:primary"` and the
235
+ footer's at `location:footer` (render version 15; raise it first with
236
+ `tr-upgrade-rendering` if `read_site_settings` → `render.version` is lower).
237
+ After creating the Pages, curate the menus with `add_menu_item` or
238
+ `update_menu`: Page items by `page_id`, a `children` item for an automatic
239
+ submenu, `url` items only for external addresses. Do not type Page URLs into
240
+ inline `links`; they do not follow renames.
241
+
231
242
  Stage the complete tree with `update_partial partial_id="header"
232
243
  patch={blocks:[...]} save=true`, then call `set_partial_mode partial_id="header"
233
244
  to="blocks"`. Repeat for the footer and read both partials back. The inactive