
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
A Model Context Protocol (MCP) server for Figma data extraction with component and design token focus
Give your AI coding agents (like Cursor) powerful, structured access to your Figma design data, with a deep focus on Components, Variants, and Variables. This Model Context Protocol (MCP) server is implemented in Python using FastMCP and is designed to help generate and reuse mobile UI components for Jetpack Compose (Android) and SwiftUI (iOS).
This project is inspired by and aims to provide a Python-based alternative/enhancement to the figma-developer-mcp Node.js server, tailored for a component-driven workflow.
get_figma_data
: Fetches and processes Figma file or node data.download_figma_images
: Downloads specified image assets (PNG, SVG) from your Figma designs.While general Figma data extraction is useful, this server specifically aims to:
componentName
and appliedVariants
, it helps AI agents identify and use existing coded components in your mobile projects.pip install figma-mcp-server
After installation, you can run the server using:
figma-mcp-server
If you have uvx installed, you can run the server directly without installing it:
uvx figma-mcp-server
This will automatically download and run the latest version.
For development or if you want to modify the code:
git clone https://github.com/yourusername/figma-mcp.git
cd figma-mcp
pip install -e .
Help and account
> Account settings
> Personal access tokens
.Set up your Figma API key:
Create a .env
file in your working directory:
FIGMA_API_KEY="your_figma_personal_access_token_here"
Run the server:
figma-mcp-server
The figma-mcp-server
command supports various options:
figma-mcp-server --help # Show all available options
figma-mcp-server # Run with stdio transport (default)
figma-mcp-server --transport http # Run with HTTP transport on port 8000
figma-mcp-server --transport http --port 9000 # Run with HTTP transport on port 9000
figma-mcp-server --transport sse --port 8080 # Run with SSE transport on port 8080
figma-mcp-server --env-file custom.env # Use custom environment file
figma-mcp-server --debug # Enable debug mode
Supported transports:
stdio
- Standard input/output (default, for MCP clients like Cursor)http
- HTTP transport (alias for streamable-http)streamable-http
- HTTP transport with streaming supportsse
- Server-Sent Events transportIf you're working with the source code, this project provides convenient scripts for setup, running, and testing:
Use the provided script to set up your environment and start the server:
chmod +x install_and_run.sh
./install_and_run.sh [server arguments]
.env
file (and prompt you to edit it if missing)./install_and_run.sh
(default stdio)./install_and_run.sh http 9000
(HTTP mode on port 9000)Use the test script to run the included test client:
chmod +x test_server.sh
./test_server.sh <tool> <file_key> [node_id]
<tool>
: get_data
or download_images
<file_key>
: Your Figma file key (from the URL)[node_id]
: (Optional) Specific node ID to fetchExamples:
./test_server.sh get_data abc123
./test_server.sh get_data abc123 45:678
./test_server.sh download_images abc123
If you prefer to set up manually:
git clone https://github.com/yourusername/figma-mcp.git
cd figma-mcp
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
.env
file in the root of the project with your Figma Personal Access Token:
# Copy from env.example
FIGMA_API_KEY="your_figma_personal_access_token_here"
The server primarily runs in STDIO mode, which is expected by clients like Cursor for direct integration.
python main.py
You should see output like:
Starting Figma Data MCP Server on STDIO...
For testing with tools like the MCP Inspector, you can run it in HTTP mode:
python main.py http 8000
Output:
Starting Figma Data MCP Server with streamable-http transport on port 8000
The main.py
script accepts the following command-line arguments:
stdio
, http
, streamable-http
, or sse
). Default is stdio
.8000
.Examples:
python main.py # Run with stdio transport
python main.py http 9000 # Run with streamable-http transport on port 9000
python main.py sse 8080 # Run with SSE transport on port 8080
If you're using this server with Cursor, you can configure it in the Cursor MCP settings:
{
"mcpServers": {
"Figma Data MCP": {
"command": "figma-mcp-server",
"transport": "stdio"
}
}
}
{
"mcpServers": {
"Figma Data MCP": {
"command": "/path/to/your/.venv/bin/python", // Or just "python" if in PATH and venv active
"args": ["/path/to/your/figma-mcp/main.py"],
"transport": "stdio"
}
}
}
Make sure the command
points to the Python interpreter within your virtual environment if you are using one.
get_figma_data
:
fileKey
(string, required): The key of the Figma file.nodeId
(string, optional): The ID of a specific node/frame to fetch.depth
(integer, optional): Traversal depth for node fetching.SimplifiedDesign
.download_figma_images
:
fileKey
(string, required): The key of the Figma file.nodes
(list of objects, required): Each object with nodeId
, fileName
, and optional imageRef
.scale
(float, optional, default: 2.0): Export scale for PNGs.format
(string, optional, default: "png"): Image format (png, svg, jpg, pdf).localPath
(string, required): Absolute local directory path to save images.The code is organized into the following modules:
main.py
: Root entry point for the server.figma_mcp_server/
: Main package containing the server implementation.
main.py
: FastMCP server definition and tool implementations.figma_service.py
: Service for communicating with the Figma API.figma_parser.py
: Core logic for parsing and transforming Figma API data.figma_transformers.py
: Functions for transforming specific aspects of Figma data (e.g., fills, strokes, effects).figma_utils.py
: Utility functions for processing Figma data.models.py
: Pydantic models for the Figma API responses and our simplified output format.The get_figma_data
tool returns a YAML string with the following structure:
name: "SNOW UI Guide"
lastModified: "2025-05-30T07:28:34Z"
thumbnailUrl: "https://example.com/thumb.png"
nodes:
- id: "8239:115746"
name: "Components"
type: "CANVAS"
visible: true
children:
- id: "112254:66708"
name: "Editor / List_Mosaic"
type: "SECTION"
visible: true
children:
- id: "112760:29599"
name: "mosaic_thumbnail"
type: "COMPONENT_SET" # This is a component set with variants
visible: true
cornerRadius: 5.0
variantProperties: # Available variant properties for this component set
Property 1:
- "Selected"
- "Download"
- "Downloading"
- "Default"
- "New"
children:
- id: "112254:66749"
name: "Property 1=Default"
type: "COMPONENT"
visible: true
cornerRadius: 7.0
- id: "112760:29600"
name: "Property 1=Selected"
type: "COMPONENT"
visible: true
cornerRadius: 7.0
- id: "112760:29634"
name: "Property 1=Download"
type: "COMPONENT"
visible: true
cornerRadius: 7.0
children:
- id: "112760:29636"
name: "icon_common_download"
type: "INSTANCE" # This is a component instance
visible: true
componentId: "716:41330"
componentName: "icon_common_download" # Useful for code reuse!
components: # Definitions of all components referenced by instances
"112254:66749":
id: "112254:66749"
name: "Property 1=Default"
description: ""
variantProperties:
"Property 1":
- "Default"
"716:41330":
id: "716:41330"
name: "icon_common_download"
description: ""
figmaVariables:
"Color/Primary":
id: "var123"
nameFromFigma: "Color/Primary"
resolvedValue: "#0066FF"
collectionName: "Color"
globalVars:
definitions:
layouts:
layout_c2232da6: # Layout definitions are simplified and de-duplicated
mode: "HORIZONTAL"
alignment:
primaryAxis: "center"
counterAxis: "center"
fills:
fill_9c763c83: # De-duplicated fill styles
type: "SOLID"
color: "#FFFFFF"
strokes:
stroke_97447a6f: # De-duplicated stroke styles
type: "SOLID"
color: "#000000"
weight: 1.0
This structure is specifically designed to make it easy for LLMs to:
globalVars.styles
The component-related information follows this pattern:
Component Sets: When a node is a component set (type: "COMPONENT_SET"
), it includes:
variantProperties
: All available variant properties and their possible valueschildren
: Individual component variants within the setComponent Instances in Nodes: When a node is a component instance (type: "INSTANCE"
), it includes:
componentId
: The unique ID of the main component definitioncomponentName
: The name of the main component (crucial for code mapping)appliedVariants
: Current variant selections (property-value pairs) when applicableoverriddenProperties
: Any properties overridden at the instance levelComponent Definitions: The components
section contains definitions for all components used in instances:
id
, name
, and optional description
variantProperties
lists all possible variant properties and their possible valuesClean Output: The output is automatically simplified to focus on component structure:
\b
) are removed from namesThis structure enables AI coding agents to identify when a component from your design matches an existing coded component in your codebase, allowing for accurate reuse rather than regeneration.
Contributions are welcome! Please feel free to submit a Pull Request.
This project includes automated publishing to PyPI using GitHub Actions. To set up automated deployment:
docs/github-actions-setup.md
pyproject.toml
and figma_mcp_server/cli.py
v0.1.2
)For detailed setup instructions, see the GitHub Actions Setup Guide.
You can also publish manually using the included script:
# Update version numbers first, then:
./scripts/publish.sh
FAQs
A Model Context Protocol (MCP) server for Figma data extraction with component and design token focus
We found that figma-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.