Pixelbyte Figma MCP Server

Pixelbyte Figma MCP Server

Enables seamless integration with Figma API for extracting design tokens, generating production-ready code in multiple frameworks, capturing screenshots, and managing design assets directly from Figma.

Category
访问服务器

README

🎨 Pixelbyte Figma MCP Server

Python 3.10+ License: MIT MCP

A powerful Model Context Protocol (MCP) server for seamless Figma API integration. Extract design tokens, generate production-ready code, capture screenshots, and manage Code Connect mappings directly from your Figma designs.

✨ Features

Feature Description
🛠️ 12 MCP Tools Complete Figma integration toolkit
💻 10 Code Frameworks React, Vue, Tailwind, CSS, SCSS, SwiftUI, Kotlin
🎨 Design Tokens Extract colors, typography, spacing, effects
🌈 Gradient Support Linear, radial, angular, diamond gradients
🔄 Transform & Effects Rotation, blend modes, shadows, blurs
🌳 Nested Children Full component tree with all styles preserved
📸 Screenshot Export PNG, SVG, JPG, PDF formats with scale control
🔗 Code Connect Map Figma components to code implementations
📦 Asset Management List, export, and download design assets

📦 Installation

From GitHub (Recommended)

pip install git+https://github.com/Rylaa/pixelbyte-figma-mcp.git

From PyPI

pip install pixelbyte-figma-mcp

From Source

git clone https://github.com/Rylaa/pixelbyte-figma-mcp.git
cd pixelbyte-figma-mcp
pip install -e .

⚙️ Setup

1. Get Figma Access Token

  1. Go to Figma Account Settings
  2. Scroll to Personal Access Tokens
  3. Click Generate new token
  4. Copy the token (you won't see it again!)

2. Configure Environment

Option A: Environment Variable

export FIGMA_ACCESS_TOKEN="figd_xxxxxxxxxxxxxxxxxxxxxx"

Option B: .env File

# .env
FIGMA_ACCESS_TOKEN=figd_xxxxxxxxxxxxxxxxxxxxxx

3. Add to Claude Code

Add to your Claude Code settings (~/.claude/settings.json):

{
  "mcpServers": {
    "pixelbyte-figma-mcp": {
      "command": "pixelbyte-figma-mcp",
      "env": {
        "FIGMA_ACCESS_TOKEN": "figd_xxxxxxxxxxxxxxxxxxxxxx"
      }
    }
  }
}

4. Verify Installation

# Check if installed correctly
pixelbyte-figma-mcp --help

🛠️ Available Tools

File & Node Tools

Tool Description Parameters
figma_get_file_structure Get file hierarchy and node tree file_key, depth (1-10), response_format
figma_get_node_details Get detailed node properties file_key, node_id, response_format
figma_get_screenshot Export nodes as images file_key, node_ids[], format, scale

Design Token Tools

Tool Description Parameters
figma_get_design_tokens Extract all design tokens with ready-to-use code file_key, node_id, include_* flags, include_generated_code
figma_get_styles Get published styles from file file_key, include_* flags

Code Generation Tools

Tool Description Parameters
figma_generate_code Generate production-ready code file_key, node_id, framework, component_name

Code Connect Tools

Tool Description Parameters
figma_get_code_connect_map Get stored Code Connect mappings file_key, node_id (optional)
figma_add_code_connect_map Add/update a mapping file_key, node_id, component_path, component_name, props_mapping, variants, example
figma_remove_code_connect_map Remove a mapping file_key, node_id

Asset Management Tools

Tool Description Parameters
figma_list_assets List all exportable assets (images, vectors, exports) file_key, node_id (optional), include_images, include_vectors, include_exports
figma_get_images Get actual download URLs for image fills file_key, node_id (optional)
figma_export_assets Batch export nodes with SVG generation file_key, node_ids[], format, scale, include_svg_for_vectors

💻 Code Generation

Generate production-ready code for 10 frameworks with comprehensive style support.

Supported Styles

Style Feature CSS/SCSS React/Vue SwiftUI Kotlin
Solid Colors
Linear Gradients
Radial Gradients
Individual Corner Radii
Rotation/Transform
Blend Modes
Opacity
Drop Shadows
Inner Shadows - -
Layer Blur
Background Blur - -
Auto Layout

Supported Frameworks

Framework Output Best For
react React + inline styles Quick prototypes
react_tailwind React + Tailwind CSS Production React apps
vue Vue 3 + scoped CSS Vue.js projects
vue_tailwind Vue 3 + Tailwind CSS Vue + Tailwind projects
html_css HTML + CSS Static sites
tailwind_only Tailwind classes only Copy-paste styling
css Pure CSS Framework-agnostic
scss SCSS with variables Complex styling
swiftui iOS SwiftUI Views iOS development
kotlin Android Jetpack Compose Android development

Example Usage

# Generate React + Tailwind component
figma_generate_code(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_id="1707:6176",
    framework="react_tailwind",
    component_name="HeroSection"
)

# Generate SwiftUI View
figma_generate_code(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_id="1707:6176",
    framework="swiftui"
)

# Generate Android Compose
figma_generate_code(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_id="1707:6176",
    framework="kotlin"
)

Generated Code Example

Input: A Figma button with gradient, shadow, and rounded corners

Output (CSS):

.hero-button {
  width: 200px;
  height: 48px;
  background: linear-gradient(90deg, #3B82F6 0%, #8B5CF6 100%);
  border-radius: 8px 8px 16px 16px;
  box-shadow: 0px 4px 12px 0px rgba(59, 130, 246, 0.40);
  transform: rotate(0deg);
  opacity: 1;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
}

🎨 Design Token Extraction

Extract design tokens in a structured format with ready-to-use CSS, SCSS, and Tailwind code.

All-in-One Token Extraction

figma_get_design_tokens(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_id="1707:6176",
    include_colors=True,
    include_typography=True,
    include_spacing=True,
    include_effects=True,
    include_generated_code=True  # NEW in v2.0!
)

Output:

{
  "$schema": "https://design-tokens.github.io/community-group/format/",
  "figmaFile": "qyFsYyLyBsutXGGzZ9PLCp",
  "tokens": {
    "colors": [
      {
        "name": "Button Background",
        "value": "#3B82F6",
        "hex": "#3B82F6",
        "rgb": "59, 130, 246",
        "hsl": "217, 91%, 60%",
        "contrast": { "white": 3.02, "black": 6.96 }
      }
    ],
    "typography": [...],
    "spacing": [...],
    "shadows": [...],
    "blurs": [...]
  },
  "generated": {
    "css_variables": ":root {\n  --color-button-background: #3B82F6;\n  ...\n}",
    "scss_variables": "$color-button-background: #3B82F6;\n...",
    "tailwind_config": "module.exports = {\n  theme: {\n    extend: {\n      colors: {\n        'button-background': '#3B82F6'\n      }\n    }\n  }\n}"
  }
}

Rich Color Information

Every extracted color now includes:

Property Description Example
hex Hexadecimal color #3B82F6
rgb RGB values 59, 130, 246
hsl HSL values 217, 91%, 60%
contrast.white WCAG contrast ratio vs white 3.02
contrast.black WCAG contrast ratio vs black 6.96

Ready-to-Use Generated Code

The generated section provides copy-paste ready code:

CSS Variables:

:root {
  --color-button-background: #3B82F6;
  --color-card-bg: #FFFFFF;
  --font-inter-16: 16px/24px 'Inter';
  --spacing-card: 24px 24px 24px 24px;
  --shadow-card: 0px 4px 12px rgba(0, 0, 0, 0.1);
}

SCSS Variables:

$color-button-background: #3B82F6;
$color-card-bg: #FFFFFF;
$font-inter-size: 16px;
$font-inter-weight: 500;

Tailwind Config:

module.exports = {
  theme: {
    extend: {
      colors: {
        'button-background': '#3B82F6',
        'card-bg': '#FFFFFF'
      }
    }
  }
}

Published Styles

figma_get_styles(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    include_fill_styles=True,
    include_text_styles=True,
    include_effect_styles=True
)

Output:

{
  "fill_styles": [
    {
      "key": "abc123",
      "name": "Primary/500",
      "description": "Primary brand color",
      "fills": [{"type": "SOLID", "color": "#3B82F6"}]
    }
  ],
  "text_styles": [
    {
      "key": "def456",
      "name": "Heading/H1",
      "fontFamily": "Inter",
      "fontSize": 32,
      "fontWeight": 700
    }
  ],
  "effect_styles": [...]
}

🔗 Code Connect

Map Figma components to your actual code implementations for better AI-assisted code generation.

Why Code Connect?

  • 🎯 Accurate code generation - AI knows your component paths and props
  • 🔄 Consistent mappings - Link design to code once, use everywhere
  • 📚 Example snippets - Provide usage examples for better context

Add a Mapping

figma_add_code_connect_map(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_id="1707:6176",
    component_path="src/components/ui/Button.tsx",
    component_name="Button",
    props_mapping={
        "Variant": "variant",      # Figma prop -> Code prop
        "Size": "size",
        "Disabled": "disabled"
    },
    variants={
        "primary": {"variant": "primary", "className": "bg-blue-500"},
        "secondary": {"variant": "secondary", "className": "bg-gray-500"},
        "outline": {"variant": "outline", "className": "border-2"}
    },
    example="<Button variant='primary' size='md'>Click me</Button>"
)

Get Mappings

# Get all mappings for a file
figma_get_code_connect_map(
    file_key="qyFsYyLyBsutXGGzZ9PLCp"
)

# Get specific node mapping
figma_get_code_connect_map(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_id="1707:6176"
)

Remove a Mapping

figma_remove_code_connect_map(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_id="1707:6176"
)

Storage Configuration

Setting Default Description
Storage Path ~/.config/pixelbyte-figma-mcp/code_connect.json Local JSON storage
Custom Path FIGMA_CODE_CONNECT_PATH env variable Override default path

📸 Screenshot Export

Export Figma nodes as images in multiple formats. Screenshots are automatically downloaded and saved locally for easy access.

figma_get_screenshot(
    file_key="qyFsYyLyBsutXGGzZ9PLCp",
    node_ids=["1707:6176", "1707:6200"],
    format="png",   # png, svg, jpg, pdf
    scale=2.0       # 0.01 to 4.0
)

Output:

# Generated Screenshots
**Format:** PNG
**Scale:** 2x

## Local Files

- **1707:6176**: `/tmp/figma_screenshots/qyFsYyLyBsutXGGzZ9PLCp_1707-6176_20260113_143022.png`
- **1707:6200**: `/tmp/figma_screenshots/qyFsYyLyBsutXGGzZ9PLCp_1707-6200_20260113_143022.png`

> Screenshots saved to: `/tmp/figma_screenshots`

Screenshots are saved to a temporary directory and can be directly read by Claude Code's Read tool for visual analysis.


🔑 Getting File Key and Node ID

File Key

From your Figma URL:

https://www.figma.com/design/qyFsYyLyBsutXGGzZ9PLCp/My-Design
                              ^^^^^^^^^^^^^^^^^^^^^^
                              This is the file_key

Node ID

  1. Select a layer in Figma
  2. Right-click → Copy link
  3. The URL contains node-id=1707-6176
  4. Use 1707:6176 or 1707-6176 (both work)

📝 Changelog

v2.4.0

  • feat: smart file structure filtering with include_empty_frames, min_children_count, mark_downloadable_assets options
  • feat: asset detection indicator (hasAsset) in file structure tree
  • fix: prevent KeyError in figma_get_images by disabling icon collection
  • fix: add microseconds to timestamps to prevent filename collisions
  • fix: improve exception handling specificity in download functions

v2.3.6

  • feat: download assets locally for figma_export_assets and figma_get_images

v2.3.5

  • feat: save screenshots locally for Claude Code compatibility

v2.3.4

  • feat: smart asset detection for figma_list_assets

🌍 Environment Variables

Variable Required Description
FIGMA_ACCESS_TOKEN ✅ Yes Figma Personal Access Token
FIGMA_TOKEN ⚡ Alternative Alternative token variable name
FIGMA_CODE_CONNECT_PATH ❌ No Custom Code Connect storage path

📋 Requirements

  • Python 3.10+
  • Figma account with API access
  • Personal Access Token

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

MIT License - see LICENSE for details.


👤 Author

Yusuf Demirkoparan - @PixelByte


🔗 Links

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选