Figma to React MCP

Figma to React MCP

Automates the conversion of Figma designs into TypeScript React components and integrates with GitHub to create pull requests for the generated code. It includes visual regression testing with Playwright and accessibility validation to ensure implementations match the original designs.

Category
访问服务器

README

Figma to React MCP

A powerful MCP (Model Context Protocol) server that converts Figma designs into React components automatically. Combines GitHub, Figma, and Playwright integrations for a seamless design-to-React workflow.

Latest Updates: Enhanced performance optimizations, browser pooling, request caching, and improved error handling for production-ready workflows.

✨ Features

  • 🎨 Figma Integration: Extract designs, components, and design tokens from Figma files
  • 🐙 GitHub Integration: Create branches, generate pull requests, and manage repository operations
  • 🎭 Playwright Integration: Automated visual testing and browser automation
  • ⚛️ React-Focused: Generates TypeScript React functional components with proper typing
  • 🔄 Automated Workflow: Figma design → React component → GitHub PR in one step
  • 📦 NPX Distribution: Easy installation and setup via npx

🚀 Quick Start

Easy Installation with npx

# Interactive setup (recommended for first-time users)
npx figma-to-react-mcp --setup

# Or run directly if you have tokens configured
GITHUB_TOKEN=xxx FIGMA_ACCESS_TOKEN=yyy npx figma-to-react-mcp

The --setup command will:

  • Prompt for your GitHub and Figma tokens
  • Configure environment variables
  • Set up Cursor MCP integration automatically
  • Create all necessary configuration files

Manual Setup

  1. Get your API tokens:

    • GitHub: Go to Settings → Developer settings → Personal access tokens → Generate new token with repo permissions
    • Figma: Go to Figma Settings → Account → Personal access tokens → Generate new token
  2. Run with environment variables:

    GITHUB_TOKEN=your_github_token FIGMA_ACCESS_TOKEN=your_figma_token npx figma-to-react-mcp
    

🛠️ Available Tools

1. design_to_code

Converts Figma designs to React TypeScript components and creates GitHub PRs.

What you get:

  • React functional component with TypeScript
  • Responsive CSS styles
  • Proper component structure and props
  • Automatic GitHub branch and PR creation

Example usage in Cursor:

  • Paste a Figma URL: https://www.figma.com/file/abc123/Design?node-id=1%3A2
  • Specify component name: HeroButton
  • Get a complete React component with GitHub PR

2. test_design_implementation

Tests generated React components against Figma designs using visual regression testing and accessibility validation.

3. analyze_figma_design

Analyzes Figma designs and extracts design tokens, components, and structure.

4. create_design_pr

Creates GitHub PRs with generated React components and comprehensive test results.

5. setup_project_branch

Creates new GitHub branches for feature development.

📋 CLI Commands

npx figma-to-react-mcp --setup    # Interactive setup
npx figma-to-react-mcp --help     # Show help
npx figma-to-react-mcp --version  # Show version
npx figma-to-react-mcp            # Start MCP server

⚙️ Cursor Integration

After running npx figma-to-react-mcp --setup, the MCP server will be automatically configured in Cursor.

Manual Cursor Setup (if needed): Add this to your Cursor MCP settings:

{
  "mcpServers": {
    "figma-to-react-mcp": {
      "command": "npx",
      "args": ["figma-to-react-mcp"],
      "env": {
        "GITHUB_TOKEN": "your_github_token_here",
        "FIGMA_ACCESS_TOKEN": "your_figma_token_here"
      }
    }
  }
}

🔧 Configuration

Environment Variables

Required:

  • GITHUB_TOKEN: GitHub Personal Access Token with repo permissions
  • FIGMA_ACCESS_TOKEN: Figma Access Token from your account settings

Optional:

  • LOG_LEVEL: Logging level (debug, info, warn, error) - default: info
  • PLAYWRIGHT_BROWSER: Browser to use (chromium, firefox, webkit) - default: chromium

📚 Usage Examples

Basic Workflow

  1. Setup once:

    npx figma-to-react-mcp --setup
    
  2. In Cursor, use the MCP tools:

    • Open a Figma design
    • Copy the URL (with node selection)
    • Use the design_to_code tool
    • Get a React component + GitHub PR automatically

Design to Code Flow

Figma Design URL → Extract Design Tokens → Generate React Component → Run Tests → GitHub PR
                                          ↓
                              TypeScript + CSS + Tests

🚀 Release Management

This package includes multiple approaches for version management:

Interactive Release (Recommended)

# Guided release with prompts
npm run release

Quick Analysis

# Analyze commits to suggest version bump
npm run release:analyze

Commit Helper

# Interactive commit message creation with conventional commits
npm run commit

Direct Release

npm run release:patch   # Bug fixes
npm run release:minor   # New features
npm run release:major   # Breaking changes

GitHub Actions

Use the "Manual Release" workflow in GitHub Actions for team releases.

📖 Complete Release Guide

🏗️ Development

Local Development

git clone <your-repo>
cd figma-to-react-mcp
npm install
npm run build
npm run dev

Testing

npm test
npm run test:watch
npm run test:coverage

📦 Publishing

To publish your own version:

  1. Update package.json with your package name
  2. Build the project: npm run build
  3. Publish: npm publish

🛠️ Architecture

  • MCP SDK: Model Context Protocol implementation
  • TypeScript: Type-safe development
  • Playwright: Browser automation and testing
  • Octokit: GitHub API integration
  • Axios: HTTP client for Figma API
  • Zod: Runtime type validation

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🆘 Support

For issues and questions:

  • Create an issue in the GitHub repository
  • Run npx figma-to-react-mcp --help for CLI help
  • Check the interactive setup: npx figma-to-react-mcp --setup

Happy coding! 🎨➡️💻

Made with ❤️ for frontend developers who want to automate their design-to-code workflow.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选