@discourser/design-system 0.22.2 → 0.22.4

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.
Files changed (75) hide show
  1. package/dist/figma-codex.json +2 -2
  2. package/docs/CSS_USAGE.md +235 -0
  3. package/docs/FIGMA_MAKE_SETUP.md +339 -0
  4. package/docs/GUIDELINES_REVIEW.md +728 -0
  5. package/docs/MAINTAINER_CHECKLIST.md +265 -0
  6. package/docs/TESTING_QUICK_REFERENCE.md +159 -0
  7. package/docs/TESTING_TOKENS.md +340 -0
  8. package/docs/active-stories/README.md +29 -0
  9. package/docs/active-stories/STORY-006a-figma-translation-foundations.md +324 -0
  10. package/docs/active-stories/STORY-006b-figma-translation-components.md +201 -0
  11. package/docs/active-stories/STORY-006c-figma-translation-layout-extension.md +258 -0
  12. package/docs/active-stories/STORY-008-kai-sidecar-fragments.md +137 -0
  13. package/docs/active-stories/STORY-011-verify-translation-docs.md +182 -0
  14. package/docs/archive/ARCHITECTURE-discourser-design-system.md +448 -0
  15. package/docs/claude-feed-back/ARCHITECTURE_DIAGRAM.md +243 -0
  16. package/docs/claude-feed-back/STYLING_VERIFICATION.md +89 -0
  17. package/docs/claude-feed-back/TEST_RESULTS.md +182 -0
  18. package/docs/context-share/ELEVATION_FIX_PLAN.md +903 -0
  19. package/docs/context-share/STORY-001-VALIDATION-PASSED.md +192 -0
  20. package/docs/context-share/STORY-002-IMPLEMENTATION-COMPLETE.md +161 -0
  21. package/docs/context-share/STORYBOOK_MCP_STRATEGY.md +867 -0
  22. package/docs/context-share/TESTING_GAPS_FILLED.md +353 -0
  23. package/docs/context-share/TOKEN_TESTING_SUMMARY.md +388 -0
  24. package/docs/context-share/code-connect-prompt.md +90 -0
  25. package/docs/context-share/dds-autonomous-pipeline.md +765 -0
  26. package/docs/context-share/fix-checkbox-radio-tokens.md +145 -0
  27. package/docs/context-share/icon-component-prompt.md +154 -0
  28. package/docs/context-share/icons/Audience.svg +3 -0
  29. package/docs/context-share/icons/AudioSpeaker.svg +3 -0
  30. package/docs/context-share/icons/BookmarkPlus.svg +3 -0
  31. package/docs/context-share/icons/ClipBoard.svg +8 -0
  32. package/docs/context-share/icons/DiscourserLogo.svg +4 -0
  33. package/docs/context-share/icons/ExitStudio.svg +4 -0
  34. package/docs/context-share/icons/Microphone.svg +5 -0
  35. package/docs/context-share/icons/NotebookPen.svg +3 -0
  36. package/docs/context-share/icons/PausePlay.svg +5 -0
  37. package/docs/context-share/icons/Play.svg +4 -0
  38. package/docs/context-share/icons/Record.svg +6 -0
  39. package/docs/context-share/icons/RepeatQuestion.svg +3 -0
  40. package/docs/context-share/icons/ScrollText.svg +3 -0
  41. package/docs/context-share/icons/Sparkles.svg +3 -0
  42. package/docs/context-share/icons/Speech.svg +3 -0
  43. package/docs/context-share/icons/StopPlay.svg +4 -0
  44. package/docs/context-share/icons/Timer.svg +3 -0
  45. package/docs/context-share/icons/UserProfile.svg +3 -0
  46. package/docs/context-share/m3-token-pipeline-audit.md +125 -0
  47. package/docs/context-share/storybook-mcp-kai-agent-revised-summary.md +211 -0
  48. package/docs/discourser-design-system-prd.md +3698 -0
  49. package/docs/figma-captures/01-typography.png +0 -0
  50. package/docs/figma-captures/02-button-iconbutton.png +0 -0
  51. package/docs/figma-captures/03-form-inputs.png +0 -0
  52. package/docs/figma-captures/04-form-controls.png +0 -0
  53. package/docs/figma-captures/05-data-display.png +0 -0
  54. package/docs/figma-captures/06-feedback.png +0 -0
  55. package/docs/figma-captures/07-overlays.png +0 -0
  56. package/docs/figma-captures/08-navigation-layout.png +0 -0
  57. package/docs/figma-captures/09-custom-components.png +0 -0
  58. package/docs/figma-captures/10-scenario-queue.png +0 -0
  59. package/docs/figma-captures/11-icon-library.png +0 -0
  60. package/docs/figma-make-docs/01-understanding-templates.md +235 -0
  61. package/docs/figma-make-docs/02-prerequisites.md +266 -0
  62. package/docs/figma-make-docs/03-creating-template.md +306 -0
  63. package/docs/figma-make-docs/04-adding-guidelines.md +448 -0
  64. package/docs/figma-make-docs/05-example-starter-code.md +590 -0
  65. package/docs/figma-make-docs/06-publishing-template.md +417 -0
  66. package/docs/figma-make-docs/07-maintenance.md +536 -0
  67. package/docs/figma-make-docs/08-faq.md +490 -0
  68. package/docs/figma-make-docs/README.md +95 -0
  69. package/docs/material-theme.json +418 -0
  70. package/docs/plans/2026-03-12-figma-token-export-rewrite.md +504 -0
  71. package/docs/plans/2026-03-12-step7-panda-token-resolution-design.md +119 -0
  72. package/docs/plans/2026-03-12-step7-panda-token-resolution.md +993 -0
  73. package/docs/token-name-mapping.json +850 -0
  74. package/docs/token-name-mapping.md +251 -0
  75. package/package.json +3 -2
@@ -0,0 +1,867 @@
1
+ # Storybook MCP Strategy for Design System Integration
2
+
3
+ > **Document Purpose:** Analysis of using `@storybook/addon-mcp` to provide agents with Panda CSS and design system knowledge for translating Figma designs into code.
4
+ >
5
+ > **Status:** Planning Phase
6
+ > **Last Updated:** 2026-02-10
7
+ > **Owner:** Design System Team
8
+
9
+ ---
10
+
11
+ ## Table of Contents
12
+
13
+ 1. [Vision & Concept](#vision--concept)
14
+ 2. [Current Approach: Storybook + MCP Addon](#current-approach-storybook--mcp-addon)
15
+ 3. [What We Can Do Now](#what-we-can-do-now)
16
+ 4. [Implementation Roadmap](#implementation-roadmap)
17
+ 5. [Limitations & Future Needs](#limitations--future-needs)
18
+ 6. [Future: Custom MCP Server](#future-custom-mcp-server)
19
+ 7. [Decision Matrix](#decision-matrix)
20
+
21
+ ---
22
+
23
+ ## Vision & Concept
24
+
25
+ ### The Problem
26
+
27
+ When building applications that consume the Discourser Design System, developers (and AI agents) need to:
28
+
29
+ 1. **Translate Figma designs** into working code
30
+ 2. **Choose the right components** from the design system
31
+ 3. **Apply Panda CSS patterns** correctly (VStack, HStack, Grid, etc.)
32
+ 4. **Use semantic tokens** instead of raw color values
33
+ 5. **Follow M3 design principles** and accessibility guidelines
34
+
35
+ Currently, this knowledge is scattered across:
36
+ - Component stories in Storybook
37
+ - Token documentation in MDX files
38
+ - Panda CSS official documentation (external)
39
+ - Design system guidelines (internal docs)
40
+ - Figma files (visual reference only)
41
+
42
+ ### The Solution
43
+
44
+ **Create a centralized knowledge hub in Storybook** that:
45
+ - Contains all component examples
46
+ - Documents Panda CSS patterns and utilities
47
+ - Provides Figma → Component translation guides
48
+ - Exposes everything via `@storybook/addon-mcp`
49
+ - Enables agents (like BMAD) to query this knowledge when building pages
50
+
51
+ ### The Workflow
52
+
53
+ ```
54
+ ┌─────────────────────────────────────────────────────────────┐
55
+ │ 1. Designer creates Figma page design │
56
+ └─────────────────────────────────────────────────────────────┘
57
+
58
+ ┌─────────────────────────────────────────────────────────────┐
59
+ │ 2. Agent (BMAD Dev) receives Figma design via figma-mcp │
60
+ └─────────────────────────────────────────────────────────────┘
61
+
62
+ ┌─────────────────────────────────────────────────────────────┐
63
+ │ 3. Agent queries Discourser Design System Storybook MCP: │
64
+ │ - "What layout pattern for vertical auto-layout?" │
65
+ │ - "What component for Figma 'Button/Filled'?" │
66
+ │ - "What tokens for primary brand color?" │
67
+ └─────────────────────────────────────────────────────────────┘
68
+
69
+ ┌─────────────────────────────────────────────────────────────┐
70
+ │ 4. Agent generates code using: │
71
+ │ - Discourser components │
72
+ │ - Panda CSS patterns │
73
+ │ - Semantic tokens │
74
+ └─────────────────────────────────────────────────────────────┘
75
+
76
+ ┌─────────────────────────────────────────────────────────────┐
77
+ │ 5. Result: Page matches Figma design, uses design system │
78
+ └─────────────────────────────────────────────────────────────┘
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Current Approach: Storybook + MCP Addon
84
+
85
+ ### Why Storybook?
86
+
87
+ **Storybook is already our component documentation hub:**
88
+
89
+ ✅ **Already Contains:**
90
+ - Component stories (`stories/*.stories.tsx`)
91
+ - Token documentation (`src/stories/foundations/`)
92
+ - Design guidelines (`stories/documentation/guidelines/`)
93
+ - Usage examples with live previews
94
+
95
+ ✅ **Benefits:**
96
+ - Single source of truth
97
+ - Interactive component demos
98
+ - Automatically stays in sync with code
99
+ - Great developer experience
100
+
101
+ ### Why @storybook/addon-mcp?
102
+
103
+ The [`@storybook/addon-mcp`](https://github.com/storybookjs/mcp) addon:
104
+
105
+ ✅ **Exposes Storybook content via MCP protocol:**
106
+ - Story content as resources
107
+ - Documentation pages (MDX)
108
+ - Component metadata
109
+ - Custom resources
110
+
111
+ ✅ **No Custom Server Needed (Initially):**
112
+ - Leverages existing Storybook infrastructure
113
+ - No additional maintenance burden
114
+ - Simpler deployment story
115
+
116
+ ✅ **Works with AI Agents:**
117
+ - Claude, GPT, or custom agents (like BMAD)
118
+ - Can query docs, examples, and guidelines
119
+ - Standard MCP protocol
120
+
121
+ ---
122
+
123
+ ## What We Can Do Now
124
+
125
+ ### Phase 1: Enhance Storybook with Panda CSS Knowledge
126
+
127
+ #### 1.1 Add Panda CSS Pattern Documentation
128
+
129
+ Create comprehensive MDX files documenting Panda CSS usage:
130
+
131
+ **New Stories to Create:**
132
+
133
+ ```
134
+ stories/
135
+ ├── panda-css/
136
+ │ ├── 01-Patterns.mdx # VStack, HStack, Grid, etc.
137
+ │ ├── 02-Utilities.mdx # Spacing, colors, typography
138
+ │ ├── 03-Responsive.mdx # Breakpoints, conditions
139
+ │ ├── 04-Composition.mdx # Layout composition patterns
140
+ │ └── 05-FigmaTranslation.mdx # Figma → Panda mapping
141
+ ```
142
+
143
+ **Content Structure:**
144
+
145
+ ```markdown
146
+ # Panda CSS Patterns
147
+
148
+ ## Layout Patterns
149
+
150
+ ### VStack - Vertical Stack
151
+
152
+ **Purpose:** Arrange children vertically with consistent spacing.
153
+
154
+ **When to use:**
155
+ - Forms with multiple fields
156
+ - Vertical lists
157
+ - Content sections stacked vertically
158
+
159
+ **Figma equivalent:** Auto Layout with Vertical direction
160
+
161
+ **Usage:**
162
+ ```tsx
163
+ import { VStack } from 'styled-system/jsx'
164
+
165
+ <VStack gap="4" alignItems="start">
166
+ <Header>Title</Header>
167
+ <Text>Description text</Text>
168
+ <Button>Action</Button>
169
+ </VStack>
170
+ ```
171
+
172
+ **Props:**
173
+ - `gap` - Spacing between items (use token values: 1-12)
174
+ - `alignItems` - Horizontal alignment (start/center/end)
175
+ - `justifyContent` - Vertical distribution
176
+ ```
177
+
178
+ #### 1.2 Create Figma Translation Guide
179
+
180
+ **stories/panda-css/05-FigmaTranslation.mdx:**
181
+
182
+ ```markdown
183
+ # Figma to Code Translation Guide
184
+
185
+ ## Quick Reference Table
186
+
187
+ | Figma Element | Discourser Component | Example |
188
+ |---------------|---------------------|---------|
189
+ | Button (Filled) | `<Button variant="solid">` | `<Button variant="solid" colorPalette="primary">Submit</Button>` |
190
+ | Button (Outlined) | `<Button variant="outline">` | `<Button variant="outline">Cancel</Button>` |
191
+ | Text Input | `<Input variant="outline">` | `<Input placeholder="Email" />` |
192
+ | Checkbox | `<Checkbox>` | `<Checkbox>I agree</Checkbox>` |
193
+ | Auto Layout (V) | `<VStack>` | `<VStack gap="4">...</VStack>` |
194
+ | Auto Layout (H) | `<HStack>` | `<HStack gap="2">...</HStack>` |
195
+ | Frame with Grid | `<Grid>` | `<Grid columns={3} gap="4">...</Grid>` |
196
+
197
+ ## Layout Constraints
198
+
199
+ | Figma Constraint | Panda CSS |
200
+ |-----------------|-----------|
201
+ | Fill Container | `w="full"` or `h="full"` |
202
+ | Hug Contents | `w="fit"` or `h="fit"` |
203
+ | Fixed (200px) | `w="200px"` |
204
+ | Min Width | `minW="200px"` |
205
+ | Max Width | `maxW="600px"` |
206
+
207
+ ## Spacing Translation
208
+
209
+ | Figma Spacing | Panda Token | CSS Value |
210
+ |---------------|-------------|-----------|
211
+ | 4px | `gap="1"` | 0.25rem |
212
+ | 8px | `gap="2"` | 0.5rem |
213
+ | 16px | `gap="4"` | 1rem |
214
+ | 24px | `gap="6"` | 1.5rem |
215
+ | 32px | `gap="8"` | 2rem |
216
+
217
+ ## Color Translation
218
+
219
+ **❌ Never use raw color values:**
220
+ ```tsx
221
+ <Button style={{ backgroundColor: '#64A104' }}>❌ Wrong</Button>
222
+ ```
223
+
224
+ **✅ Always use semantic tokens:**
225
+ ```tsx
226
+ <Button colorPalette="primary">✅ Correct</Button>
227
+ ```
228
+
229
+ **Token Selection:**
230
+ - Primary actions → `colorPalette="primary"`
231
+ - Secondary actions → `colorPalette="secondary"`
232
+ - Destructive actions → `colorPalette="error"`
233
+ - Neutral actions → `colorPalette="neutral"`
234
+ ```
235
+
236
+ #### 1.3 Enhance Token Documentation
237
+
238
+ Expand existing `src/stories/foundations/Colors.mdx` with usage guidance:
239
+
240
+ ```markdown
241
+ ## Token Usage in Code
242
+
243
+ ### For Agents/Developers
244
+
245
+ When translating Figma designs:
246
+
247
+ 1. **Identify the semantic meaning**, not the color value
248
+ 2. **Choose the semantic token** that matches the intent
249
+ 3. **Never reference tonal palette values directly** (e.g., `primary.60`)
250
+
251
+ ### Decision Tree
252
+
253
+ ```
254
+ Is this a primary brand action?
255
+ → Yes: colorPalette="primary"
256
+ → No: Continue...
257
+
258
+ Is this a secondary/supporting action?
259
+ → Yes: colorPalette="secondary"
260
+ → No: Continue...
261
+
262
+ Is this a destructive/error action?
263
+ → Yes: colorPalette="error"
264
+ → No: colorPalette="neutral"
265
+ ```
266
+ ```
267
+
268
+ ### Phase 2: Install & Configure @storybook/addon-mcp
269
+
270
+ #### 2.1 Installation
271
+
272
+ ```bash
273
+ pnpm add -D @storybook/addon-mcp
274
+ ```
275
+
276
+ #### 2.2 Configuration
277
+
278
+ **.storybook/main.ts:**
279
+
280
+ ```typescript
281
+ import type { StorybookConfig } from '@storybook/react-vite';
282
+
283
+ const config: StorybookConfig = {
284
+ stories: [
285
+ '../stories/**/*.mdx',
286
+ '../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
287
+ '../src/**/*.mdx',
288
+ '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
289
+ ],
290
+ addons: [
291
+ '@storybook/addon-essentials',
292
+ '@storybook/addon-a11y',
293
+ '@storybook/addon-docs',
294
+ '@storybook/addon-mcp', // ← Add this
295
+ ],
296
+ framework: {
297
+ name: '@storybook/react-vite',
298
+ options: {},
299
+ }
300
+ };
301
+
302
+ export default config;
303
+ ```
304
+
305
+ **.storybook/preview.ts:**
306
+
307
+ ```typescript
308
+ import type { Preview } from '@storybook/react-vite';
309
+ import '../src/global.css';
310
+
311
+ const preview: Preview = {
312
+ parameters: {
313
+ // ... existing parameters
314
+
315
+ // MCP Configuration
316
+ mcp: {
317
+ servers: {
318
+ 'discourser-design-system': {
319
+ // Expose all documentation as resources
320
+ resources: [
321
+ // Panda CSS documentation
322
+ '/docs/panda-css--patterns',
323
+ '/docs/panda-css--utilities',
324
+ '/docs/panda-css--responsive',
325
+ '/docs/panda-css--composition',
326
+ '/docs/panda-css--figma-translation',
327
+
328
+ // Foundation docs
329
+ '/docs/foundations--colors',
330
+ '/docs/foundations--typography',
331
+ '/docs/foundations--spacing',
332
+ '/docs/foundations--elevation',
333
+
334
+ // Component guidelines
335
+ '/docs/documentation-guidelines--*',
336
+
337
+ // All component stories
338
+ '/stories/components--*',
339
+ ],
340
+
341
+ // Optional: Custom metadata
342
+ metadata: {
343
+ version: '0.13.0',
344
+ description: 'Discourser Design System - Material 3 components with Panda CSS',
345
+ repository: 'https://github.com/Tasty-Maker-Studio/Discourser-Design-System',
346
+ }
347
+ }
348
+ }
349
+ }
350
+ },
351
+ };
352
+
353
+ export default preview;
354
+ ```
355
+
356
+ ### Phase 3: Test with BMAD Agent
357
+
358
+ #### 3.1 Consuming App Setup
359
+
360
+ In the consuming application (e.g., `discourser.ai`):
361
+
362
+ **Install the design system:**
363
+ ```bash
364
+ pnpm add @discourser/design-system
365
+ ```
366
+
367
+ **Configure MCP client to connect to Storybook:**
368
+
369
+ ```json
370
+ // .mcp/config.json
371
+ {
372
+ "mcpServers": {
373
+ "design-system": {
374
+ "url": "http://localhost:6006/mcp",
375
+ "description": "Discourser Design System documentation and examples"
376
+ }
377
+ }
378
+ }
379
+ ```
380
+
381
+ #### 3.2 Agent Query Examples
382
+
383
+ **Example 1: Query for layout pattern**
384
+
385
+ ```typescript
386
+ // Agent prompt:
387
+ // "I have a Figma frame with vertical auto-layout and 16px spacing.
388
+ // What Panda CSS pattern should I use?"
389
+
390
+ // MCP Query:
391
+ const result = await mcp.readResource('design-system://docs/panda-css--patterns');
392
+
393
+ // Agent parses the docs and finds:
394
+ // "Auto Layout (Vertical) → <VStack gap='4'>"
395
+
396
+ // Agent generates code:
397
+ <VStack gap="4">
398
+ {/* children */}
399
+ </VStack>
400
+ ```
401
+
402
+ **Example 2: Query for component selection**
403
+
404
+ ```typescript
405
+ // Agent prompt:
406
+ // "I have a Figma button with 'Filled' variant and primary color.
407
+ // What component should I use?"
408
+
409
+ // MCP Query:
410
+ const translation = await mcp.readResource('design-system://docs/panda-css--figma-translation');
411
+
412
+ // Agent finds mapping:
413
+ // "Button (Filled) → <Button variant='solid' colorPalette='primary'>"
414
+
415
+ // Agent generates code:
416
+ <Button variant="solid" colorPalette="primary">
417
+ Submit
418
+ </Button>
419
+ ```
420
+
421
+ **Example 3: Query for token usage**
422
+
423
+ ```typescript
424
+ // Agent prompt:
425
+ // "Should I use 'primary.60' or 'primary' for a button background?"
426
+
427
+ // MCP Query:
428
+ const colors = await mcp.readResource('design-system://docs/foundations--colors');
429
+
430
+ // Agent reads token usage guidelines and learns:
431
+ // "✅ Always use semantic tokens"
432
+ // "❌ Never use tonal palette directly"
433
+
434
+ // Agent generates code:
435
+ <Button colorPalette="primary"> {/* ✅ Correct */}
436
+ ```
437
+
438
+ ---
439
+
440
+ ## Implementation Roadmap
441
+
442
+ ### Week 1: Content Creation
443
+
444
+ - [ ] Create `stories/panda-css/01-Patterns.mdx`
445
+ - [ ] Create `stories/panda-css/02-Utilities.mdx`
446
+ - [ ] Create `stories/panda-css/03-Responsive.mdx`
447
+ - [ ] Create `stories/panda-css/04-Composition.mdx`
448
+ - [ ] Create `stories/panda-css/05-FigmaTranslation.mdx`
449
+ - [ ] Enhance `src/stories/foundations/Colors.mdx` with usage guidance
450
+ - [ ] Add token selection decision tree to docs
451
+
452
+ ### Week 2: MCP Integration
453
+
454
+ - [ ] Install `@storybook/addon-mcp`
455
+ - [ ] Configure `.storybook/main.ts`
456
+ - [ ] Configure `.storybook/preview.ts` with MCP resources
457
+ - [ ] Test local Storybook with MCP addon
458
+ - [ ] Document MCP endpoints
459
+
460
+ ### Week 3: Testing & Validation
461
+
462
+ - [ ] Create test consuming app
463
+ - [ ] Configure MCP client in consuming app
464
+ - [ ] Write example agent prompts
465
+ - [ ] Validate agent can query docs
466
+ - [ ] Validate agent generates correct code
467
+ - [ ] Document agent workflow
468
+
469
+ ### Week 4: Documentation & Rollout
470
+
471
+ - [ ] Update README with MCP usage
472
+ - [ ] Create developer guide for consuming apps
473
+ - [ ] Create agent prompt examples
474
+ - [ ] Publish updated design system version
475
+ - [ ] Announce to team
476
+
477
+ ---
478
+
479
+ ## Limitations & Future Needs
480
+
481
+ ### What @storybook/addon-mcp CAN Do ✅
482
+
483
+ 1. **Expose static documentation** as MCP resources
484
+ 2. **Provide component examples** with code snippets
485
+ 3. **Share design guidelines** and best practices
486
+ 4. **Enable agents to read** comprehensive docs
487
+
488
+ ### What @storybook/addon-mcp CANNOT Do ❌
489
+
490
+ 1. **No intelligent querying**
491
+ - Can't answer "What component for X?"
492
+ - Agent must parse docs and infer
493
+
494
+ 2. **No context-aware recommendations**
495
+ - Can't say "For this use case, use VStack instead of Flex"
496
+ - Agent must understand Panda CSS concepts
497
+
498
+ 3. **No validation**
499
+ - Can't validate "Is this the right token?"
500
+ - Agent must follow guidelines correctly
501
+
502
+ 4. **No Figma integration**
503
+ - Can't directly translate Figma nodes
504
+ - Agent must implement translation logic
505
+
506
+ ### Real-World Agent Workflow
507
+
508
+ **With Storybook MCP (Current Approach):**
509
+
510
+ ```
511
+ 1. Agent receives Figma design
512
+ 2. Agent reads Figma Translation guide from MCP
513
+ 3. Agent parses the guide to build mappings
514
+ 4. Agent applies mappings to generate code
515
+ 5. Agent reads token docs to choose correct tokens
516
+ ```
517
+
518
+ **Pros:**
519
+ - ✅ Simple to implement
520
+ - ✅ No custom server needed
521
+ - ✅ Comprehensive documentation available
522
+
523
+ **Cons:**
524
+ - ⚠️ Agent must be sophisticated enough to parse and apply
525
+ - ⚠️ More prompting/context needed
526
+ - ⚠️ Slower query responses (must read full docs)
527
+
528
+ ---
529
+
530
+ ## Future: Custom MCP Server
531
+
532
+ ### When to Build a Custom Server
533
+
534
+ Build a custom MCP server when:
535
+
536
+ 1. **Agents need intelligent querying** beyond static docs
537
+ 2. **Performance becomes critical** (caching, pre-computed answers)
538
+ 3. **Validation is required** (check if component usage is correct)
539
+ 4. **Complex Figma translation** (direct node → component mapping)
540
+
541
+ ### Custom MCP Server Architecture
542
+
543
+ ```typescript
544
+ // packages/design-system/mcp-server/index.ts
545
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
546
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
547
+
548
+ const server = new Server({
549
+ name: 'discourser-design-system',
550
+ version: '1.0.0',
551
+ }, {
552
+ capabilities: {
553
+ resources: {},
554
+ tools: {},
555
+ }
556
+ });
557
+
558
+ // Tool: Find component for Figma element
559
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
560
+ if (request.params.name === 'find_component_for_figma_element') {
561
+ const { figmaType, variant, properties } = request.params.arguments;
562
+
563
+ // Intelligent mapping logic
564
+ const mapping = componentMapper.find({
565
+ type: figmaType,
566
+ variant: variant,
567
+ ...properties
568
+ });
569
+
570
+ return {
571
+ component: mapping.component,
572
+ props: mapping.props,
573
+ example: mapping.exampleCode,
574
+ reasoning: mapping.why
575
+ };
576
+ }
577
+
578
+ if (request.params.name === 'suggest_layout_pattern') {
579
+ const { layout, spacing, alignment } = request.params.arguments;
580
+
581
+ // Pattern recommendation logic
582
+ const pattern = patternSelector.recommend({
583
+ layout,
584
+ spacing,
585
+ alignment
586
+ });
587
+
588
+ return {
589
+ pattern: pattern.name,
590
+ props: pattern.props,
591
+ example: pattern.code,
592
+ alternatives: pattern.alternatives
593
+ };
594
+ }
595
+
596
+ if (request.params.name === 'choose_semantic_token') {
597
+ const { context, colorValue } = request.params.arguments;
598
+
599
+ // Token recommendation logic
600
+ const token = tokenSelector.recommend({
601
+ context,
602
+ approximateValue: colorValue
603
+ });
604
+
605
+ return {
606
+ token: token.name,
607
+ cssVar: token.cssVar,
608
+ reasoning: token.why,
609
+ warning: token.warning
610
+ };
611
+ }
612
+ });
613
+
614
+ // Resource: Pre-processed documentation
615
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
616
+ resources: [
617
+ {
618
+ uri: 'design-system://components/catalog',
619
+ name: 'Component Catalog (Searchable)',
620
+ mimeType: 'application/json',
621
+ },
622
+ {
623
+ uri: 'design-system://patterns/index',
624
+ name: 'Pattern Index (Queryable)',
625
+ mimeType: 'application/json',
626
+ },
627
+ {
628
+ uri: 'design-system://tokens/semantic',
629
+ name: 'Semantic Token Registry',
630
+ mimeType: 'application/json',
631
+ }
632
+ ]
633
+ }));
634
+ ```
635
+
636
+ ### Custom Server Benefits
637
+
638
+ ✅ **Intelligent Tools:**
639
+ ```typescript
640
+ // Instead of reading docs and parsing:
641
+ const docs = await mcp.readResource('design-system://docs/figma-translation');
642
+ // Parse, infer, decide...
643
+
644
+ // Agent directly queries:
645
+ const result = await mcp.callTool('find_component_for_figma_element', {
646
+ figmaType: 'Button',
647
+ variant: 'Filled',
648
+ size: 'Large'
649
+ });
650
+
651
+ // Returns:
652
+ {
653
+ component: 'Button',
654
+ props: {
655
+ variant: 'solid',
656
+ size: 'lg',
657
+ colorPalette: 'primary'
658
+ },
659
+ example: '<Button variant="solid" size="lg" colorPalette="primary">Click</Button>',
660
+ reasoning: 'Figma "Filled" variant maps to Panda "solid". Large size maps to "lg".'
661
+ }
662
+ ```
663
+
664
+ ✅ **Validation:**
665
+ ```typescript
666
+ const validation = await mcp.callTool('validate_component_usage', {
667
+ component: 'Button',
668
+ props: {
669
+ variant: 'solid',
670
+ colorPalette: 'primary.60' // ❌ Wrong
671
+ }
672
+ });
673
+
674
+ // Returns:
675
+ {
676
+ valid: false,
677
+ errors: [
678
+ {
679
+ property: 'colorPalette',
680
+ message: 'Use semantic token "primary" instead of tonal palette "primary.60"',
681
+ suggestion: 'colorPalette: "primary"'
682
+ }
683
+ ]
684
+ }
685
+ ```
686
+
687
+ ✅ **Context-Aware Recommendations:**
688
+ ```typescript
689
+ const recommendation = await mcp.callTool('recommend_pattern', {
690
+ context: 'form-layout',
691
+ elements: ['heading', 'input', 'input', 'checkbox', 'button']
692
+ });
693
+
694
+ // Returns:
695
+ {
696
+ pattern: 'VStack',
697
+ props: { gap: '4', alignItems: 'stretch' },
698
+ reasoning: 'Form elements should stack vertically with consistent spacing',
699
+ example: `
700
+ <VStack gap="4" alignItems="stretch">
701
+ <Header>Form Title</Header>
702
+ <Input />
703
+ <Input />
704
+ <Checkbox>I agree</Checkbox>
705
+ <Button>Submit</Button>
706
+ </VStack>
707
+ `
708
+ }
709
+ ```
710
+
711
+ ### Migration Path
712
+
713
+ **Phase 1: Current (Storybook MCP)**
714
+ - Start with `@storybook/addon-mcp`
715
+ - Comprehensive documentation
716
+ - Static resources only
717
+ - Agent must be sophisticated
718
+
719
+ **Phase 2: Hybrid**
720
+ - Keep Storybook MCP for docs
721
+ - Add lightweight custom server for specific tools
722
+ - Best of both worlds
723
+
724
+ **Phase 3: Full Custom Server**
725
+ - Replace Storybook MCP
726
+ - Custom server handles everything
727
+ - Maximum intelligence and performance
728
+
729
+ ---
730
+
731
+ ## Decision Matrix
732
+
733
+ ### Start with Storybook MCP if:
734
+
735
+ - ✅ You want to move fast (1-2 weeks)
736
+ - ✅ You have sophisticated agents (Claude, GPT-4)
737
+ - ✅ Documentation is comprehensive
738
+ - ✅ You want minimal maintenance
739
+
740
+ ### Build Custom MCP Server if:
741
+
742
+ - ✅ Agents need intelligent querying
743
+ - ✅ Performance is critical
744
+ - ✅ Validation is required
745
+ - ✅ Complex Figma integration needed
746
+ - ✅ You have engineering resources for custom tooling
747
+
748
+ ### Hybrid Approach if:
749
+
750
+ - ✅ You want quick wins now + future flexibility
751
+ - ✅ Some queries need intelligence, others just docs
752
+ - ✅ You want to iterate and learn
753
+
754
+ ---
755
+
756
+ ## Recommended Approach
757
+
758
+ ### Start Now: Storybook MCP (2-4 weeks)
759
+
760
+ **Why:**
761
+ 1. Fastest path to value
762
+ 2. Leverages existing Storybook infrastructure
763
+ 3. Validates the concept with real agents
764
+ 4. Learns what agents actually need
765
+
766
+ **Deliverables:**
767
+ - Comprehensive Panda CSS docs in Storybook
768
+ - Figma translation guide
769
+ - MCP addon configured
770
+ - Tested with BMAD agent
771
+
772
+ ### Evaluate in 1-2 Months
773
+
774
+ **Questions to answer:**
775
+ - Are agents successfully translating Figma designs?
776
+ - Are they choosing the right components?
777
+ - Are they applying tokens correctly?
778
+ - What queries are most common?
779
+ - Where do agents struggle?
780
+
781
+ ### Build Custom Server if Needed (Future)
782
+
783
+ **Based on:**
784
+ - Frequency of complex queries
785
+ - Agent success rate
786
+ - Performance requirements
787
+ - Engineering capacity
788
+
789
+ **Benefits:**
790
+ - Intelligent recommendations
791
+ - Validation
792
+ - Better UX for agents
793
+ - Faster responses
794
+
795
+ ---
796
+
797
+ ## Success Metrics
798
+
799
+ ### Phase 1 (Storybook MCP)
800
+
801
+ - ✅ 100% of Panda CSS patterns documented
802
+ - ✅ Figma → Component mapping table complete
803
+ - ✅ MCP addon successfully exposes resources
804
+ - ✅ BMAD agent can query and retrieve docs
805
+ - ✅ Agent generates valid code from Figma designs
806
+
807
+ ### Phase 2 (Validation)
808
+
809
+ - ✅ Agent success rate > 80% for simple pages
810
+ - ✅ Agent chooses correct components > 90%
811
+ - ✅ Agent uses semantic tokens > 95%
812
+ - ✅ Generated code passes design system linting
813
+
814
+ ### Phase 3 (Custom Server, if needed)
815
+
816
+ - ✅ Intelligent queries reduce agent prompt size by 50%
817
+ - ✅ Response time < 200ms for common queries
818
+ - ✅ Validation catches 100% of token misuse
819
+ - ✅ Agent success rate > 95%
820
+
821
+ ---
822
+
823
+ ## Next Steps
824
+
825
+ ### Immediate (This Week)
826
+
827
+ 1. ✅ Document this strategy (current document)
828
+ 2. ⬜ Create Panda CSS pattern documentation (stories/panda-css/)
829
+ 3. ⬜ Create Figma translation guide
830
+ 4. ⬜ Install `@storybook/addon-mcp`
831
+
832
+ ### Short Term (Next 2 Weeks)
833
+
834
+ 1. ⬜ Configure MCP addon in Storybook
835
+ 2. ⬜ Test MCP resources are accessible
836
+ 3. ⬜ Set up test consuming app
837
+ 4. ⬜ Validate agent workflow
838
+
839
+ ### Medium Term (1-2 Months)
840
+
841
+ 1. ⬜ Collect agent usage data
842
+ 2. ⬜ Identify pain points
843
+ 3. ⬜ Evaluate need for custom server
844
+ 4. ⬜ Document lessons learned
845
+
846
+ ---
847
+
848
+ ## References
849
+
850
+ - **@storybook/addon-mcp:** https://github.com/storybookjs/mcp
851
+ - **MCP Protocol Spec:** https://modelcontextprotocol.io/
852
+ - **Panda CSS Docs:** https://panda-css.com/
853
+ - **Design System Repo:** https://github.com/Tasty-Maker-Studio/Discourser-Design-System
854
+ - **Material Design 3:** https://m3.material.io/
855
+
856
+ ---
857
+
858
+ ## Questions & Feedback
859
+
860
+ For questions about this strategy or to provide feedback:
861
+
862
+ 1. Open an issue in the design system repo
863
+ 2. Discuss in team standup
864
+ 3. Update this document with new learnings
865
+
866
+ **Document maintained by:** Design System Team
867
+ **Review cycle:** Monthly or as strategy evolves