EmilyThaHuman/figma-mcp-server
If you are the rightful owner of figma-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Figma MCP Server integrates Figma and FigJam with ChatGPT Apps SDK, enabling AI interactions with design files.
Figma MCP Server
A Model Context Protocol (MCP) server for Figma and FigJam integration with ChatGPT Apps SDK. This server enables AI assistants to interact with Figma designs, generate screenshots, extract design context, and create diagrams in FigJam.
Features
Tools
OAuth-Required Tools
-
get_screenshot - Generate screenshots of Figma nodes
- Extract fileKey and nodeId from URLs
- Configurable scale (1-4)
- Returns PNG images
- Requires Figma OAuth authentication
-
get_design_context - Generate UI code from Figma designs
- Extract design specifications
- Get component code
- Access asset download URLs
- Requires Figma OAuth authentication
-
get_metadata - Get node/page metadata in XML format
- Overview of design structure
- Node IDs, types, names, positions, sizes
- Useful for understanding file organization
- Requires Figma OAuth authentication
No-Auth / Optional OAuth Tool
- generate_diagram - Create diagrams in FigJam using Mermaid.js
- Supports: flowcharts, sequence diagrams, gantt charts, state diagrams
- Works without authentication for basic use
- OAuth optional for saving to FigJam
- Beautiful widget display with Mermaid rendering
UI Components
- FigJam Diagram Widget - Interactive diagram viewer
- Live Mermaid.js rendering
- Download as SVG
- Copy Mermaid code
- Open in FigJam (when authenticated)
- Responsive design
Prerequisites
- Node.js 18+
- Figma Developer Account (for OAuth tools)
- Figma App credentials (for OAuth)
Setup
1. Create Figma App (Optional - only for OAuth tools)
- Go to Figma Developers
- Click "Create new app"
- Fill in the details:
- App name: Your MCP Server name
- Website: Your server URL
- Callback URL:
http://localhost:8000/auth/callback
- Save your Client ID and Client Secret
2. Configure OAuth Scopes
Required scopes:
file_read- Read Figma filesfile_write- Write to Figma files (for diagram creation)
3. Environment Variables
Create a .env file:
# Optional - only needed for OAuth tools
FIGMA_CLIENT_ID=your_client_id_here
FIGMA_CLIENT_SECRET=your_client_secret_here
FIGMA_REDIRECT_URI=http://localhost:8000/auth/callback
PORT=8000
Note: The generate_diagram tool works without these credentials!
4. Install & Run
npm install
npm run dev
Usage Examples
Generate Diagram (No Auth Required!)
{
"tool": "generate_diagram",
"arguments": {
"mermaidCode": "flowchart TD\\n A[Start] --> B[Process]\\n B --> C[End]",
"diagramType": "flowchart",
"title": "Simple Process Flow"
}
}
Get Screenshot (OAuth Required)
{
"tool": "get_screenshot",
"arguments": {
"url": "https://figma.com/design/pqrs/ExampleFile?node-id=1-2",
"scale": 2
}
}
Or with direct parameters:
{
"tool": "get_screenshot",
"arguments": {
"fileKey": "pqrs",
"nodeId": "1:2",
"scale": 2
}
}
Get Design Context (OAuth Required)
{
"tool": "get_design_context",
"arguments": {
"url": "https://figma.com/design/abc123/MyDesign?node-id=10-20"
}
}
Get Metadata (OAuth Required)
{
"tool": "get_metadata",
"arguments": {
"fileKey": "abc123",
"nodeId": "0:1"
}
}
URL Parsing
The server automatically extracts fileKey and nodeId from Figma URLs:
- Input:
https://figma.com/design/pqrs/ExampleFile?node-id=1-2 - Extracted
fileKey:pqrs - Extracted
nodeId:1:2(automatically converts1-2to1:2)
Supported Diagram Types
- ✅ Flowcharts
- ✅ Sequence Diagrams
- ✅ Gantt Charts
- ✅ State Diagrams
- ❌ Class Diagrams (not supported)
- ❌ Timelines (not supported)
- ❌ Venn Diagrams (not supported)
- ❌ Entity Relationship Diagrams (not supported)
Authentication Flow
- OAuth-required tools check for authentication
- If not authenticated, user receives auth URL
- User authorizes app with Figma account
- Tokens stored securely (in-memory for dev, use database for production)
- Tokens auto-refresh when expired
Project Structure
figma-mcp-server/
├── src/
│ └── server.ts # Main server implementation
├── ui-components/
│ └── figjam-diagram.html # Diagram widget
├── package.json
├── tsconfig.json
└── README.md
Security Notes
Production Deployment
- Token Storage: Use PostgreSQL/Redis instead of in-memory
- Environment Variables: Never commit secrets
- HTTPS: Always use HTTPS in production
- Rate Limiting: Implement proper rate limiting
- Session Management: Implement secure session handling
No-Auth Mode
The generate_diagram tool works without authentication, making it perfect for:
- Quick diagram generation
- Public use cases
- Testing without OAuth setup
- Embedded applications
Development
# Install dependencies
npm install
# Development mode
npm run dev
# Build TypeScript
npm run build
# Type checking
npm run typecheck
# Production
npm start
API Endpoints
- GET /mcp - SSE stream for MCP protocol
- POST /mcp/messages - Message posting endpoint
- GET /auth/callback - OAuth callback handler
Troubleshooting
"Not authenticated" Error
- OAuth tools require Figma authentication
- Use
generate_diagramwithout auth - Check your FIGMA_CLIENT_ID and FIGMA_CLIENT_SECRET
URL Parsing Issues
- Ensure URLs are in format:
https://figma.com/design/:fileKey/:fileName?node-id=X-Y - Node IDs can use either
-or:separator - Both will be normalized to
:format
Diagram Rendering Fails
- Check Mermaid.js syntax
- Ensure diagram type is supported
- Try simpler diagram first
- Check browser console for errors
Resources
License
MIT License
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
Built with ❤️ using the Model Context Protocol, Figma API, and Mermaid.js