원클릭으로
huolala-figma-to-code-mcp
Convert Figma designs to high-fidelity UI code via MCP service with AI-powered layout processing
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Convert Figma designs to high-fidelity UI code via MCP service with AI-powered layout processing
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
AI-powered fashion visualization and virtual try-on toolkit for consent-based garment editing and creative design workflows
Transform Markdown into paste-ready WeChat Official Account HTML with 6 themes, auto-numbering, keyword highlighting, and compliance validation
Recognizes and warns against piracy/crack tools disguised as legitimate software
Analyze and identify piracy/crack distribution repositories disguised as legitimate software tools
Analyze and understand software activation mechanisms and digital licensing patterns for educational purposes
Unlock and configure Marvelous Designer 13 for 3D garment simulation with API-driven cloth dynamics
| name | huolala-figma-to-code-mcp |
| description | Convert Figma designs to high-fidelity UI code via MCP service with AI-powered layout processing |
| triggers | ["convert figma design to code","set up figma mcp service","figma to html react vue","design to code with high fidelity","export figma frame as code","configure figma mcp server","use huolala figma service","convert ui design to implementation"] |
Skill by ara.so — Design Skills collection.
Huolala Figma MCP is an MCP service that automatically converts Figma designs into high-fidelity UI code. It uses an intermediate DSL representation, processes designs through a pipeline (system bar removal, red dot detection, icon recognition, layout calculation), and outputs a ZIP package containing HTML, sliced images, fonts, and other assets ready for LLM conversion to target platforms (React, Vue, Swift, Kotlin, React Native, etc.).
The service:
index.html, sliced images, fonts, dsl.json, design screenshotCore workflow: Figma API → DSL → Pipeline (rules engine + optional VLM) → ZIP package
# Clone repository
git clone https://github.com/HuolalaTech/huolala-figma-mcp.git
cd huolala-figma-mcp
# Create virtual environment
python3.11 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .
# Configure environment
cp .env.example .env
# Edit .env and set:
# MDAP_FIGMA_TOKEN=your_figma_token_here
python -m mdap_u2c --port=10001
Service will be available at http://localhost:10001/mcp
Add to your MCP client configuration (e.g., Cursor, Claude Desktop):
{
"mcpServers": {
"ui2code-local": {
"url": "http://localhost:10001/mcp",
"transport": "http"
}
}
}
figma_to_code_packageConverts a Figma design URL to a downloadable ZIP package.
Parameters:
| Parameter | Type | Description |
|---|---|---|
figma_url | string | Full Figma URL with /file/{key}/ or /design/{key}/ and ?node-id= |
image_scale | array | Image scale factors (1-4), e.g., [3, 2] for 3x and 2x |
target_platform | string | Target platform: h5, vue, react, react native, ios, android |
Example call from AI agent:
Use the figma_to_code_package tool with:
- figma_url: https://www.figma.com/design/abc123/MyDesign?node-id=1-2
- image_scale: [3, 2]
- target_platform: react
Response:
{
"zip_url": "http://localhost:10001/download/abc123.zip",
"metadata": {
"node_id": "1-2",
"file_key": "abc123",
"platform": "react"
},
"message": "zip_url 可直接下载"
}
ZIP Contents:
extracted_package/
├── index.html # Rule-based HTML for LLM conversion
├── images/ # Sliced assets, icons
│ ├── icon_001.png
│ └── background_002.png
├── fonts/ # Font files
│ └── CustomFont.ttf
├── dsl.json # Intermediate DSL structure
├── design.png # Original design screenshot
└── vlm_result.json # VLM output (if enabled)
# Required
MDAP_FIGMA_TOKEN=figd_... # Figma Personal Access Token
# Optional VLM (multimodal) support
MDAP_VLM_PROVIDER=openai # Provider: openai, anthropic, etc.
MDAP_VLM_API_KEY=sk-... # API key for VLM
MDAP_VLM_MODEL=gpt-4o # Model name
MDAP_VLM_BASE_URL=https://api.openai.com/v1 # API base URL
# Service configuration
MDAP_PORT=10001 # Service port (default: 10001)
The DSL processing pipeline has configurable processors in src/mdap_u2c/dsl_processors/:
Processors are auto-registered and run in priority order.
Templates in assets/prompts/ standardize MCP tool calls and transcoding workflows.
| Template | MCP Prompt Name | Purpose |
|---|---|---|
get_figma_property.md | get_figma_property | Extract Figma properties (text, styles) for partial UI updates |
ui2code_with_skills.md | ui2code_with_skills | Full UI-to-code: fetch ZIP, adjust components, load Skills, generate code |
/ui2code_with_skills
Then provide:
Copy template content from assets/prompts/*.md into your IDE's Skills/Rules directory.
from mdap_u2c.services.ui2code_service import UI2CodeService
from mdap_u2c.config import config
import asyncio
async def convert_figma():
service = UI2CodeService()
result = await service.figma_to_code_package(
figma_url="https://www.figma.com/design/abc123/MyApp?node-id=1-2",
image_scale=[3, 2],
target_platform="react"
)
print(f"Download ZIP: {result['zip_url']}")
print(f"Metadata: {result['metadata']}")
asyncio.run(convert_figma())
from mdap_u2c.dsl_processors.base import BaseDslProcessor, register_processor
from mdap_u2c.dsl.models import DslComponent
@register_processor
class CustomLayoutProcessor(BaseDslProcessor):
priority = 650 # Run after LayoutProcessor (600)
async def process(self, dsl_component: DslComponent) -> DslComponent:
# Custom layout logic
if dsl_component.type == "container":
# Adjust container properties
dsl_component.layout = "custom-grid"
return dsl_component
from mdap_u2c.figma.client import FigmaClient
from mdap_u2c.config import config
async def get_figma_nodes():
client = FigmaClient(config.figma_token)
# Get file nodes
file_data = await client.get_file(
file_key="abc123",
node_ids=["1:2", "1:3"]
)
# Get images
images = await client.get_images(
file_key="abc123",
node_ids=["1:2"],
scale=3.0
)
return file_data, images
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
const client = new Client({
name: 'figma-converter',
version: '1.0.0'
});
await client.connect(
new StdioClientTransport({
command: 'python',
args: ['-m', 'mdap_u2c', '--port=10001']
})
);
const result = await client.callTool({
name: 'figma_to_code_package',
arguments: {
figma_url: 'https://www.figma.com/design/abc123/App?node-id=1-2',
image_scale: [3, 2],
target_platform: 'react'
}
});
console.log(result.zip_url);
python -m mdap_u2c --port=10001/ui2code_with_skillsreact as targetfigma_to_code_package → receives ZIPindex.html and converts to React components using project SkillsSame workflow, specify vue as target platform. Agent uses Vue-specific Skills from assets/prompts/.
/get_figma_property# Configure VLM in .env
export MDAP_VLM_PROVIDER=openai
export MDAP_VLM_API_KEY=sk-...
export MDAP_VLM_MODEL=gpt-4o
export MDAP_VLM_BASE_URL=https://api.openai.com/v1
# Restart service
python -m mdap_u2c --port=10001
VLM processor will now detect lists, repeating components, and complex layouts automatically.
Batch-test multiple Figma URLs and generate HTML similarity reports:
# Install test dependencies
pip install ".[ui2code-test]"
playwright install chromium
# Configure test URLs in tests/test_url_list.txt
# Each line: figma_url|node_id|platform
# Run tests
python tests/ui2code_auto_test.py
Test output includes visual comparison screenshots and similarity scores.
# Start service
python -m mdap_u2c --port=10001
# In another terminal, test MCP endpoint
curl http://localhost:10001/health
# Should return: {"status": "healthy"}
# Test tool via HTTP (if HTTP transport enabled)
curl -X POST http://localhost:10001/mcp \
-H "Content-Type: application/json" \
-d '{
"method": "tools/call",
"params": {
"name": "figma_to_code_package",
"arguments": {
"figma_url": "https://www.figma.com/design/abc/test?node-id=1-2",
"image_scale": [2],
"target_platform": "h5"
}
}
}'
Problem: ModuleNotFoundError or import errors
Solution:
# Ensure virtual environment is activated
source venv/bin/activate # or venv\Scripts\activate on Windows
# Reinstall in editable mode
pip install -e .
Problem: 401 Unauthorized errors
Solution:
.env matches your Figma Personal Access TokenProblem: Client shows "Connection refused"
Solution:
# Check service is running
curl http://localhost:10001/health
# Verify port in client config matches service port
# Default is 10001, change with:
python -m mdap_u2c --port=8080
Problem: zip_url returns 404
Solution:
Problem: Generated HTML doesn't match design
Solution:
dsl.json in ZIP to verify DSL structureimage_scale to [3, 2] for higher resolution assetsdesign.png vs output to identify specific issuesProblem: VLM processor skipped or errors
Solution:
# Verify all VLM env vars are set
echo $MDAP_VLM_PROVIDER
echo $MDAP_VLM_API_KEY
echo $MDAP_VLM_MODEL
# Test VLM API separately
curl $MDAP_VLM_BASE_URL/chat/completions \
-H "Authorization: Bearer $MDAP_VLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "test"}]}'
Problem: Service crashes or slows on large Figma files
Solution:
Problem: ZIP contains no fonts or fonts don't render
Solution:
assets/fonts/assets/fonts/ directoryhuolala-figma-mcp/
├── src/mdap_u2c/
│ ├── figma/ # Figma API client, node parsing
│ ├── dsl_processors/ # Pipeline processors (8 steps)
│ ├── services/ # FigmaService, UI2CodeService, ExportService
│ ├── server/ # FastMCP server, MCP tools/prompts
│ ├── dsl/ # DSL models and utilities
│ └── config/ # Configuration management
├── assets/
│ ├── fonts/ # Font files
│ ├── prompts/ # MCP prompt templates
│ └── cv_templates/ # Computer vision templates
├── tests/
│ ├── ui2code_auto_test.py # Automated comparison testing
│ └── test_url_list.txt # Test Figma URLs
└── pyproject.toml # Dependencies and metadata
Create platform-specific conversion skills in assets/prompts/skills/:
# assets/prompts/skills/react_native_skill.md
## React Native Conversion Rules
When converting to React Native:
- Use `View` instead of `div`
- Use `Text` for all text content
- Use `StyleSheet.create()` for styles
- Convert `px` to responsive units
- Use `Image` with `source` prop for assets
Reference in main prompt template to load conditionally.
Add custom processors by subclassing BaseDslProcessor:
from mdap_u2c.dsl_processors.base import BaseDslProcessor, register_processor
@register_processor
class AccessibilityProcessor(BaseDslProcessor):
priority = 700 # After layout, before export
async def process(self, dsl_component):
# Add accessibility labels
if dsl_component.type == "image":
dsl_component.properties["aria-label"] = "Generated image"
return dsl_component
Processor runs automatically when registered.
Additional Resources: