@nysds/mcp-server 1.20.1 → 1.21.1

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.
@@ -2,8 +2,150 @@
2
2
  * Utility Tools
3
3
  *
4
4
  * MCP tools for NYSDS utility classes.
5
+ *
6
+ * The class lists this tool returns are RENDERED from the scale constants
7
+ * below. Those constants mirror the Sass sources that actually generate the
8
+ * stylesheet:
9
+ *
10
+ * - packages/styles/src/utilities/_config.scss ($spacing, $opacity-values,
11
+ * $zindex-values, $display-values,
12
+ * $breakpoints, $flex-columns)
13
+ * - packages/styles/src/utilities/_layout-grid.scss ($responsive-gap-suffixes)
14
+ * - packages/styles/src/core/typography.scss ($body-sizes, $ui-sizes,
15
+ * $ui-underline-styles, $display-sizes)
16
+ *
17
+ * Do not hand-write a class name into the markdown. Add it to a scale and let
18
+ * the renderer emit it, so a name can never appear here without a scale entry
19
+ * behind it.
20
+ *
21
+ * `npm run verify:utility-docs` compiles the stylesheet and asserts that every
22
+ * class this tool names exists in it. Run it after touching any scale.
5
23
  */
6
24
  import { z } from "zod";
25
+ /**
26
+ * `$spacing` in _config.scss. The utilities emit literal pixel values, not
27
+ * `var(--nys-space-*)` references, so the rendered docs quote pixels.
28
+ *
29
+ * There is deliberately no `0` key: `nys-margin-0` and `nys-padding-0` are
30
+ * not generated.
31
+ */
32
+ const SPACING = [
33
+ ["1px", "1px"],
34
+ ["2px", "2px"],
35
+ ["50", "4px", "0.25rem"],
36
+ ["100", "8px", "0.5rem"],
37
+ ["150", "12px", "0.75rem"],
38
+ ["200", "16px", "1rem"],
39
+ ["250", "20px", "1.25rem"],
40
+ ["300", "24px", "1.5rem"],
41
+ ["400", "32px", "2rem"],
42
+ ["500", "40px", "2.5rem"],
43
+ ["600", "48px", "3rem"],
44
+ ["700", "56px", "3.5rem"],
45
+ ["800", "64px", "4rem"],
46
+ ["1200", "96px", "6rem"],
47
+ ];
48
+ /** `$responsive-gap-suffixes` in _layout-grid.scss. */
49
+ const RESPONSIVE_GAP_KEYS = [
50
+ "400",
51
+ "500",
52
+ "600",
53
+ "700",
54
+ "800",
55
+ "1200",
56
+ ];
57
+ /** `$opacity-values` in _config.scss. */
58
+ const OPACITY = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
59
+ /** `$zindex-values` in _config.scss. */
60
+ const ZINDEX = [
61
+ ["0", "0"],
62
+ ["100", "100"],
63
+ ["200", "200"],
64
+ ["300", "300"],
65
+ ["400", "400"],
66
+ ["500", "500"],
67
+ ["auto", "auto"],
68
+ ["bottom", "-100"],
69
+ ["top", "99999"],
70
+ ];
71
+ /** `$display-values` in _config.scss. */
72
+ const DISPLAY = [
73
+ "none",
74
+ "block",
75
+ "inline",
76
+ "inline-block",
77
+ "flex",
78
+ "inline-flex",
79
+ "table",
80
+ "table-cell",
81
+ "table-row",
82
+ ];
83
+ /** `$breakpoints` in _config.scss. */
84
+ const BREAKPOINTS = [
85
+ ["mobile-lg", "30em", "480px"],
86
+ ["tablet", "40em", "640px"],
87
+ ["desktop", "64em", "1024px"],
88
+ ["widescreen", "87.5em", "1400px"],
89
+ ];
90
+ /** Typography scales in core/typography.scss. */
91
+ const HEADING_LEVELS = [1, 2, 3, 4, 5, 6];
92
+ const BODY_SIZES = ["xs", "sm", "md"];
93
+ const UI_SIZES = ["xs", "sm", "md", "lg", "xl"];
94
+ const DISPLAY_SIZES = ["sm", "md", "lg", "xl"];
95
+ /** `$ui-underline-styles` — only these size/weight pairs are generated. */
96
+ const UI_UNDERLINE = [
97
+ ["sm", "semibold"],
98
+ ["md", "semibold"],
99
+ ["md", "regular"],
100
+ ["lg", "semibold"],
101
+ ];
102
+ const FLEX_ALIGN = [
103
+ "start",
104
+ "center",
105
+ "end",
106
+ "baseline",
107
+ "stretch",
108
+ ];
109
+ const FLEX_JUSTIFY = [
110
+ "start",
111
+ "center",
112
+ "end",
113
+ "space-between",
114
+ "space-around",
115
+ "space-evenly",
116
+ ];
117
+ /* ------------------------------------------------------------------ *
118
+ * Renderers
119
+ * ------------------------------------------------------------------ */
120
+ const spacingKeys = SPACING.map(([key]) => key);
121
+ const bullets = (lines) => lines.join("\n");
122
+ const inlineList = (items) => items.map((i) => `\`${i}\``).join(", ");
123
+ const spacingValueRows = bullets(SPACING.map(([key, px, rem]) => `- \`${key}\` - ${px}${rem ? ` (${rem})` : ""}`));
124
+ const gapValueRows = bullets(SPACING.map(([key, px, rem]) => {
125
+ const size = `${px}${rem ? ` (${rem})` : ""}`;
126
+ // Gaps in the responsive set are capped at 2rem below 64em. For 400 the
127
+ // cap equals the full value, so only note it where it actually differs.
128
+ const capped = RESPONSIVE_GAP_KEYS.includes(key) && Number.parseInt(px, 10) > 32;
129
+ return capped
130
+ ? `- \`nys-grid-gap-${key}\` - ${size} at 64em and up, capped at 32px (2rem) below that`
131
+ : `- \`nys-grid-gap-${key}\` - ${size}`;
132
+ }));
133
+ const opacityRows = bullets(OPACITY.map((v) => {
134
+ const label = v === 0
135
+ ? "Fully transparent"
136
+ : v === 100
137
+ ? "Fully opaque"
138
+ : `${v}% opaque`;
139
+ return `- \`nys-opacity-${v}\` - opacity: ${v / 100} (${label})`;
140
+ }));
141
+ const zindexRows = bullets(ZINDEX.map(([name, value]) => `- \`nys-z-${name}\` - z-index: ${value}`));
142
+ const displayRows = bullets(DISPLAY.map((v) => `- \`nys-display-${v}\` - display: ${v}`));
143
+ const breakpointRows = bullets(BREAKPOINTS.map(([name, em, px]) => `- \`nys-${name}:\` - ${em} (${px}) and up`));
144
+ const headingRows = bullets(HEADING_LEVELS.map((n) => `- \`nys-font-h${n}\` - Heading level ${n} type style`));
145
+ const underlineRows = bullets(UI_UNDERLINE.flatMap(([size, weight]) => [
146
+ `- \`nys-font-ui-${size}-${weight}-underline\` - UI ${size} ${weight}, 7% underline`,
147
+ `- \`nys-font-ui-${size}-${weight}-underline-strong\` - UI ${size} ${weight}, 14% underline`,
148
+ ]));
7
149
  const UTILITY_DOCS = {
8
150
  grid: `## Grid System
9
151
 
@@ -26,20 +168,11 @@ NYSDS provides a 12-column responsive grid system.
26
168
  - \`nys-grid-col-fill\` - Column fills remaining space
27
169
 
28
170
  ### Gap Classes
29
- - \`nys-grid-gap-0\` - No gap
30
- - \`nys-grid-gap-2px\` - 2px gap
31
- - \`nys-grid-gap-50\` - 4px gap (0.25rem)
32
- - \`nys-grid-gap-100\` - 8px gap (0.5rem)
33
- - \`nys-grid-gap-150\` - 12px gap (0.75rem)
34
- - \`nys-grid-gap-200\` - 16px gap (1rem)
35
- - \`nys-grid-gap-250\` - 20px gap (1.25rem)
36
- - \`nys-grid-gap-300\` - 24px gap (1.5rem)
37
- - \`nys-grid-gap-400\` - 32px gap (2rem)
38
- - \`nys-grid-gap-500\` - 40px gap (2.5rem)
39
- - \`nys-grid-gap-600\` - 48px gap (3rem)
40
- - \`nys-grid-gap-700\` - 56px gap (3.5rem)
41
- - \`nys-grid-gap-800\` - 64px gap (4rem)
42
- - \`nys-grid-gap-1200\` - 96px gap (6rem)
171
+ Gap classes apply to \`nys-grid-row\`. Use \`nys-grid-gap-x-*\` or
172
+ \`nys-grid-gap-y-*\` for a single axis. There is no \`nys-grid-gap-0\`; omit
173
+ the gap class instead.
174
+
175
+ ${gapValueRows}
43
176
 
44
177
  ### Offset Classes
45
178
  - \`nys-grid-offset-[1-12]\` - Offset column by 1-12 columns
@@ -61,6 +194,7 @@ NYSDS provides a 12-column responsive grid system.
61
194
 
62
195
  ### Display
63
196
  - \`nys-display-flex\` - Sets display: flex
197
+ - \`nys-display-inline-flex\` - Sets display: inline-flex
64
198
 
65
199
  ### Direction
66
200
  - \`nys-flex-row\` - Row direction (default)
@@ -71,21 +205,26 @@ NYSDS provides a 12-column responsive grid system.
71
205
  - \`nys-flex-no-wrap\` - Prevent wrapping
72
206
 
73
207
  ### Alignment (Cross Axis)
74
- - \`nys-flex-align-start\` - Align items to start
75
- - \`nys-flex-align-center\` - Align items to center
76
- - \`nys-flex-align-end\` - Align items to end
77
- - \`nys-flex-align-stretch\` - Stretch items to fill
208
+ ${bullets(FLEX_ALIGN.map((v) => `- \`nys-flex-align-${v}\` - align-items: ${v}`))}
209
+
210
+ ### Self Alignment
211
+ ${bullets(FLEX_ALIGN.map((v) => `- \`nys-flex-align-self-${v}\` - align-self: ${v}`))}
78
212
 
79
213
  ### Justification (Main Axis)
80
- - \`nys-flex-justify-start\` - Justify to start
81
- - \`nys-flex-justify-center\` - Justify to center
82
- - \`nys-flex-justify-end\` - Justify to end
214
+ ${bullets(FLEX_JUSTIFY.map((v) => `- \`nys-flex-justify-${v}\` - justify-content: ${v}`))}
83
215
 
84
216
  ### Flex Sizing
85
217
  - \`nys-flex-[1-12]\` - Flex grow/shrink values
86
218
  - \`nys-flex-auto\` - flex: auto (grow and shrink)
87
219
  - \`nys-flex-fill\` - Fill available space
88
220
 
221
+ ### Gaps
222
+ Available on the spacing scale: ${inlineList(spacingKeys)}
223
+
224
+ - \`nys-flex-gap-{value}\` - gap on both axes
225
+ - \`nys-flex-row-gap-{value}\` - row-gap only
226
+ - \`nys-flex-column-gap-{value}\` - column-gap only
227
+
89
228
  ### Example: Button Group
90
229
  \`\`\`html
91
230
  <div class="nys-display-flex nys-flex-justify-end nys-flex-gap-200">
@@ -111,21 +250,11 @@ Pattern: \`nys-{property}-{direction}-{value}\`
111
250
  - (none) - All sides
112
251
 
113
252
  ### Values
114
- - \`0\` - 0
115
- - \`1px\` - 1px
116
- - \`2px\` - 2px
117
- - \`50\` - var(--nys-space-50) = 0.125rem (2px)
118
- - \`100\` - var(--nys-space-100) = 0.25rem (4px)
119
- - \`150\` - var(--nys-space-150) = 0.375rem (6px)
120
- - \`200\` - var(--nys-space-200) = 0.5rem (8px)
121
- - \`250\` - var(--nys-space-250) = 0.625rem (10px)
122
- - \`300\` - var(--nys-space-300) = 0.75rem (12px)
123
- - \`400\` - var(--nys-space-400) = 1rem (16px)
124
- - \`500\` - var(--nys-space-500) = 1.25rem (20px)
125
- - \`600\` - var(--nys-space-600) = 1.5rem (24px)
126
- - \`700\` - var(--nys-space-700) = 2rem (32px)
127
- - \`800\` - var(--nys-space-800) = 2.5rem (40px)
128
- - \`1200\` - var(--nys-space-1200) = 4rem (64px)
253
+ The utilities emit literal pixel values. There is no zero and no \`auto\`
254
+ value — \`nys-margin-0\` and \`nys-padding-0\` are not generated. Omit the
255
+ class instead.
256
+
257
+ ${spacingValueRows}
129
258
 
130
259
  ### Examples
131
260
  \`\`\`html
@@ -140,11 +269,7 @@ Pattern: \`nys-{property}-{direction}-{value}\`
140
269
  \`\`\``,
141
270
  display: `## Display Utilities
142
271
 
143
- - \`nys-display-none\` - Hide element
144
- - \`nys-display-block\` - Block display
145
- - \`nys-display-inline\` - Inline display
146
- - \`nys-display-inline-block\` - Inline-block display
147
- - \`nys-display-flex\` - Flex display
272
+ ${displayRows}
148
273
 
149
274
  ### Example: Hide on Mobile
150
275
  \`\`\`html
@@ -154,46 +279,57 @@ Pattern: \`nys-{property}-{direction}-{value}\`
154
279
  \`\`\``,
155
280
  opacity: `## Opacity Utilities
156
281
 
157
- - \`nys-opacity-0\` - Fully transparent
158
- - \`nys-opacity-25\` - 25% opacity
159
- - \`nys-opacity-50\` - 50% opacity
160
- - \`nys-opacity-75\` - 75% opacity
161
- - \`nys-opacity-100\` - Fully opaque`,
282
+ The scale steps by 10 — there is no \`nys-opacity-25\` or \`nys-opacity-75\`.
283
+
284
+ ${opacityRows}`,
162
285
  zindex: `## Z-Index Utilities
163
286
 
164
- - \`nys-z-0\` - z-index: 0
165
- - \`nys-z-10\` - z-index: 10
166
- - \`nys-z-20\` - z-index: 20
167
- - \`nys-z-30\` - z-index: 30
168
- - \`nys-z-40\` - z-index: 40
169
- - \`nys-z-50\` - z-index: 50
170
- - \`nys-z-auto\` - z-index: auto`,
287
+ The scale steps by 100, not by 10. \`nys-z-10\` through \`nys-z-50\` do not
288
+ exist — the comparable values are \`nys-z-100\` through \`nys-z-500\`.
289
+
290
+ ${zindexRows}`,
171
291
  typography: `## Typography Utilities
172
292
 
173
- ### Text Alignment
174
- - \`nys-text-left\` - Left align text
175
- - \`nys-text-center\` - Center align text
176
- - \`nys-text-right\` - Right align text
177
-
178
- ### Font Weight
179
- - \`nys-font-normal\` - Normal weight
180
- - \`nys-font-medium\` - Medium weight
181
- - \`nys-font-semibold\` - Semibold weight
182
- - \`nys-font-bold\` - Bold weight
183
-
184
- ### Text Transform
185
- - \`nys-text-uppercase\` - Uppercase text
186
- - \`nys-text-lowercase\` - Lowercase text
187
- - \`nys-text-capitalize\` - Capitalize text`,
293
+ NYSDS ships a role-based type scale, not atomic text modifiers. Each class
294
+ sets font-family, size, and line-height together, matching the text styles in
295
+ the NYSDS Foundations Figma file.
296
+
297
+ There are NO text-alignment, text-transform, or font-weight utilities
298
+ (no \`nys-text-center\`, no \`nys-font-bold\`). Use CSS for those.
299
+
300
+ ### Headings
301
+ ${headingRows}
302
+
303
+ ### Body
304
+ ${bullets(BODY_SIZES.map((s) => `- \`nys-font-body-${s}\` - Body text, ${s}`))}
305
+
306
+ ### UI
307
+ ${bullets(UI_SIZES.map((s) => `- \`nys-font-ui-${s}\` - UI text, ${s}`))}
308
+
309
+ ### UI Underline
310
+ ${underlineRows}
311
+
312
+ ### Display
313
+ ${bullets(DISPLAY_SIZES.map((s) => `- \`nys-font-display-${s}\` - Display text, ${s}`))}
314
+
315
+ ### Agency
316
+ - \`nys-font-agency\` - Agency / application title
317
+
318
+ ### Font family hooks
319
+ These are attribute selectors, not standalone classes. They set only
320
+ font-family on any element whose class list contains the substring, so pair
321
+ them with a size class:
322
+
323
+ - \`[class*="nys-font-mono-"]\` - monospace family
324
+ - \`[class*="nys-font-sans-"]\` - sans-serif family
325
+ - \`[class*="nys-font-serif-"]\` - serif family`,
188
326
  responsive: `## Responsive Breakpoints
189
327
 
190
328
  NYSDS utility classes support responsive prefixes.
191
329
 
192
330
  ### Breakpoints
193
331
  - (no prefix) - All screen sizes (mobile-first)
194
- - \`nys-mobile-lg:\` - 30em (480px) and up
195
- - \`nys-tablet:\` - 40em (640px) and up
196
- - \`nys-desktop:\` - 64em (1024px) and up
332
+ ${breakpointRows}
197
333
 
198
334
  ### Pattern
199
335
  \`nys-{breakpoint}:nys-{class}\`
@@ -236,6 +372,35 @@ When adding spacing around NYSDS components, use utility classes rather than wra
236
372
  <nys-button label="Submit"></nys-button>
237
373
  \`\`\``,
238
374
  };
375
+ /**
376
+ * Classes the reference deliberately names in order to say they do NOT exist.
377
+ *
378
+ * These are the names people reach for out of habit from other frameworks.
379
+ * Saying so explicitly is more useful than silence, but it means the docs
380
+ * mention class names the stylesheet does not define, which would otherwise
381
+ * trip the verifier.
382
+ *
383
+ * `verify-utility-docs.mjs` asserts each of these is genuinely absent, so if
384
+ * NYSDS ever adds one, the stale warning fails the check instead of quietly
385
+ * misinforming people.
386
+ */
387
+ const KNOWN_ABSENT = [
388
+ "nys-text-center",
389
+ "nys-font-bold",
390
+ "nys-z-10",
391
+ "nys-z-50",
392
+ "nys-opacity-25",
393
+ "nys-opacity-75",
394
+ "nys-margin-0",
395
+ "nys-padding-0",
396
+ "nys-grid-gap-0",
397
+ ];
398
+ /**
399
+ * Exported so `src/scripts/verify-utility-docs.mjs` can assert that every class
400
+ * named in this reference exists in the compiled stylesheet — and that every
401
+ * class named in KNOWN_ABSENT still does not.
402
+ */
403
+ export { UTILITY_DOCS, KNOWN_ABSENT };
239
404
  export function registerUtilityTools(server) {
240
405
  // get_utility_classes - Comprehensive utility class reference
241
406
  server.tool("get_utility_classes", "Get NYSDS utility class reference for layout, spacing, and styling", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nysds/mcp-server",
3
- "version": "1.20.1",
3
+ "version": "1.21.1",
4
4
  "description": "MCP server for the New York State Design System. Exposes components, tokens, and documentation to AI assistants.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,8 +30,8 @@
30
30
  "zod": "^3.25"
31
31
  },
32
32
  "devDependencies": {
33
- "@nysds/styles": "^1.20.1",
34
- "@nysds/tokens": "^1.20.1",
33
+ "@nysds/styles": "^1.21.1",
34
+ "@nysds/tokens": "^1.21.1",
35
35
  "@types/node": "^22.0.0",
36
36
  "typescript": "^5.9.3"
37
37
  },