Logo vun Figma MCP 服务器

Figma MCP 服务器

Communautéit
1yhy

Figma Context MCP is a Model Context Protocol (MCP) server that bridges Figma designs with AI coding assistants like Cursor, Windsurf, and Cline.

Editeur1yhy
RepositoryFigma-Context-MCP
SproochTypeScript
Forks
9
Stären
31
Disponibel Tools
5
Transporttypstdio
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    Figma MCP 服务器 stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 5 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    31 Stären an 9 Forks aus dem verlinkte Repository.


What is This?

Figma Context MCP is a Model Context Protocol (MCP) server that bridges Figma designs with AI coding assistants like Cursor, Windsurf, and Cline.

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 on Figma-Context-MCP, with optimized data structures and intelligent layout detection algorithms.

Features

Core Capabilities

CapabilityDescription
Smart Layout DetectionAutomatically infers Flexbox/Grid layouts from absolute positioning
Icon MergingIntelligently merges vector layers into single exportable icons
CSS GenerationConverts Figma styles to clean, usable CSS
Image ExportDownloads images and icons with proper naming
Multi-layer CachingL1 memory + L2 disk cache to reduce API calls
Design-to-Code PromptsBuilt-in professional prompt templates to guide AI code generation
Lightweight Resource AccessResources API provides low-token data access

Key Improvements

FeatureBeforeAfter
Icon exports~45 fragmented2 merged (96% reduction)
Layout detectionManual absoluteAuto Flexbox/Grid inference
CSS outputRaw valuesOptimized with defaults removed
API callsEvery request24-hour smart caching

Quick Start

Prerequisites

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

Installation

Via Smithery (Recommended)

bash
npx -y @smithery/cli install @1yhy/Figma-Context-MCP --client claude

Via npm

bash
npm install -g @yhy2001/figma-mcp-server

From Source

bash
git clone https://github.com/1yhy/Figma-Context-MCP.git
cd Figma-Context-MCP
pnpm install
pnpm build

Configuration

1. Get Figma API Token

  1. Go to Figma Account Settings
  2. Scroll to "Personal access tokens"
  3. Click "Create new token"
  4. Copy the token

2. Configure Your AI Tool

Add to your MCP configuration file:

json
{
  "mcpServers": {
    "Figma": {
      "command": "npx",
      "args": ["-y", "@yhy2001/figma-mcp-server", "--stdio"],
      "env": {
        "FIGMA_API_KEY": "your-figma-api-key"
      }
    }
  }
}
bash
# 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

Usage Example

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

Use React and Tailwind CSS.

MCP Capabilities

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) │
└─────────────────────────────────────────────────────────────┘

Tools

ToolDescriptionParameters
get_figma_dataFetch simplified design datafileKey, nodeId?, depth?
download_figma_imagesDownload images and iconsfileKey, nodes[], localPath

Prompts

Built-in professional prompt templates to help AI generate high-quality code:

PromptDescriptionParameters
design_to_codeComplete design-to-code workflowframework?, includeResponsive?
analyze_componentsAnalyze component structure and reusability-
extract_stylesExtract design tokens-

design_to_code workflow includes:

  1. Project Analysis - Read theme config, global styles, component library
  2. Structure Analysis - Identify page patterns, component splitting strategy
  3. ASCII Layout Blueprint - Generate layout diagram with component and asset annotations
  4. Asset Management - Analyze, download, and organize images/icons
  5. Code Generation - Generate code following project conventions
  6. Accessibility Optimization - Semantic HTML, ARIA labels
  7. Responsive Adaptation - Mobile layout adjustments

Resources

Lightweight data access to save tokens:

bash
# 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

Resources vs Tools comparison:

FeatureToolsResources
ControllerAI auto-invokedUser/client initiated
Token costHigher (full data)Lower (summaries)
Use caseExecute actionsBrowse and explore

Architecture

┌──────────────────────────────────────────────────────────────┐
│                        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   │    │
│                                   └─────────────────────┘    │
└──────────────────────────────────────────────────────────────┘

Cache System

Two-layer cache architecture significantly reduces API calls:

LayerStorageCapacityTTLPurpose
L1Memory LRU100 nodes / 50 images5-10 minHot data fast access
L2Disk500MB24 hoursPersistent cache

Layout Detection Algorithm

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

Project Structure

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

Documentation

Core Algorithms

Research Documents

Architecture Documents


Command Line Options

OptionDescriptionDefault
--figma-api-keyFigma API tokenRequired
--portServer port for HTTP mode3333
--stdioRun in stdio modefalse
--helpShow help-

Contributing

Contributions are welcome!

bash
# 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"

Commit Types

TypeDescription
featNew feature
fixBug fix
docsDocumentation
styleCode style
refactorRefactoring
testTests
choreMaintenance

Release Process (Maintainers)

bash
# 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

Testing with Your Own Figma Data

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

1. Configure Environment Variables

bash
# 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

2. Fetch Figma Node Data

bash
# 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

Parameters:

ParameterDescriptionHow to Get
fileKeyFigma file identifierPart after /design/ in URL, e.g., UgtwrncR3GokKDIS7dpm4Z
nodeIdNode IDnode-id= parameter in URL, e.g., 402-34955
outputNameOutput filenameCustom name, e.g., my-design

Example URL Parsing:

https://www.figma.com/design/UgtwrncR3GokKDIS7dpm4Z/MyProject?node-id=402-34955
                            ↑ fileKey                              ↑ nodeId

3. Run Tests to Validate Output

bash
# 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/

4. Analyze Optimization Results

Tests automatically validate:

  • 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.


License

MIT © 1yhy

Acknowledgments


Installatioun

TypingMind
{
  "mcpServers": {
    "figma-context-mcp": {
      "command": "npx",
      "args": [
        "figma-mcp",
        "--figma-api-key={{config.FIGMA_API_KEY}}",
        "--stdio"
      ],
      "env": {
        "FIGMA_API_KEY": "<FIGMA_API_KEY>"
      }
    }
  }
}

Disponibel Tools

  • add_figma_file

    Add a Figma file to your context

  • view_node

    Get a thumbnail for a specific node in a Figma file

  • read_comments

    Get all comments on a Figma file

  • post_comment

    Post a comment on a node in a Figma file

  • reply_to_comment

    Reply to an existing comment in a Figma file

Figma MCP 服务器 MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal Figma MCP 服务器 verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

Figma MCP 服务器 als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu Figma MCP 服务器 an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "figma-context-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@yhy2001/figma-mcp-server"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu Figma MCP 服务器. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu Figma MCP 服务器.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat Figma MCP 服务器?
Figma MCP 服务器
Jo. Ech hunn et gelies.
Dat hunn ech mat Figma MCP 服务器 fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server Figma MCP 服务器 benotzt?

Figma MCP 服务器 ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech Figma MCP 服务器 MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir Figma MCP 服务器 mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat Figma MCP 服务器 MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann Figma MCP 服务器 verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech Figma MCP 服务器 MCP mat TypingMind?

Figma MCP 服务器 leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt Figma MCP 服务器 MCP an TypingMind zur Verfügung?

Figma MCP 服务器 stellt 5 MCP-Tools zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir Figma MCP 服务器 MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann Figma MCP 服务器 eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇