Figma Context

by 1yhy

8 stars
338 downloads
Not rated
GitHub

About

Bridges AI systems with Figma design platform, transforming complex API responses into structured design information for easier understanding of layout properties, styling, and text content.

Details

Author
1yhy
Repository
1yhy/Figma-Context-MCP
GitHub stars
8
Downloads
338
License
MIT License
Categories
Productivity, Developer Tools, Design, File Management, AI, Media, Knowledge Base, Infrastructure, Communication, API, Other, Frontend
Tags
#figma

| Capability | Description |
| ------------------------------- | ------------------------------------------------------------------- |
| Smart Layout Detection | Automatically infers Flexbox/Grid layouts from absolute positioning |
| Icon Merging | Intelligently merges vector layers into single exportable icons |
| CSS Generation | Converts Figma styles to clean, usable CSS |
| Image Export | Downloads images and icons with proper naming |
| Multi-layer Caching | L1 memory + L2 disk cache to reduce API calls |
| Design-to-Code Prompts | Built-in professional prompt templates to guide AI code generation |
| Lightweight Resource Access | Resources API provides low-token data access |

This server provides full MCP capabilities support:

┌─────────────────────────────────────────────────────────────┐
│                  Figma MCP Server v1.1.0                    │
├─────────────────────────────────────────────────────────────┤
│  Tools (2)                        AI-invoked operations     │
│  ├── get_figma_data              Fetch design data          │
│  └── download_figma_images       Download image assets      │
├─────────────────────────────────────────────────────────────┤
│  Prompts (3)                      User-selected templates   │
│  ├── design_to_code              Full design-to-code flow   │
│  ├── analyze_components          Component structure        │
│  └── extract_styles              Style token extraction     │
├─────────────────────────────────────────────────────────────┤
│  Resources (5)                    Lightweight data sources  │
│  ├── figma://help                Usage guide                │
│  ├── figma://file/{key}          File metadata (~200 tok)   │
│  ├── figma://file/{key}/styles   Design tokens (~500 tok)   │
│  ├── figma://file/{key}/components Component list (~300 tok)│
│  └── figma://file/{key}/assets   Asset inventory (~400 tok) │
└─────────────────────────────────────────────────────────────┘

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Figma Context
    Command (node, npx, python, etc.) npx
    Arguments
    • Argument 1 -y
    • Argument 2 @yhy2001/figma-mcp-server
    • Argument 3 --stdio
    Environment
    • FIGMA_API_KEY your-figma-api-key

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

<details>
<summary><strong>Cursor / Windsurf / Cline</strong></summary>

Add to your MCP configuration file:

{
  "mcpServers": {
    "Figma": {
      "command": "npx",
      "args": ["-y", "@yhy2001/figma-mcp-server", "--stdio"],
      "env": {
        "FIGMA_API_KEY": "your-figma-api-key"
      }
    }
  }
}

</details>

<details>
<summary><strong>HTTP/SSE Mode (Local Development)</strong></summary>


FIGMA_API_KEY=<your-key> pnpm start

figma-mcp --figma-api-key=<your-key> --port=3333


Please implement this Figma design: https://www.figma.com/design/abc123/MyDesign?node-id=1:234

Use React and Tailwind CSS.
```

---

get_figma_data

Fetch simplified design data. Parameters: fileKey (string), nodeId (optional string), depth (optional number)

download_figma_images

Download images and icons. Parameters: fileKey (string), nodes (array of strings), localPath (string)

| Tool | Description | Parameters |
| ----------------------- | ---------------------------- | --------------------------------- |
| get_figma_data | Fetch simplified design data | fileKey, nodeId?, depth? |
| download_figma_images | Download images and icons | fileKey, nodes[], localPath |

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "figma context": {
            "env": {
                "FIGMA_API_KEY": "your-figma-api-key"
            },
            "args": [
                "-y",
                "@yhy2001/figma-mcp-server",
                "--stdio"
            ],
            "command": "npx"
        }
    }
}

Linux

{
    "env": {
        "FIGMA_API_KEY": "your-figma-api-key"
    },
    "args": [
        "-y",
        "@yhy2001/figma-mcp-server",
        "--stdio"
    ],
    "command": "npx"
}

Macos

{
    "env": {
        "FIGMA_API_KEY": "your-figma-api-key"
    },
    "args": [
        "-y",
        "@yhy2001/figma-mcp-server",
        "--stdio"
    ],
    "command": "npx"
}

Windows

{
    "env": {
        "FIGMA_API_KEY": "your-figma-api-key"
    },
    "args": [
        "/c",
        "npx",
        "-y",
        "@yhy2001/figma-mcp-server",
        "--stdio"
    ],
    "command": "cmd"
}

Features•Quick Start•MCP Capabilities•Architecture•Documentation•中文文档

Figma Context MCP is aModel Context Protocol (MCP)server that bridges Figma designs with AI coding assistants likeCursor,Windsurf, andCline.

When AI tools can access Figma design data directly, they generate more accurate code on the first try—far better than using screenshots.

Note: This project is based onFigma-Context-MCP, with optimized data structures and intelligent layout detection algorithms.

- Node.js >= 18.0.0
- A Figma account with API access

npx -y @smithery/cli install @1yhy/Figma-Context-MCP --client claude
npm install -g @yhy2001/figma-mcp-server
git clone https://github.com/1yhy/Figma-Context-MCP.git cd Figma-Context-MCP pnpm install pnpm build

- Go toFigma Account Settings
- Scroll to "Personal access tokens"
- Click "Create new token"
- Copy the token

{ "mcpServers": { "Figma": { "command": "npx", "args": ["-y", "@yhy2001/figma-mcp-server", "--stdio"], "env": { "FIGMA_API_KEY": "your-figma-api-key" } } } }
# From source (development) cp .env.example .env # Add FIGMA_API_KEY to .env pnpm install && pnpm build pnpm start # Starts on port 3333 # Or with environment variable FIGMA_API_KEY=<your-key> pnpm start # Or via global install figma-mcp --figma-api-key=<your-key> --port=3333 # Connect via SSE # URL: http://localhost:3333/sse
Please implement this Figma design: https://www.figma.com/design/abc123/MyDesign?node-id=1:234 Use React and Tailwind CSS.

This server provides full MCP capabilities support:

┌─────────────────────────────────────────────────────────────┐ │ Figma MCP Server v1.1.0 │ ├─────────────────────────────────────────────────────────────┤ │ Tools (2) AI-invoked operations │ │ ├── get_figma_data Fetch design data │ │ └── download_figma_images Download image assets │ ├─────────────────────────────────────────────────────────────┤ │ Prompts (3) User-selected templates │ │ ├── design_to_code Full design-to-code flow │ │ ├── analyze_components Component structure │ │ └── extract_styles Style token extraction │ ├─────────────────────────────────────────────────────────────┤ │ Resources (5) Lightweight data sources │ │ ├── figma://help Usage guide │ │ ├── figma://file/{key} File metadata (~200 tok) │ │ ├── figma://file/{key}/styles Design tokens (~500 tok) │ │ ├── figma://file/{key}/components Component list (~300 tok)│ │ └── figma://file/{key}/assets Asset inventory (~400 tok) │ └─────────────────────────────────────────────────────────────┘

Built-in professional prompt templates to help AI generate high-quality code:
- Project Analysis- Read theme config, global styles, component library
- Structure Analysis- Identify page patterns, component splitting strategy
- ASCII Layout Blueprint- Generate layout diagram with component and asset annotations
- Asset Management- Analyze, download, and organize images/icons
- Code Generation- Generate code following project conventions
- Accessibility Optimization- Semantic HTML, ARIA labels
- Responsive Adaptation- Mobile layout adjustments

# Get file metadata (~200 tokens) figma://file/abc123 # Get design tokens (~500 tokens) figma://file/abc123/styles # Get component list (~300 tokens) figma://file/abc123/components # Get asset inventory (~400 tokens) figma://file/abc123/assets
┌──────────────────────────────────────────────────────────────┐ │ MCP Server │ ├──────────────────────────────────────────────────────────────┤ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │ │ │ Tools │ │ Prompts │ │ Resources │ │ │ │ (2 tools) │ │ (3 prompts) │ │ (5 resources) │ │ │ └──────┬──────┘ └─────────────┘ └──────────┬──────────┘ │ │ │ │ │ │ └──────────────────┬───────────────────┘ │ │ ▼ │ │ ┌────────────────────────────────────────────────────────┐ │ │ │ FigmaService │ │ │ │ API Calls • Validation • Error Handling │ │ │ └────────────────────────┬───────────────────────────────┘ │ │ │ │ │ ┌─────────────────┴─────────────────┐ │ │ ▼ ▼ │ │ ┌─────────────────┐ ┌─────────────────────┐ │ │ │ CacheManager │ │ Parser + Algo │ │ │ │ L1: LRU Memory │ │ • Layout Detection │ │ │ │ L2: Disk Store │ │ • Icon Merging │ │ │ └─────────────────┘ │ • CSS Generation │ │ │ └─────────────────────┘ │ └──────────────────────────────────────────────────────────────┘

Two-layer cache architecture significantly reduces API calls:

Automatically converts absolute positioning to semantic Flexbox/Grid layouts:

Input (Figma absolute positioning): ┌─────────────────────────┐ │ ■ (10,10) ■ (110,10) │ │ ■ (10,60) ■ (110,60) │ └─────────────────────────┘ Output (Inferred Grid): display: grid grid-template-columns: 100px 100px grid-template-rows: 50px 50px gap: 10px
src/ ├── algorithms/ # Smart algorithms │ ├── layout/ # Layout detection (Flex/Grid inference) │ └── icon/ # Icon merge detection ├── core/ # Core parsing │ ├── parser.ts # Figma data parser │ ├── style.ts # CSS style generation │ ├── layout.ts # Layout processing │ └── effects.ts # Effects handling ├── services/ # Service layer │ ├── figma.ts # Figma API client │ └── cache/ # Multi-layer cache system ├── prompts/ # MCP prompt templates ├── resources/ # MCP resource handlers ├── types/ # TypeScript type definitions ├── utils/ # Utility functions ├── server.ts # MCP server main entry └── index.ts # CLI entry tests/ ├── fixtures/ # Test data │ ├── figma-data/ # Raw JSON from Figma API │ └── expected/ # Expected output snapshots ├── integration/ # Integration tests │ ├── layout-optimization.test.ts # Layout optimization tests │ ├── output-quality.test.ts # Output quality validation │ └── parser.test.ts # Parser tests └── unit/ # Unit tests ├── algorithms/ # Algorithm tests (layout, icon detection) ├── resources/ # Resource handler tests └── services/ # Service layer tests scripts/ └── fetch-test-data.ts # Figma test data fetcher
# Setup git clone https://github.com/1yhy/Figma-Context-MCP.git cd Figma-Context-MCP pnpm install # Development pnpm dev # Watch mode pnpm test # Run tests (272 test cases) pnpm lint # Lint code pnpm build # Build # Debug pnpm inspect # MCP Inspector # Test with your own Figma data pnpm tsx scripts/fetch-test-data.ts <fileKey> <nodeId> <outputName> # Commit (uses conventional commits) git commit -m "feat: add new feature"
# 1. Update version in package.json and CHANGELOG.md # 2. Commit version bump git add -A git commit -m "chore: bump version to x.x.x" # 3. Publish to npm (auto runs: type-check → lint → test → build) npm login --scope=@yhy2001 # if not logged in pnpm run pub:release # 4. Create git tag and push git tag vx.x.x git push origin main --tags # 5. Create GitHub Release (optional) # Go to https://github.com/1yhy/Figma-Context-MCP/releases/new

You can test the layout detection and optimization with your own Figma designs:

# Copy the environment template cp .env.example .env # Edit .env file with your configuration FIGMA_API_KEY=your_figma_api_key_here TEST_FIGMA_FILE_KEY=your_file_key # Optional TEST_FIGMA_NODE_ID=your_node_id # Optional
# Method 1: Using command line arguments (recommended) pnpm tsx scripts/fetch-test-data.ts <fileKey> <nodeId> <outputName> # Example: Fetch a specific node pnpm tsx scripts/fetch-test-data.ts UgtwrncR3GokKDIS7dpm4Z 402-34955 my-design # Method 2: Using environment variables TEST_FIGMA_FILE_KEY=xxx TEST_FIGMA_NODE_ID=123-456 pnpm tsx scripts/fetch-test-data.ts
https://www.figma.com/design/UgtwrncR3GokKDIS7dpm4Z/MyProject?node-id=402-34955 ↑ fileKey ↑ nodeId
# Run all tests pnpm test # Run only integration tests (validate layout optimization) pnpm test tests/integration/ # View output JSON files ls tests/fixtures/figma-data/

- Data Compression- Typically >50% compression
- Layout Detection- Flex/Grid layout recognition rate
- CSS Properties- Redundant property cleanup
- Output Quality- Structural consistency checks

If tests fail, the output may not meet expectations. Check error messages to adjust or report an issue.

- Figma-Context-MCP- Original project
-
Model Context Protocol- MCP specification
-
Best-README-Template- README template reference

Made with ❤️ for the AI coding community

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Integrates Cursor AI with Figma to read and programmatically modify designs.

Enables AI assistants to interact with and automate Figma designs programmatically.

Figma MCP server for accessing Figma files, projects, comments, components, and design metadata from Claude, Cursor, and other AI agents.

Connects to the Figma API, allowing AI tools to access and interact with your Figma designs.

Enables AI assistants to interact with Figma via WebSocket for reading data and design analysis.

A server for integrating with Figma, allowing you to interact with your design files.

Connect AI coding agents to Anima Playground, Figma designs, and your team's design system. Bridge the gap between prototypes and production code.

A growing collection of MCP tools for Android Development. Currently features a deterministic Figma-SVG-to-Android-XML converter, with plans for Gradle analysis, Resource management, and ADB integration tools.

Interact with the Figma API to access and manage design files and resources.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.