Insider Design System MCP
# ๐จ Insider Design System MCP
**Automated Model Context Protocol server** for the Insider Design System. Enables AI assistants like Claude to discover, understand, and generate code for 60+ Design System components with **automated extraction** from source code.
**Version**: 2.0 (Automated Extraction)
**Status**: โ
Production Ready
**Last Updated**: 2025-11-21
---
## โจ Features
### ๐ค Automated Extraction
- **Zero Manual Work**: Automatically extracts component metadata from Vue source files
- **Always Up-to-Date**: Re-run extraction when Design System changes (~5 minutes)
- **Rich Metadata**: Props, emits, enums, validators, slots - all extracted automatically
### ๐ Comprehensive Data
- **62 Components**: Full coverage of Insider Design System
- **1,087 Props**: With types, defaults, and validators
- **30 Enums**: STYLES, TYPES, SIZES automatically detected
- **Real Usage Analysis**: Common mistakes detected from analytics-fe codebase
- **Manual Enrichments**: Critical components have detailed examples and notes
### ๐ง MCP Tools
- `list-components` - List all components
- `get-component` - **๐ Markdown format** - Get component info in human-readable format with **77% token savings**
- `search-components` - Search by name/description
- `generate-code` - Generate Vue component code
- `map-figma-component` - Map Figma to DS components
### โก Markdown Format (NEW!)
The `get-component` tool now returns component documentation in **Markdown format** for massive token savings:
**Benefits:**
- ๐ฐ **77% token savings** compared to JSON format (690KB โ 161KB)
- ๐ **Human-readable** format with clear structure
- ๐ฏ **~135,335 tokens saved** across all components
- โก **Faster responses** with smaller payloads
**Top Performers:**
- InButtonV2: 88% savings (55KB โ 6.6KB)
- InDropdownMenu: 87% savings (36KB โ 4.8KB)
- InTooltipV2: 86% savings (31KB โ 4.2KB)
**Format includes:**
- Props with types, defaults, descriptions
- Events with payloads
- Examples with code snippets
- Common mistakes and best practices
- Related components
### ๐ MCP Resources
- `ds://components` - All components list
- `ds://registry` - Registry metadata
- `ds://component/{name}` - Individual component
- `ds://categories` - Component categories
---
## ๐ Documentation
**โ See [docs/](docs/) for complete documentation index**
- **[Architecture](docs/architecture/)** - System design and data flow
- [How It Works](docs/architecture/how-it-works.md) - Complete architecture overview
- [Smart Filter Layer](docs/architecture/smart-filter-layer.md) - Token optimization system
- [Figma Integration](docs/architecture/figma-integration.md) - Figma to Vue workflow
- **[Guides](docs/guides/)** - How-to guides and workflows
- [Developer Workflow](docs/guides/workflow.md) - Day-to-day development
- [Enrichment Strategy](docs/guides/enrichment-strategy.md) - Creating enrichments
- [Enrichment Template](docs/guides/enrichment-template.md) - Enrichment templates
- **[Reference](docs/reference/)** - API and tool references
- [Agent Usage](docs/reference/agent-usage.md) - Specialized agents guide
---
## ๐ Quick Start
### Prerequisites
- Node.js >= 20.0.0
- npm >= 10.0.0
### Installation
```bash
# Clone repository
git clone <repo-url>
cd design-system-mcp
# Install dependencies
npm install
# Extract component metadata (first time)
npm run extract:all
# Build
npm run build
# Test
npm run test:production
```
**Need help with extraction scripts?** See [WORKFLOW.md](WORKFLOW.md) for detailed usage guide.
---
## โ๏ธ Configuration
### Claude Desktop
Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"design-system": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/path/to/design-system-mcp/dist/index.js"]
}
}
}
```
### Environment Variables
```bash
# Design System source path (for extraction)
export DS_PATH="/Users/YOUR_USERNAME/path/to/insider-design-system"
# Analytics FE path (for usage analysis)
export ANALYTICS_FE_PATH="/Users/YOUR_USERNAME/path/to/analytics-fe"
```
---
## ๐ Data Extraction Pipeline
### Architecture
```
Design System Source Code (Vue files)
โ AUTOMATED EXTRACTION
data/combined.json (209 KB)
โ BUILD & COPY
dist/data/combined.json
โ RUNTIME LOADING
MCP Server (in-memory, enum-resolved)
โ FAST QUERIES
Claude Code
```
### Extraction Commands
```bash
# Extract all data (run when Design System changes)
npm run extract:all
# Or run individually:
npm run extract:components # Parse Vue components โ data/components.json
npm run extract:storybook # Extract examples โ data/storybook.json
npm run extract:usage # Analyze usage โ data/usage.json
npm run extract:argtypes # Sync possibleValues from storybook argTypes
npm run extract:merge # Merge all โ data/combined.json
# Rebuild MCP server
npm run build
```
### What Gets Extracted?
**1. Component Metadata** (`extract-components.ts`)
- Props (type, default, required, validator)
- Emits (from `$emit()` calls)
- Enums (const STYLES = {...})
- Slots
- Version (V1/V2)
**2. Storybook Examples** (`extract-storybook.ts`)
- Code examples from stories
- Descriptions
- Categories
**3. Real Usage Analysis** (`extract-usage.ts`)
- Usage counts from analytics-fe
- Common mistakes (auto-detected)
- Most used props
- Real code patterns
**4. Manual Enrichments** (overlay)
- Detailed valueFormat for critical props
- Common mistakes documentation
- Helper functions
- Migration guides
---
## ๐ Usage Examples
### ๐ฏ Complete Walkthrough: From Raw Request to Implementation
**Scenario:** You need a button that opens a dropdown menu.
#### Step 1: Optimize Your Raw Request
```bash
# In Claude Code (works in ANY project with Design System MCP!)
User: "Use optimize-prompt to transform this request: I need a button that opens a dropdown menu"
```
Claude calls `mcp__design-system__optimize-prompt` and returns:
```markdown
# Original Prompt
I need a button that opens a dropdown menu
# Analysis
- Language: English
- Intent: implement
- Components: InButtonV2, InDropdownMenu
- Complexity: medium
- Estimated Token Savings: ~24,000 tokens
# Optimized Prompt
I need to implement InButtonV2 and InDropdownMenu components with proper integration.
Please use the Design System MCP to:
1. Get documentation for both components
- Tool: mcp__design-system__get-component
- Components: InButtonV2, InDropdownMenu
- Note: Markdown format saves ~87% tokens on average
2. Generate implementation code
- Tool: mcp__design-system__generate-code
- Include integration between components
Requirements:
- Primary styling for main actions
- Dropdown opens below trigger element
- Proper state management between components
Show me:
โ
Which components you're using
โ
Token savings from Markdown format for each component
โ
The generated Vue code
โ
Integration example showing how components work together
```
#### Step 2: Use the Optimized Prompt
```bash
User: "Now use the optimized prompt above to implement the button + dropdown"
```
Claude executes:
1. **Gets InButtonV2 docs** (Markdown format)
- Original: 55KB JSON โ 6.6KB Markdown
- Token savings: 88% (~12,198 tokens)
2. **Gets InDropdownMenu docs** (Markdown format)
- Original: 36KB JSON โ 4.8KB Markdown
- Token savings: 87% (~8,214 tokens)
3. **Generates integrated Vue code:**
```vue
<template>
<div class="button-dropdown-container">
<InButtonV2
id="actions-button"
:type="TYPES.PRIMARY"
:styling="STYLES.SOLID"
label-text="Actions"
@click="toggleDropdown"
/>
<InDropdownMenu
v-if="isOpen"
:items="menuItems"
@item-click="handleItemClick"
@close="isOpen = false"
/>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { InButtonV2, InDropdownMenu } from '@useinsider/design-system-vue';
import '@useinsider/design-system-vue/dist/design-system-vue.css';
const isOpen = ref(false);
const menuItems = [
{ id: 'export', label: 'Export Data', icon: 'download' },
{ id: 'share', label: 'Share Report', icon: 'share' },
{ id: 'settings', label: 'Settings', icon: 'settings' },
];
const toggleDropdown = () => {
isOpen.value = !isOpen.value;
};
const handleItemClick = (item: any) => {
console.log('Clicked:', item.id);
isOpen.value = false;
};
</script>
```
#### Summary
**Total token savings:** ~20,412 tokens (87.5% reduction)
**Time saved:** Claude uses the right tools in the right order
**Quality:** Proper integration, best practices included
---
### ๐ก Pro Tips
**Always optimize raw requests first:**
โ **Don't do this:**
```
User: "I need a button"
```
Claude searches through code files, wastes time.
โ
**Do this:**
```
User: "Use optimize-prompt: I need a button"
```
Claude gets optimized prompt โ Uses MCP tools โ Fast & accurate implementation.
**Works everywhere:**
- โ
analytics-fe project
- โ
marketing-web project
- โ
customer-portal project
- โ
ANY project with Design System MCP configured
---
### ๐ฏ Quick Reference: optimize-prompt
```typescript
// Single component
mcp__design-system__optimize-prompt("I need a button")
// Multiple components
mcp__design-system__optimize-prompt("button and dropdown menu")
// Migration task
mcp__design-system__optimize-prompt("migrate InDatePicker from V1 to V2")
// Debug issue
mcp__design-system__optimize-prompt("InSelect not working, showing errors")
// Learning
mcp__design-system__optimize-prompt("how to use InTooltipV2?")
```
### Get Component Details
```typescript
// Claude automatically calls:
mcp__design-system__get-component("InButtonV2")
// Returns in Markdown format (88% token savings):
# InButtonV2
**Version:** v2
## Props
### `styling`
**Type:** `String` | **Default:** `"STYLES.SOLID"`
**Allowed values:** `solid`, `ghost`, `text`
### `type`
**Type:** `String` | **Default:** `"TYPES.PRIMARY"`
...
## Examples
### Basic Primary Button
```vue
<InButtonV2
id="primary-btn"
styling="solid"
type="primary"
label-text="Click Me"
/>
```
Token savings: 55KB โ 6.6KB (88% reduction)
```
### Search Components
```typescript
mcp__design-system__search-components("button")
// Returns: InButton, InButtonV2, InCreateButton...
```
### Generate Code
```typescript
mcp__design-system__generate-code({
component: "InButtonV2",
props: { styling: "solid", type: "primary" }
})
// Returns:
// <InButtonV2
// id="button-1"
// styling="solid"
// type="primary"
// label-text="Button"
// />
```
---
## ๐งช Testing
```bash
# Test combined dataset
npm run test:data
# Test production build
npm run test:production
# Run unit tests
npm test
# Coverage
npm run test:coverage
```
---
## ๐ Project Structure
```
design-system-mcp/
โโโ ๐ README.md # This file
โโโ ๐ COMPLETION_REPORT.md # Full project report
โโโ ๐ HOW_IT_WORKS.md # Architecture deep dive
โโโ ๐ CLEANUP_SUMMARY.md # Cleanup history
โโโ ๐ฆ package.json # Dependencies & scripts
โโโ ๐ง tsup.config.ts # Build configuration
โ
โโโ ๐ src/ # Source code
โ โโโ index.ts # Entry point
โ โโโ server.ts # MCP server
โ โโโ tools/index.ts # MCP tools
โ โโโ resources/index.ts # MCP resources
โ โโโ types/index.ts # TypeScript types
โ โโโ registry/
โ โโโ combined-loader.ts # โญ Dataset loader (NEW)
โ โโโ enrichments/ # Manual enrichments
โ โ โโโ InButtonV2.json
โ โ โโโ InDatePickerV2.json
โ โ โโโ InSelect.json
โ โโโ migrations/ # V1โV2 guides
โ โโโ InDatePicker-to-V2.json
โ
โโโ ๐ scripts/ # Extraction scripts
โ โโโ extract-components.ts # Vue component parser
โ โโโ extract-storybook.ts # Example extractor
โ โโโ extract-usage.ts # Usage analyzer
โ โโโ merge-datasets.ts # Dataset combiner
โ
โโโ ๐ data/ # Extracted data
โ โโโ components.json # 148 KB - Parsed components
โ โโโ storybook.json # 1.6 KB - Examples
โ โโโ usage.json # Real usage data
โ โโโ combined.json # 209 KB - โญ FINAL DATASET
โ
โโโ ๐ dist/ # Build output
โโโ index.js # Bundled MCP server
โโโ data/combined.json # Runtime dataset
```
---
## ๐ Update Workflow
### When Design System Changes
```bash
# 1. Pull latest Design System
cd /path/to/insider-design-system
git pull
# 2. Re-extract metadata
cd /path/to/design-system-mcp
npm run extract:all # ~5 minutes
# 3. Rebuild MCP server
npm run build
# 4. Test
npm run test:production
# 5. Commit (optional)
git add data/combined.json
git commit -m "chore: update component metadata"
git push
# Claude Desktop will auto-reload! โ
```
**Before**: 2-3 hours manual work
**Now**: 5 minutes automated! ๐
**For more scenarios and detailed workflow guide**, see [WORKFLOW.md](WORKFLOW.md).
---
## ๐ก Key Innovations
### 1. Automated Extraction
No more manual JSON editing. Parser reads Vue files directly.
### 2. Enum Resolution
```javascript
// Source: const STYLES = { SOLID: 'solid', GHOST: 'ghost' }
// Extracted: enums: [{ name: "STYLES", values: {...} }]
// Runtime: validValues: ["solid", "ghost", "text"] โ
```
### 3. Real Usage Intelligence
Scans analytics-fe for common mistakes:
```json
{
"mistake": "Using number for iconSize",
"occurrences": 12,
"fix": "Use string: icon-size=\"24\"",
"severity": "critical"
}
```
### 4. Layered Enrichment
```
Auto-extracted (100% coverage)
+
Manual enrichments (critical details)
=
Best of both worlds! โ
```
---
## ๐ Data Quality
```
Components: 62 (100% coverage)
Props: 1,087 (with types, defaults, validators)
Enums: 30 (automatically detected)
Emits: 170
Manual Enrichments: 3 (InButtonV2, InDatePickerV2, InSelect)
Migration Guides: 1
File Size: 209 KB (combined.json)
```
---
## ๐ฏ Benefits
### For Developers
- โ
Accurate component information
- โ
Enum values always correct
- โ
Common mistakes documented
- โ
Real usage examples
- โ
Fast code generation
### For Design System Team
- โ
Zero manual maintenance
- โ
Always synchronized with source
- โ
Easy updates (5 minutes)
- โ
Automatic mistake detection
### Expected Impact
- Code Generation Accuracy: 30% โ **85%**
- First-Try Correctness: 20% โ **80%**
- Onboarding Time: **-70%**
- Design System Questions: **-50%**
---
## ๐ ๏ธ Development
### Scripts
```bash
# Build
npm run build # Build for production
npm run dev # Watch mode
# Extraction
npm run extract:components # Extract component metadata
npm run extract:storybook # Extract examples
npm run extract:usage # Analyze real usage
npm run extract:merge # Merge all datasets
npm run extract:all # Run all extractions
# Testing
npm test # Run unit tests
npm run test:coverage # Coverage report
npm run test:data # Test dataset validity
npm run test:production # Test production build
# Code Quality
npm run lint # Run ESLint
npm run lint:fix # Fix linting issues
npm run typecheck # TypeScript check
```
### Adding New Enrichments
**Option 1: Use enrichment-maker agent** (Recommended)
```bash
# Let AI generate enrichment for you
# In Claude Code: "Use enrichment-maker agent to create enrichment for InTooltipV2"
# Agent analyzes component and creates:
# - valueFormat for complex props
# - commonMistakes documentation
# - Real-world examples
# - Helper functions
# Then merge and build:
npm run extract:merge
npm run build
```
**Option 2: Manual creation**
```bash
# 1. Create enrichment file
touch src/registry/enrichments/InTooltipV2.json
# 2. Add detailed metadata
# (See existing enrichments: InButtonV2, InDatePickerV2, InSelect)
# 3. Rebuild
npm run extract:merge
npm run build
```
---
## ๐ Documentation
- **README.md** (this file) - Quick start & overview
- **WORKFLOW.md** - โญ **When and how to run extraction scripts**
- **AGENT_USAGE.md** - ๐ค **How to use agents and slash commands**
- **HOW_IT_WORKS.md** - Architecture deep dive
- **COMPLETION_REPORT.md** - Full project report
- **CLEANUP_SUMMARY.md** - Cleanup history
- **CLAUDE.md** - Instructions for Claude Code
---
## ๐ค Contributing
1. Fork the repository
2. Create feature branch: `git checkout -b feature/amazing`
3. Make changes
4. Run tests: `npm test`
5. Commit: `git commit -m "feat: add amazing feature"`
6. Push: `git push origin feature/amazing`
7. Submit Pull Request
---
## ๐ License
UNLICENSED - Internal use only (Insider)
---
## ๐ฌ Support
For questions and issues:
- Create GitHub issue
- Contact Design System team
- Slack: #design-system
---
## ๐ Success Stories
> "Component metadata is now always accurate. Claude generates correct code on first try!"
> โ Developer using MCP
> "We updated 15 components in Design System. Re-extraction took 5 minutes!"
> โ Design System Team
---
**Built with** โค๏ธ **by the Insider Design System Team**
**Powered by**: Claude Code (Sonnet 4.5)
TDQS
Scored across 14 tools
Most tools have clear verb+object distinctions, but several overlap: get-component versus get-props/get-events/get-examples, get-ds-for-figma versus map-figma-component, and generate-code versus generate-figma-component. Descriptions clarify intent somewhat, but an agent could easily select the wrong tool for a similar task.
Tool names uniformly follow lowercase snake_case with a verb-object structure (list/get/search/generate/map/validate/convert). Minor inconsistencies like get-ds-for-figma and the pair generate-figma-component versus convert-figma-to-vue slightly break the pattern but remain predictable.
14 tools is a reasonable count for a design-system documentation and Figma conversion server. However, some tools feel redundant or consolidatable, such as get-ds-for-figma and map-figma-component, making the set slightly heavier than necessary.
The server covers component discovery, detailed documentation, props/events/examples, code generation, and Figma mapping/validation/conversion well. Minor gaps like design tokens, theme variables, or component dependency relationships are missing but not critical for the core workflow.