Prerequisites
Before you begin, ensure you have:- Bun runtime installed
- Git installed
- A code editor (VS Code, Cursor, or similar)
- Node.js knowledge (TypeScript)
- Figma account with editor access
Initial Setup
1
Clone the repository
2
Install dependencies
@modelcontextprotocol/sdk- MCP protocol implementationws- WebSocket clientuuid- Unique ID generationzod- Schema validation- TypeScript and build tools
3
Review project structure
Development Configuration
For local development, you need to point the MCP configuration to your local source files instead of the published package.Cursor Configuration
Create or edit.cursor/mcp.json in your project root:
Claude Code Configuration
Create or edit.mcp.json in your project root:
Finding your absolute path
- macOS/Linux:
/home/username/projects/talk-to-figma-mcp/src/talk_to_figma_mcp/server.ts - Windows:
C:/Users/username/projects/talk-to-figma-mcp/src/talk_to_figma_mcp/server.ts
Development Workflow
Running the WebSocket Server
The WebSocket relay server requires no build step:Building the MCP Server
The MCP server is written in TypeScript and needs to be built:Running the MCP Server
After building:Figma Plugin Development
The Figma plugin requires no build step - it uses vanilla JavaScript:1
Link the plugin
In Figma Desktop:
- Go to Plugins → Development → New Plugin
- Choose “Link existing plugin”
- Select
src/cursor_mcp_plugin/manifest.json
2
Make changes
Edit
code.js or ui.html in src/cursor_mcp_plugin/3
Reload
Close and reopen the plugin in Figma to see your changes.
The plugin files are loaded directly by Figma - no transpilation or bundling needed.
Development Commands
All available commands frompackage.json:
Testing Your Changes
1
Start the WebSocket server
2
Build and run the MCP server (in watch mode)
3
Run the Figma plugin
In Figma: Plugins → Development → Cursor MCP Plugin
4
Test via Cursor or Claude Code
Use your AI agent to send commands and verify the behavior.
Architecture Deep Dive
MCP Server (src/talk_to_figma_mcp/server.ts)
The MCP server:
- Implements the Model Context Protocol
- Exposes 50+ tools for Figma manipulation
- Manages WebSocket communication
- Handles request/response correlation with UUIDs
- Implements 30-second timeouts with progress resets
- Validates all parameters with Zod schemas
WebSocket Relay (src/socket.ts)
The WebSocket relay:
- Lightweight Bun WebSocket server
- Channel-based message routing
- Runs on port 3055 (configurable via
PORTenv) - Handles connection management
- CORS-enabled for browser plugin
Figma Plugin (src/cursor_mcp_plugin/)
The plugin:
- Vanilla JavaScript (no build process)
- Command dispatcher for 30+ operations
- Chunking for large operations (prevents UI freezing)
- WebSocket client for MCP communication
- Progress reporting for long-running tasks
Common Development Tasks
Adding a new MCP tool
1
Define the tool schema
In
server.ts, add a new tool definition:2
Implement the tool handler
Add the handler in the CallToolRequestSchema handler:
3
Add plugin handler
In
code.js, add the command handler:4
Test the new tool
Rebuild, restart, and test via your AI agent.
Modifying WebSocket communication
The WebSocket protocol uses this message format:Debugging
Build Configuration
The project usestsup for building. Configuration in tsup.config.ts:
- Compiles TypeScript to JavaScript
- Outputs to
dist/directory - Uses ES modules format
- Cleans output directory on each build
Contributing Guidelines
When contributing:- Code Style: Follow existing patterns
- Logging: Use stderr for MCP server logs
- Error Handling: All errors should return structured responses
- Validation: Use Zod for parameter validation
- Documentation: Update relevant docs for new features
- Testing: Test with both Cursor and Claude Code
- Chunking: Use chunking for operations on 100+ nodes
Publishing Changes
For maintainers:1
Update version
Edit
package.json and bump the version number.2
Build and publish
3
Update Figma plugin
If plugin changes are made, update the plugin on Figma Community separately.
Next Steps
Architecture
Understand the system architecture
API Reference
Explore all available MCP tools
Troubleshooting Development Issues
Build errors
- Ensure all dependencies are installed:
bun install - Clear the build cache:
rm -rf dist && bun run build - Check TypeScript version compatibility
MCP server not reloading
- You must restart your AI agent after making MCP server changes
- Verify the absolute path in your MCP configuration is correct
- Check stderr logs for error messages
Plugin changes not appearing
- Close and reopen the plugin in Figma
- For major changes, try unlinking and relinking the plugin
- Check the Figma plugin console for JavaScript errors
WebSocket connection issues
- Ensure the WebSocket server is running
- Check port 3055 isn’t in use by another process
- On Windows, verify
hostname: "0.0.0.0"is set