对话Figma
STDIOCursor AI与Figma集成,实现设计读取与编程修改
Cursor AI与Figma集成,实现设计读取与编程修改
This project implements a Model Context Protocol (MCP) integration between Cursor AI and Figma, allowing Cursor to communicate with Figma for reading designs and modifying them programmatically.
https://github.com/user-attachments/assets/129a14d2-ed73-470f-9a4c-2240b2a4885c
src/talk_to_figma_mcp/ - TypeScript MCP server for Figma integrationsrc/cursor_mcp_plugin/ - Figma plugin for communicating with Cursorsrc/socket.ts - WebSocket server that facilitates communication between the MCP server and Figma plugincurl -fsSL https://bun.sh/install | bash
bun setup
bun start
Add the server to your Cursor MCP configuration in ~/.cursor/mcp.json:
{ "mcpServers": { "TalkToFigma": { "command": "bun", "args": [ "/path/to/cursor-talk-to-figma-mcp/src/talk_to_figma_mcp/server.ts" ] } } }
Start the WebSocket server:
bun run src/socket.ts
src/cursor_mcp_plugin/manifest.json filejoin_channelThe MCP server provides the following tools for interacting with Figma:
get_document_info - Get information about the current Figma documentget_selection - Get information about the current selectionget_node_info - Get detailed information about a specific nodecreate_rectangle - Create a new rectangle with position, size, and optional namecreate_frame - Create a new frame with position, size, and optional namecreate_text - Create a new text node with customizable font propertiesset_fill_color - Set the fill color of a node (RGBA)set_stroke_color - Set the stroke color and weight of a nodeset_corner_radius - Set the corner radius of a node with optional per-corner controlmove_node - Move a node to a new positionresize_node - Resize a node with new dimensionsdelete_node - Delete a nodeget_styles - Get information about local stylesget_local_components - Get information about local componentsget_team_components - Get information about team componentscreate_component_instance - Create an instance of a componentexport_node_as_image - Export a node as an image (PNG, JPG, SVG, or PDF)execute_figma_code - Execute arbitrary JavaScript code in Figma (use with caution)join_channel - Join a specific channel to communicate with FigmaNavigate to the Figma plugin directory:
cd src/cursor_mcp_plugin
Edit code.js and ui.html
When working with the Figma MCP:
get_document_info firstget_selection before modificationscreate_frame for containerscreate_rectangle for basic shapescreate_text for text elementsget_node_infoMIT