ds-mcp-sync
Syncs design tokens and components from Figma to a Design System codebase, enabling automated generation of React components and Storybook stories.
README
DS MCP Sync Server
An MCP (Model Context Protocol) server that enables seamless synchronization between your Figma design system and your Design System codebase.
Features
- 🎨 Design Token Sync - Extract colors, typography, spacing, and shadows from Figma styles
- 🧩 Component Generation - Automatically generate React components from Figma components
- 📚 Storybook Integration - Auto-generate Storybook stories with all component variants
- ⚛️ Atomic Design - Maps Figma components to atoms, molecules, and organisms
- 🔄 Incremental Updates - Only sync what has changed
- 🔍 Smart Analysis - Learns from existing component patterns
Installation
- Clone and install dependencies:
git clone <repository-url>
cd ds-mcp-sync
npm install
npm run build
- Configure your credentials:
Create a config/mcp-config.json file or set environment variables:
{
"figma": {
"fileId": "your-figma-file-id",
"accessToken": "your-figma-personal-access-token",
"componentPrefix": "DS"
},
"mds": {
"rootPath": "../design-system",
"componentPath": "component-lib/components",
"tokenPath": "component-lib/tokens",
"storybookPath": "component-lib/.storybook"
}
}
Environment Variables (alternative):
export FIGMA_ACCESS_TOKEN="your-token-here"
export FIGMA_FILE_ID="your-file-id"
export DS_ROOT_PATH="../design-system"
Getting Figma Credentials
1. Get Figma Personal Access Token
- Go to Figma Account Settings
- Scroll to "Personal Access Tokens"
- Click "Create a new personal access token"
- Give it a name (e.g., "DS Sync") and create
- Copy the token and add it to your config
2. Get Figma File ID
From your Figma design system URL:
https://www.figma.com/file/ABC123DEF456/Design-System
^^^^^^^^^^^^
This is your file ID
MCP Integration with Claude Code
Add this server to your Claude Code MCP configuration:
macOS/Linux: ~/.claude_mcp.json
Windows: %APPDATA%\Claude\claude_mcp.json
{
"mcpServers": {
"ds-mcp-sync": {
"command": "node",
"args": ["/path/to/ds-mcp-sync/dist/index.js"],
"env": {
"FIGMA_ACCESS_TOKEN": "your-token",
"FIGMA_FILE_ID": "your-file-id"
}
}
}
}
Usage with Claude Code
Once configured, you can use these commands in Claude Code:
Check for Updates
claude "Check if there are any new components in Figma"
Sync Design Tokens
claude "Sync design tokens from Figma to DS"
Generate Specific Component
claude "Generate the Button component from Figma"
Full Synchronization
claude "Sync all new components from Figma to DS"
Validate Setup
claude "Validate the MCP server setup"
Available MCP Tools
| Tool | Description |
|---|---|
check_figma_updates |
Compare Figma with current DS and report differences |
sync_tokens |
Extract and update design tokens from Figma styles |
generate_component |
Create a specific component with TypeScript and stories |
sync_all |
Perform complete synchronization (with optional dry-run) |
validate_setup |
Test Figma connection and validate configuration |
How It Works
1. Design Token Extraction
- Fetches color, typography, and effect styles from Figma
- Converts to DS token format (
colors.primary.500) - Updates
component-lib/tokens/tokens.ts
2. Component Analysis
- Scans Figma components and their variants
- Determines atomic level (atoms/molecules/organisms) based on name and structure
- Extracts component properties and maps to TypeScript props
3. Code Generation
- Generates React components following DS patterns
- Creates TypeScript interfaces with proper typing
- Adds theme provider integration
- Generates comprehensive Storybook stories
4. File Organization
component-lib/
├── components/
│ ├── atoms/
│ │ └── Button/
│ │ ├── Button.tsx
│ │ ├── Button.stories.tsx
│ │ └── index.ts
│ ├── molecules/
│ └── organisms/
└── tokens/
└── tokens.ts
Component Mapping Rules
| Figma Component | Atomic Level | Reason |
|---|---|---|
| Button, Input, Icon | Atoms | Basic UI elements |
| Card, Modal, Dropdown | Molecules | Groups of atoms |
| Header, Table, Navigation | Organisms | Complex layouts |
Configuration Options
{
"figma": {
"fileId": "string", // Required: Figma file ID
"accessToken": "string", // Required: Personal access token
"componentPrefix": "string" // Optional: Filter components by prefix
},
"mds": {
"rootPath": "string", // Path to MDS root directory
"componentPath": "string", // Relative path to components
"tokenPath": "string", // Relative path to tokens
"storybookPath": "string" // Relative path to Storybook config
},
"dryRun": false, // Run without making file changes
"verbose": true // Enable detailed logging
}
Troubleshooting
Common Issues
"Figma API connection failed"
- Verify your personal access token
- Check that the token has access to the file
- Ensure the file ID is correct
"DS paths not accessible"
- Verify the
rootPathpoints to your DS directory - Check that component directories exist
- Ensure write permissions
"Component generation failed"
- Check that the Figma component has proper naming
- Verify component properties are set up correctly
- Look for TypeScript compilation errors
Debug Mode
Set verbose: true in config or VERBOSE=true environment variable for detailed logging.
Development
# Development mode with hot reload
npm run dev
# Build for production
npm run build
# Run linting
npm run lint
# Type checking
npm run typecheck
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Need help? Check the troubleshooting section or create an issue on GitHub.# ds-mcp-sync
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。