|
| 1 | +# Contributing to Figma Flutter MCP |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Figma Flutter MCP! This guide will help you get started with development and testing. |
| 4 | + |
| 5 | +## 🚀 Quick Start for Contributors |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | +- Node.js 18+ |
| 9 | +- npm or yarn |
| 10 | +- Figma API Key (for testing) |
| 11 | +- Git |
| 12 | + |
| 13 | +### Setup Development Environment |
| 14 | + |
| 15 | +1. **Fork and Clone** |
| 16 | + ```bash |
| 17 | + git clone https://github.com/your-username/figma-flutter-mcp.git |
| 18 | + cd figma-flutter-mcp |
| 19 | + npm install |
| 20 | + ``` |
| 21 | + |
| 22 | +2. **Create .env file** |
| 23 | + ```bash |
| 24 | + # Create .env file with your Figma API key |
| 25 | + echo "FIGMA_API_KEY=your-figma-api-key-here" > .env |
| 26 | + ``` |
| 27 | + |
| 28 | +3. **Start Development Server** |
| 29 | + ```bash |
| 30 | + npm run dev |
| 31 | + ``` |
| 32 | + |
| 33 | +## 📋 Development Guidelines |
| 34 | + |
| 35 | +### Code Style |
| 36 | +- Use TypeScript for all new code |
| 37 | +- Follow existing code patterns and conventions |
| 38 | +- Use meaningful variable and function names |
| 39 | +- Add docs in `docs/` if you think its neccessary |
| 40 | + |
| 41 | +### Project Structure |
| 42 | +``` |
| 43 | +src/ |
| 44 | +├── cli.mts # CLI entry point |
| 45 | +├── server.mts # MCP server implementation |
| 46 | +├── config.mts # Configuration handling |
| 47 | +├── extractors/ # Figma data extractors |
| 48 | +│ ├── colors/ |
| 49 | +│ ├── components/ |
| 50 | +│ ├── screens/ |
| 51 | +│ └── typography/ |
| 52 | +├── tools/ # Flutter code generators |
| 53 | +├── services/ # External service integrations |
| 54 | +├── types/ # TypeScript type definitions |
| 55 | +└── utils/ # Utility functions |
| 56 | +``` |
| 57 | + |
| 58 | +### Making Changes |
| 59 | + |
| 60 | +1. **Create a Branch** |
| 61 | + ```bash |
| 62 | + git checkout -b feature/your-feature-name |
| 63 | + # or |
| 64 | + git checkout -b fix/issue-description |
| 65 | + ``` |
| 66 | + |
| 67 | +2. **Make Your Changes** |
| 68 | + - Write clean, documented code |
| 69 | + - Add tests for new features |
| 70 | + - Update documentation as needed |
| 71 | + |
| 72 | +3. **Test Your Changes** |
| 73 | + ```bash |
| 74 | + # Build and check for errors |
| 75 | + npm run build |
| 76 | + |
| 77 | + # Test locally |
| 78 | + npm run dev |
| 79 | + ``` |
| 80 | + |
| 81 | +4. **Commit and Push** |
| 82 | + ```bash |
| 83 | + git add . |
| 84 | + git commit -m "feat: add new feature description" |
| 85 | + git push origin feature/your-feature-name |
| 86 | + ``` |
| 87 | + |
| 88 | +5. **Create Pull Request** |
| 89 | + - Use descriptive titles and descriptions |
| 90 | + - Reference any related issues |
| 91 | + - Include screenshots/examples if applicable |
| 92 | + |
| 93 | +## 🧪 Local Testing & Development |
| 94 | + |
| 95 | +The project supports HTTP server mode for easier development and testing. This allows you to test MCP tools without setting up a full MCP client. |
| 96 | + |
| 97 | +### Setting Up Your Environment |
| 98 | + |
| 99 | +If you haven't already set up your Figma API key: |
| 100 | +```bash |
| 101 | +# Create .env file |
| 102 | +echo "FIGMA_API_KEY=your-figma-api-key-here" > .env |
| 103 | +``` |
| 104 | + |
| 105 | +**Get your Figma API Key:** |
| 106 | +1. Go to [Figma Settings > Personal Access Tokens](https://www.figma.com/developers/api#access-tokens) |
| 107 | +2. Generate a new personal access token |
| 108 | +3. Copy the token and add it to your `.env` file |
| 109 | + |
| 110 | +⚠️ **Important**: Never commit your `.env` file to version control. It's already included in `.gitignore`. |
| 111 | + |
| 112 | +### Development Server Options |
| 113 | + |
| 114 | +#### Using npm scripts (recommended) |
| 115 | +```bash |
| 116 | +# Start HTTP server on default port 3333 |
| 117 | +npm run dev |
| 118 | + |
| 119 | +# Start HTTP server on a specific port |
| 120 | +npm run dev:port 4000 |
| 121 | + |
| 122 | +# Start in stdio mode (for MCP clients) |
| 123 | +npm run dev:stdio |
| 124 | +``` |
| 125 | + |
| 126 | +#### Using direct commands |
| 127 | +```bash |
| 128 | +# Start HTTP server |
| 129 | +npx tsx src/cli.mts --http |
| 130 | + |
| 131 | +# Start HTTP server on specific port |
| 132 | +npx tsx src/cli.mts --http --port 4000 |
| 133 | + |
| 134 | +# Start in stdio mode |
| 135 | +npx tsx src/cli.mts --stdio |
| 136 | +``` |
| 137 | + |
| 138 | +#### Using built version |
| 139 | +```bash |
| 140 | +# Build first |
| 141 | +npm run build |
| 142 | + |
| 143 | +# Start HTTP server |
| 144 | +node dist/cli.mjs --http |
| 145 | + |
| 146 | +# Start HTTP server on specific port |
| 147 | +node dist/cli.mjs --http --port 4000 |
| 148 | +``` |
| 149 | + |
| 150 | +## Connecting to the Server |
| 151 | + |
| 152 | +### MCP Client Configuration |
| 153 | + |
| 154 | +To connect an MCP client to the local HTTP server, add this configuration to your MCP JSON config file: |
| 155 | + |
| 156 | +```json |
| 157 | +{ |
| 158 | + "mcpServers": { |
| 159 | + "local-figma-flutter-mcp": { |
| 160 | + "url": "http://localhost:3333/mcp" |
| 161 | + } |
| 162 | + } |
| 163 | +} |
| 164 | +``` |
| 165 | + |
| 166 | +## Available Endpoints |
| 167 | + |
| 168 | +When the HTTP server is running, the following endpoints are available: |
| 169 | + |
| 170 | +- **POST /mcp** - Main Streamable HTTP endpoint for MCP communication |
| 171 | +- **GET /mcp** - Session management for StreamableHTTP |
| 172 | +- **DELETE /mcp** - Session termination for StreamableHTTP |
| 173 | +- **GET /sse** - Server-Sent Events endpoint (alternative transport) |
| 174 | +- **POST /messages** - Message endpoint for SSE transport |
| 175 | + |
| 176 | +## Environment Variables |
| 177 | + |
| 178 | +You can configure the server using environment variables. The recommended approach is to use a `.env` file: |
| 179 | + |
| 180 | +### Using .env file (Recommended) |
| 181 | +```env |
| 182 | +# Required: Your Figma API key |
| 183 | +FIGMA_API_KEY=your-figma-api-key-here |
| 184 | +
|
| 185 | +# Optional: Enable HTTP mode by default |
| 186 | +HTTP_MODE=true |
| 187 | +
|
| 188 | +# Optional: Set default HTTP port |
| 189 | +HTTP_PORT=3333 |
| 190 | +``` |
| 191 | + |
| 192 | +## 📋 Pull Request Checklist |
| 193 | + |
| 194 | +Before submitting a PR: |
| 195 | +- [ ] Code builds without errors (`npm run build`) |
| 196 | +- [ ] Tests pass (if applicable) |
| 197 | +- [ ] Documentation updated |
| 198 | +- [ ] PR description explains changes |
| 199 | +- [ ] Related issues referenced |
| 200 | +- [ ] Follows existing code style |
| 201 | + |
| 202 | +Thank you for contributing to Figma Flutter MCP! 🚀 |
0 commit comments