@czi-sds/mcp 0.2.1 → 0.2.2
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/dist/stdio.js +331 -16
- package/package.json +2 -2
package/dist/stdio.js
CHANGED
|
@@ -3,9 +3,8 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import fs from 'fs';
|
|
6
|
-
import path
|
|
6
|
+
import path from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
-
import { readFile } from 'fs/promises';
|
|
9
8
|
|
|
10
9
|
var server = new McpServer({
|
|
11
10
|
name: "sds-mcp",
|
|
@@ -124,6 +123,37 @@ async function fetchComponentPropsStorybook(component) {
|
|
|
124
123
|
);
|
|
125
124
|
}
|
|
126
125
|
}
|
|
126
|
+
async function fetchTailwindTokens() {
|
|
127
|
+
try {
|
|
128
|
+
const possiblePaths = [
|
|
129
|
+
path.join(dirname, "../../data/tailwind.json"),
|
|
130
|
+
// From src/lib in dev
|
|
131
|
+
path.join(dirname, "../data/tailwind.json"),
|
|
132
|
+
// From dist in prod
|
|
133
|
+
path.join(process.cwd(), "data/tailwind.json")
|
|
134
|
+
// From current working directory
|
|
135
|
+
];
|
|
136
|
+
let dataPath = "";
|
|
137
|
+
for (const p of possiblePaths) {
|
|
138
|
+
if (fs.existsSync(p)) {
|
|
139
|
+
dataPath = p;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!dataPath) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"Component list not found in any expected location. Please run 'yarn generate:tailwind-tokens' first."
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const fileContent = fs.readFileSync(dataPath, "utf-8");
|
|
149
|
+
const tailwindTokens = JSON.parse(fileContent);
|
|
150
|
+
return tailwindTokens;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`Failed to load tailwind tokens: ${error instanceof Error ? error.message : `Unknown error ${error}`}`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
127
157
|
|
|
128
158
|
// src/tools/get-component-props.ts
|
|
129
159
|
var getComponentPropsTool = {
|
|
@@ -254,13 +284,293 @@ var getComponentPropsStorybookTool = {
|
|
|
254
284
|
);
|
|
255
285
|
}
|
|
256
286
|
};
|
|
287
|
+
|
|
288
|
+
// src/lib/tailwind-guidance.ts
|
|
289
|
+
var TAILWIND_TOKEN_GUIDANCE = {
|
|
290
|
+
colors: {
|
|
291
|
+
category: "Colors",
|
|
292
|
+
description: "Theme-aware color tokens with light/dark mode support. Both light and dark mode colors are using the same token name. Use the dark:color-token-name to use the dark mode color.",
|
|
293
|
+
prefixes: [
|
|
294
|
+
"bg-",
|
|
295
|
+
"border-",
|
|
296
|
+
"divide-",
|
|
297
|
+
"outline-",
|
|
298
|
+
"ring-",
|
|
299
|
+
"ring-offset-",
|
|
300
|
+
"text-",
|
|
301
|
+
"placeholder-",
|
|
302
|
+
"caret-",
|
|
303
|
+
"decoration-",
|
|
304
|
+
"accent-",
|
|
305
|
+
"shadow-",
|
|
306
|
+
"fill-",
|
|
307
|
+
"stroke-",
|
|
308
|
+
"from-",
|
|
309
|
+
"via-",
|
|
310
|
+
"to-"
|
|
311
|
+
],
|
|
312
|
+
examples: [
|
|
313
|
+
{
|
|
314
|
+
description: "Basic text and background colors",
|
|
315
|
+
code: `<div className="bg-sds-color-semantic-base-background-primary dark:bg-sds-color-semantic-base-background-primary text-sds-color-semantic-base-text-primary dark:text-sds-color-semantic-base-text-primary">
|
|
316
|
+
Content with semantic colors
|
|
317
|
+
</div>`
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
description: "Dark mode with hover states",
|
|
321
|
+
code: `<button className="bg-sds-color-semantic-accent-fill-primary dark:bg-sds-color-semantic-accent-fill-primary
|
|
322
|
+
hover:bg-sds-color-semantic-accent-fill-hover dark:hover:bg-sds-color-semantic-accent-fill-hover">
|
|
323
|
+
Click me
|
|
324
|
+
</button>`
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
description: "Border and focus states",
|
|
328
|
+
code: `<input className="
|
|
329
|
+
border-sds-color-semantic-base-border-primary
|
|
330
|
+
hover:border-sds-color-semantic-base-border-primary-hover
|
|
331
|
+
focus:border-sds-color-semantic-base-border-primary-pressed
|
|
332
|
+
"/>`
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
tips: [
|
|
336
|
+
"Always use semantic colors (e.g., 'sds-color-semantic-base-background-primary') over primitive colors when possible",
|
|
337
|
+
"Include both light and dark variants for proper theme support"
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
typography: {
|
|
341
|
+
category: "Typography",
|
|
342
|
+
description: "Complete text styling presets including font, size, weight, and spacing",
|
|
343
|
+
prefixes: ["font-", "text-", "leading-", "tracking-"],
|
|
344
|
+
examples: [
|
|
345
|
+
{
|
|
346
|
+
description: "Typography presets (recommended). SDS typography tokens come in narrow and wide variants: use token-narrow on screens smaller than md, and token-wide on md and up.",
|
|
347
|
+
code: `<!-- Use typography tokens for complete text styling -->
|
|
348
|
+
<h1 className="prose-sds-title-l-700-wide">Title</h1>
|
|
349
|
+
<h1 className="prose-sds-header-xl-600-wide">Heading</h1>
|
|
350
|
+
<p className="prose-sds-body-m-500-wide">Body text</p>
|
|
351
|
+
<span className="prose-sds-caps-xxs-600-wide">SMALL CAPS TEXT</span>
|
|
352
|
+
<span className="prose-sds-tabular-xxs-600-wide">Tabular Numbers</span>
|
|
353
|
+
<span className="prose-sds-code-s-500-wide">Code</span>
|
|
354
|
+
<span className="prose-sds-link-l-500-wide">Link style</span>`
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
description: "Individual typography properties",
|
|
358
|
+
code: `<!-- Or use individual properties when needed -->
|
|
359
|
+
<p className="
|
|
360
|
+
font-sds-body
|
|
361
|
+
text-sds-body-m-400-wide
|
|
362
|
+
leading-sds-body-m-400-wide
|
|
363
|
+
tracking-sds-body-m-400-wide
|
|
364
|
+
">
|
|
365
|
+
Custom styled text
|
|
366
|
+
</p>`
|
|
367
|
+
}
|
|
368
|
+
],
|
|
369
|
+
tips: [
|
|
370
|
+
"Use 'narrow' variants for mobile/compact layouts",
|
|
371
|
+
"Use 'wide' variants for desktop/spacious layouts",
|
|
372
|
+
"Font weights: 400 (regular), 500 (medium), 600 (semibold), 700 (bold)"
|
|
373
|
+
]
|
|
374
|
+
},
|
|
375
|
+
spacing: {
|
|
376
|
+
category: "Spacing",
|
|
377
|
+
description: "Consistent spacing scale for padding, margin, and gaps",
|
|
378
|
+
prefixes: [
|
|
379
|
+
"p-",
|
|
380
|
+
"px-",
|
|
381
|
+
"py-",
|
|
382
|
+
"pt-",
|
|
383
|
+
"pr-",
|
|
384
|
+
"pb-",
|
|
385
|
+
"pl-",
|
|
386
|
+
"m-",
|
|
387
|
+
"mx-",
|
|
388
|
+
"my-",
|
|
389
|
+
"mt-",
|
|
390
|
+
"mr-",
|
|
391
|
+
"mb-",
|
|
392
|
+
"ml-",
|
|
393
|
+
"gap-",
|
|
394
|
+
"gap-x-",
|
|
395
|
+
"gap-y-",
|
|
396
|
+
"space-x-",
|
|
397
|
+
"space-y-"
|
|
398
|
+
],
|
|
399
|
+
examples: [
|
|
400
|
+
{
|
|
401
|
+
description: "Padding and margin",
|
|
402
|
+
code: `<div className="p-sds-m mx-sds-l my-sds-s">
|
|
403
|
+
Content with medium padding and different margins
|
|
404
|
+
</div>`
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
description: "Flexbox and grid gaps",
|
|
408
|
+
code: `<div className="flex gap-sds-m">
|
|
409
|
+
<div>Item 1</div>
|
|
410
|
+
<div>Item 2</div>
|
|
411
|
+
</div>
|
|
412
|
+
|
|
413
|
+
<div className="grid grid-cols-3 gap-sds-l">
|
|
414
|
+
<div>Grid item</div>
|
|
415
|
+
</div>`
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
description: "Negative margins for overlapping",
|
|
419
|
+
code: `<div className="-mt-sds-s">
|
|
420
|
+
Overlapping element
|
|
421
|
+
</div>`
|
|
422
|
+
}
|
|
423
|
+
],
|
|
424
|
+
tips: [
|
|
425
|
+
"Scale: sds-s (small), sds-default (default), sds-m (medium), sds-l (large), sds-xl (extra large)",
|
|
426
|
+
"Use consistent spacing throughout your component",
|
|
427
|
+
"Combine with responsive prefixes: sm:p-sds-m lg:p-sds-l"
|
|
428
|
+
]
|
|
429
|
+
},
|
|
430
|
+
borderRadius: {
|
|
431
|
+
category: "Border Radius",
|
|
432
|
+
description: "Corner radius values for rounded elements",
|
|
433
|
+
prefixes: [
|
|
434
|
+
"rounded-",
|
|
435
|
+
"rounded-t-",
|
|
436
|
+
"rounded-r-",
|
|
437
|
+
"rounded-b-",
|
|
438
|
+
"rounded-l-"
|
|
439
|
+
],
|
|
440
|
+
examples: [
|
|
441
|
+
{
|
|
442
|
+
description: "Basic rounded corners",
|
|
443
|
+
code: `<div className="rounded-sds-default">
|
|
444
|
+
Standard rounded corners
|
|
445
|
+
</div>
|
|
446
|
+
|
|
447
|
+
<button className="rounded-sds-m">
|
|
448
|
+
More rounded button
|
|
449
|
+
</button>`
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
description: "Directional radius",
|
|
453
|
+
code: `<div className="rounded-t-sds-l rounded-b-none">
|
|
454
|
+
Only top corners rounded
|
|
455
|
+
</div>`
|
|
456
|
+
}
|
|
457
|
+
],
|
|
458
|
+
tips: [
|
|
459
|
+
"Use sds-default for most UI elements",
|
|
460
|
+
"Larger values (sds-l, sds-xl) for prominent elements",
|
|
461
|
+
"Combine with borders: border rounded-sds-m"
|
|
462
|
+
]
|
|
463
|
+
},
|
|
464
|
+
boxShadow: {
|
|
465
|
+
category: "Box Shadow",
|
|
466
|
+
description: "Elevation shadows for depth and hierarchy",
|
|
467
|
+
prefixes: ["shadow-", "hover:shadow-", "focus:shadow-"],
|
|
468
|
+
examples: [
|
|
469
|
+
{
|
|
470
|
+
description: "Basic shadows",
|
|
471
|
+
code: `<div className="shadow-sds-s">
|
|
472
|
+
Subtle shadow
|
|
473
|
+
</div>
|
|
474
|
+
|
|
475
|
+
<div className="shadow-sds-m">
|
|
476
|
+
Medium elevation
|
|
477
|
+
</div>`
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
description: "Interactive shadows",
|
|
481
|
+
code: `<button className="
|
|
482
|
+
shadow-sds-s
|
|
483
|
+
hover:shadow-sds-m
|
|
484
|
+
active:shadow-sds-xs
|
|
485
|
+
transition-shadow
|
|
486
|
+
">
|
|
487
|
+
Interactive element
|
|
488
|
+
</button>`
|
|
489
|
+
}
|
|
490
|
+
],
|
|
491
|
+
tips: [
|
|
492
|
+
"Use smaller shadows (sds-xs, sds-s) for subtle depth",
|
|
493
|
+
"Use larger shadows (sds-l, sds-xl) for modals and popovers",
|
|
494
|
+
"Combine with hover states for interactive feedback"
|
|
495
|
+
]
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
function getTokenGuidance(category) {
|
|
499
|
+
if (!category || category === "all") {
|
|
500
|
+
return `SDS Design System Tokens for Tailwind CSS
|
|
501
|
+
|
|
502
|
+
The Science Design System provides a comprehensive set of design tokens that map directly to Tailwind utilities.
|
|
503
|
+
|
|
504
|
+
QUICK START:
|
|
505
|
+
1. Request specific categories for detailed guidance: fontFamily, fontSize, fontVariantNumeric, letterSpacing, lineHeight, textDecoration, textTransform, typography, height, width, borderRadius, boxShadow, breakpoints, colors, spacing
|
|
506
|
+
2. Use semantic tokens over primitive ones when available
|
|
507
|
+
3. Include responsive and theme variants for robust implementations
|
|
508
|
+
4. Use the @czi-sds/components/dist/tailwind.json file to get the exact token name and value
|
|
509
|
+
5. To use the typography tokens, you need to add the @tailwindcss/typography plugin to your tailwind.config.js file and then use the typography tokens in your tailwind classes like prose-[typography-token-name] for example prose-sds-body-m-400-wide.
|
|
510
|
+
6. Colors have been defined in light and dark mode with the same name. Use the dark:color-token-name to use the dark mode color.
|
|
511
|
+
7. Use spacing tokens like sds-m for paddings, margins, etc. for example p-sds-m for padding-medium.
|
|
512
|
+
8. Use borderRadius tokens like sds-default for rounded corners for example rounded-sds-default.
|
|
513
|
+
9. Use boxShadow tokens like sds-s for subtle shadows for example shadow-sds-s.
|
|
514
|
+
10. Use breakpoints tokens like sds-m for medium breakpoints for example md:sds-m.
|
|
515
|
+
11. Use fontFamily tokens like sds-body for body font for example font-sds-body.
|
|
516
|
+
12. Use fontSize tokens like sds-body-m-400-wide for body font size for example text-sds-body-m-400-wide.
|
|
517
|
+
13. Use fontVariantNumeric tokens like sds-body-m-400-wide for body font variant numeric for example font-variant-numeric-sds-body-m-400-wide.
|
|
518
|
+
14. Use letterSpacing tokens like sds-body-m-400-wide for body letter spacing for example tracking-sds-body-m-400-wide.
|
|
519
|
+
|
|
520
|
+
For detailed examples, request a specific category.`;
|
|
521
|
+
}
|
|
522
|
+
const guidance = TAILWIND_TOKEN_GUIDANCE[category];
|
|
523
|
+
if (!guidance) {
|
|
524
|
+
return `Category "${category}" not found. Available categories: ${Object.keys(
|
|
525
|
+
TAILWIND_TOKEN_GUIDANCE
|
|
526
|
+
).join(", ")}`;
|
|
527
|
+
}
|
|
528
|
+
let output = `## ${guidance.category} Tokens
|
|
529
|
+
|
|
530
|
+
`;
|
|
531
|
+
output += `${guidance.description}
|
|
532
|
+
|
|
533
|
+
`;
|
|
534
|
+
output += `**Tailwind Prefixes:** ${guidance.prefixes.join(", ")}
|
|
535
|
+
|
|
536
|
+
`;
|
|
537
|
+
output += `### Examples:
|
|
538
|
+
|
|
539
|
+
`;
|
|
540
|
+
guidance.examples.forEach((example, index) => {
|
|
541
|
+
output += `${index + 1}. **${example.description}**
|
|
542
|
+
\`\`\`jsx
|
|
543
|
+
${example.code}
|
|
544
|
+
\`\`\`
|
|
545
|
+
|
|
546
|
+
`;
|
|
547
|
+
});
|
|
548
|
+
if (guidance.tips && guidance.tips.length > 0) {
|
|
549
|
+
output += `### Tips:
|
|
550
|
+
`;
|
|
551
|
+
guidance.tips.forEach((tip) => {
|
|
552
|
+
output += `- ${tip}
|
|
553
|
+
`;
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
return output;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// src/tools/get-tailwind-tokens.ts
|
|
257
560
|
var getTailwindTokensTool = {
|
|
258
561
|
name: "get_tailwind_tokens",
|
|
259
|
-
description: "Get all available Tailwind tokens from the SDS design system.
|
|
562
|
+
description: "Get all available Tailwind tokens from the SDS design system. Available design tokens include fontFamily, fontSize, fontVariantNumeric, letterSpacing, lineHeight, textDecoration, textTransform, typography, height, width, borderRadius, boxShadow, breakpoints, colors, spacing, and more.",
|
|
260
563
|
async ctx() {
|
|
261
|
-
|
|
564
|
+
try {
|
|
565
|
+
const tailwindTokens = await fetchTailwindTokens();
|
|
566
|
+
return { tailwindTokens };
|
|
567
|
+
} catch (error) {
|
|
568
|
+
throw new Error(
|
|
569
|
+
`Failed to initialize tailwind tokens tool: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
570
|
+
);
|
|
571
|
+
}
|
|
262
572
|
},
|
|
263
|
-
exec(server2, { name, description }) {
|
|
573
|
+
exec(server2, { ctx, name, description }) {
|
|
264
574
|
server2.tool(
|
|
265
575
|
name,
|
|
266
576
|
description,
|
|
@@ -288,20 +598,25 @@ var getTailwindTokensTool = {
|
|
|
288
598
|
},
|
|
289
599
|
async ({ category }) => {
|
|
290
600
|
try {
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
601
|
+
const tokens = ctx.tailwindTokens;
|
|
602
|
+
let result;
|
|
603
|
+
if (!category || category === "all") {
|
|
604
|
+
result = tokens;
|
|
605
|
+
} else {
|
|
296
606
|
result = tokens[category] || {};
|
|
297
607
|
}
|
|
608
|
+
const responseContent = [];
|
|
609
|
+
const guidance = getTokenGuidance(category);
|
|
610
|
+
responseContent.push({
|
|
611
|
+
type: "text",
|
|
612
|
+
text: guidance
|
|
613
|
+
});
|
|
614
|
+
responseContent.push({
|
|
615
|
+
type: "text",
|
|
616
|
+
text: JSON.stringify(result, null, 2)
|
|
617
|
+
});
|
|
298
618
|
return {
|
|
299
|
-
content:
|
|
300
|
-
{
|
|
301
|
-
type: "text",
|
|
302
|
-
text: JSON.stringify(result, null, 2)
|
|
303
|
-
}
|
|
304
|
-
]
|
|
619
|
+
content: responseContent
|
|
305
620
|
};
|
|
306
621
|
} catch (error) {
|
|
307
622
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@czi-sds/mcp",
|
|
3
3
|
"description": "The official MCP server for SDS",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"main": "dist/stdio.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"tsx": "^4.20.3",
|
|
63
63
|
"typescript": "^5.9.2"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "34691ada3ef3cc877dcf1e2eef0f09efab53e668"
|
|
66
66
|
}
|