├── .gitignore ├── LICENSE ├── README.md ├── mcp-settings-example.json ├── package-lock.json ├── package.json ├── src ├── accessibility.ts ├── component-generator.ts ├── figma-client.ts ├── figma-react-tools.ts ├── figma-tailwind-converter.ts ├── figma-tools.ts └── index.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directories 2 | node_modules/ 3 | 4 | # Build output 5 | dist/ 6 | 7 | # Environment variables 8 | .env 9 | .env.local 10 | .env.development.local 11 | .env.test.local 12 | .env.production.local 13 | 14 | # Logs 15 | logs 16 | *.log 17 | npm-debug.log* 18 | yarn-debug.log* 19 | yarn-error.log* 20 | 21 | # Editor directories and files 22 | .idea/ 23 | .vscode/ 24 | *.suo 25 | *.ntvs* 26 | *.njsproj 27 | *.sln 28 | *.sw? 29 | 30 | # OS generated files 31 | .DS_Store 32 | .DS_Store? 33 | ._* 34 | .Spotlight-V100 35 | .Trashes 36 | ehthumbs.db 37 | Thumbs.db 38 | pnpm-lock.yaml 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Rod Lewis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MCP Figma to React Converter 2 | 3 | This is a Model Context Protocol (MCP) server that converts Figma designs to React components. It provides tools for fetching Figma designs and generating React components with TypeScript and Tailwind CSS. 4 | 5 | ## Features 6 | 7 | - Fetch Figma designs using the Figma API 8 | - Extract components from Figma designs 9 | - Generate React components with TypeScript 10 | - Apply Tailwind CSS classes based on Figma styles 11 | - Enhance components with accessibility features 12 | - Support for both stdio and SSE transports 13 | 14 | ## Prerequisites 15 | 16 | - Node.js 18 or higher 17 | - A Figma API token 18 | 19 | ## Installation 20 | 21 | 1. Clone the repository 22 | 2. Install dependencies: 23 | 24 | ```bash 25 | npm install 26 | ``` 27 | 28 | 3. Build the project: 29 | 30 | ```bash 31 | npm run build 32 | ``` 33 | 34 | ## Configuration 35 | 36 | You need to set the `FIGMA_API_TOKEN` environment variable to your Figma API token. You can get a personal access token from the Figma account settings page. 37 | 38 | ## Usage 39 | 40 | ### Running as a local MCP server 41 | 42 | ```bash 43 | FIGMA_API_TOKEN=your_token_here npm start 44 | ``` 45 | 46 | Or with explicit transport: 47 | 48 | ```bash 49 | FIGMA_API_TOKEN=your_token_here node dist/index.js --transport=stdio 50 | ``` 51 | 52 | ### Running as an HTTP server 53 | 54 | ```bash 55 | FIGMA_API_TOKEN=your_token_here node dist/index.js --transport=sse 56 | ``` 57 | 58 | ## Available Tools 59 | 60 | ### Figma Tools 61 | 62 | - `getFigmaProject`: Get a Figma project structure 63 | - `getFigmaComponentNodes`: Get component nodes from a Figma file 64 | - `extractFigmaComponents`: Extract components from a Figma file 65 | - `getFigmaComponentSets`: Get component sets from a Figma file 66 | 67 | ### React Tools 68 | 69 | - `generateReactComponent`: Generate a React component from a Figma node 70 | - `generateComponentLibrary`: Generate multiple React components from Figma components 71 | - `writeComponentsToFiles`: Write generated components to files 72 | - `figmaToReactWorkflow`: Complete workflow to convert Figma designs to React components 73 | 74 | ## Example Workflow 75 | 76 | 1. Get a Figma file key (the string after `figma.com/file/` in the URL) 77 | 2. Use the `figmaToReactWorkflow` tool with the file key and output directory 78 | 3. The tool will extract components, generate React code, and save the files 79 | 80 | ## Development 81 | 82 | For development, you can use the watch mode: 83 | 84 | ```bash 85 | npm run dev 86 | ``` 87 | 88 | ## License 89 | 90 | ISC -------------------------------------------------------------------------------- /mcp-settings-example.json: -------------------------------------------------------------------------------- 1 | { 2 | "mcpServers": { 3 | "figma-to-react": { 4 | "command": "node", 5 | "args": ["path/to/mcp-figma-to-react/dist/index.js", "--transport=stdio"], 6 | "env": { 7 | "FIGMA_API_TOKEN": "your_figma_api_token_here" 8 | }, 9 | "disabled": false, 10 | "alwaysAllow": [] 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mcp-figma-to-react", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "mcp-figma-to-react", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "@modelcontextprotocol/sdk": "^1.7.0", 13 | "axios": "^1.8.4", 14 | "express": "^5.0.1", 15 | "prettier": "^3.5.3", 16 | "typescript": "^5.8.2", 17 | "ws": "^8.18.1", 18 | "zod": "^3.22.4" 19 | }, 20 | "devDependencies": { 21 | "@types/express": "^5.0.1", 22 | "@types/node": "^22.13.11", 23 | "@types/ws": "^8.18.0" 24 | } 25 | }, 26 | "node_modules/@modelcontextprotocol/sdk": { 27 | "version": "1.7.0", 28 | "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.7.0.tgz", 29 | "integrity": "sha512-IYPe/FLpvF3IZrd/f5p5ffmWhMc3aEMuM2wGJASDqC2Ge7qatVCdbfPx3n/5xFeb19xN0j/911M2AaFuircsWA==", 30 | "license": "MIT", 31 | "dependencies": { 32 | "content-type": "^1.0.5", 33 | "cors": "^2.8.5", 34 | "eventsource": "^3.0.2", 35 | "express": "^5.0.1", 36 | "express-rate-limit": "^7.5.0", 37 | "pkce-challenge": "^4.1.0", 38 | "raw-body": "^3.0.0", 39 | "zod": "^3.23.8", 40 | "zod-to-json-schema": "^3.24.1" 41 | }, 42 | "engines": { 43 | "node": ">=18" 44 | } 45 | }, 46 | "node_modules/@types/body-parser": { 47 | "version": "1.19.5", 48 | "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", 49 | "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", 50 | "dev": true, 51 | "license": "MIT", 52 | "dependencies": { 53 | "@types/connect": "*", 54 | "@types/node": "*" 55 | } 56 | }, 57 | "node_modules/@types/connect": { 58 | "version": "3.4.38", 59 | "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", 60 | "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", 61 | "dev": true, 62 | "license": "MIT", 63 | "dependencies": { 64 | "@types/node": "*" 65 | } 66 | }, 67 | "node_modules/@types/express": { 68 | "version": "5.0.1", 69 | "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.1.tgz", 70 | "integrity": "sha512-UZUw8vjpWFXuDnjFTh7/5c2TWDlQqeXHi6hcN7F2XSVT5P+WmUnnbFS3KA6Jnc6IsEqI2qCVu2bK0R0J4A8ZQQ==", 71 | "dev": true, 72 | "license": "MIT", 73 | "dependencies": { 74 | "@types/body-parser": "*", 75 | "@types/express-serve-static-core": "^5.0.0", 76 | "@types/serve-static": "*" 77 | } 78 | }, 79 | "node_modules/@types/express-serve-static-core": { 80 | "version": "5.0.6", 81 | "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.6.tgz", 82 | "integrity": "sha512-3xhRnjJPkULekpSzgtoNYYcTWgEZkp4myc+Saevii5JPnHNvHMRlBSHDbs7Bh1iPPoVTERHEZXyhyLbMEsExsA==", 83 | "dev": true, 84 | "license": "MIT", 85 | "dependencies": { 86 | "@types/node": "*", 87 | "@types/qs": "*", 88 | "@types/range-parser": "*", 89 | "@types/send": "*" 90 | } 91 | }, 92 | "node_modules/@types/http-errors": { 93 | "version": "2.0.4", 94 | "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", 95 | "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==", 96 | "dev": true, 97 | "license": "MIT" 98 | }, 99 | "node_modules/@types/mime": { 100 | "version": "1.3.5", 101 | "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", 102 | "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", 103 | "dev": true, 104 | "license": "MIT" 105 | }, 106 | "node_modules/@types/node": { 107 | "version": "22.13.11", 108 | "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.11.tgz", 109 | "integrity": "sha512-iEUCUJoU0i3VnrCmgoWCXttklWcvoCIx4jzcP22fioIVSdTmjgoEvmAO/QPw6TcS9k5FrNgn4w7q5lGOd1CT5g==", 110 | "dev": true, 111 | "license": "MIT", 112 | "dependencies": { 113 | "undici-types": "~6.20.0" 114 | } 115 | }, 116 | "node_modules/@types/qs": { 117 | "version": "6.9.18", 118 | "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.18.tgz", 119 | "integrity": "sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==", 120 | "dev": true, 121 | "license": "MIT" 122 | }, 123 | "node_modules/@types/range-parser": { 124 | "version": "1.2.7", 125 | "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", 126 | "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", 127 | "dev": true, 128 | "license": "MIT" 129 | }, 130 | "node_modules/@types/send": { 131 | "version": "0.17.4", 132 | "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", 133 | "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", 134 | "dev": true, 135 | "license": "MIT", 136 | "dependencies": { 137 | "@types/mime": "^1", 138 | "@types/node": "*" 139 | } 140 | }, 141 | "node_modules/@types/serve-static": { 142 | "version": "1.15.7", 143 | "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz", 144 | "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", 145 | "dev": true, 146 | "license": "MIT", 147 | "dependencies": { 148 | "@types/http-errors": "*", 149 | "@types/node": "*", 150 | "@types/send": "*" 151 | } 152 | }, 153 | "node_modules/@types/ws": { 154 | "version": "8.18.0", 155 | "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.0.tgz", 156 | "integrity": "sha512-8svvI3hMyvN0kKCJMvTJP/x6Y/EoQbepff882wL+Sn5QsXb3etnamgrJq4isrBxSJj5L2AuXcI0+bgkoAXGUJw==", 157 | "dev": true, 158 | "license": "MIT", 159 | "dependencies": { 160 | "@types/node": "*" 161 | } 162 | }, 163 | "node_modules/accepts": { 164 | "version": "2.0.0", 165 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", 166 | "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", 167 | "license": "MIT", 168 | "dependencies": { 169 | "mime-types": "^3.0.0", 170 | "negotiator": "^1.0.0" 171 | }, 172 | "engines": { 173 | "node": ">= 0.6" 174 | } 175 | }, 176 | "node_modules/asynckit": { 177 | "version": "0.4.0", 178 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 179 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", 180 | "license": "MIT" 181 | }, 182 | "node_modules/axios": { 183 | "version": "1.8.4", 184 | "resolved": "https://registry.npmjs.org/axios/-/axios-1.8.4.tgz", 185 | "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", 186 | "license": "MIT", 187 | "dependencies": { 188 | "follow-redirects": "^1.15.6", 189 | "form-data": "^4.0.0", 190 | "proxy-from-env": "^1.1.0" 191 | } 192 | }, 193 | "node_modules/body-parser": { 194 | "version": "2.1.0", 195 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.1.0.tgz", 196 | "integrity": "sha512-/hPxh61E+ll0Ujp24Ilm64cykicul1ypfwjVttduAiEdtnJFvLePSrIPk+HMImtNv5270wOGCb1Tns2rybMkoQ==", 197 | "license": "MIT", 198 | "dependencies": { 199 | "bytes": "^3.1.2", 200 | "content-type": "^1.0.5", 201 | "debug": "^4.4.0", 202 | "http-errors": "^2.0.0", 203 | "iconv-lite": "^0.5.2", 204 | "on-finished": "^2.4.1", 205 | "qs": "^6.14.0", 206 | "raw-body": "^3.0.0", 207 | "type-is": "^2.0.0" 208 | }, 209 | "engines": { 210 | "node": ">=18" 211 | } 212 | }, 213 | "node_modules/body-parser/node_modules/debug": { 214 | "version": "4.4.0", 215 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", 216 | "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", 217 | "license": "MIT", 218 | "dependencies": { 219 | "ms": "^2.1.3" 220 | }, 221 | "engines": { 222 | "node": ">=6.0" 223 | }, 224 | "peerDependenciesMeta": { 225 | "supports-color": { 226 | "optional": true 227 | } 228 | } 229 | }, 230 | "node_modules/body-parser/node_modules/ms": { 231 | "version": "2.1.3", 232 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 233 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 234 | "license": "MIT" 235 | }, 236 | "node_modules/body-parser/node_modules/qs": { 237 | "version": "6.14.0", 238 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", 239 | "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", 240 | "license": "BSD-3-Clause", 241 | "dependencies": { 242 | "side-channel": "^1.1.0" 243 | }, 244 | "engines": { 245 | "node": ">=0.6" 246 | }, 247 | "funding": { 248 | "url": "https://github.com/sponsors/ljharb" 249 | } 250 | }, 251 | "node_modules/bytes": { 252 | "version": "3.1.2", 253 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", 254 | "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", 255 | "license": "MIT", 256 | "engines": { 257 | "node": ">= 0.8" 258 | } 259 | }, 260 | "node_modules/call-bind-apply-helpers": { 261 | "version": "1.0.2", 262 | "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", 263 | "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", 264 | "license": "MIT", 265 | "dependencies": { 266 | "es-errors": "^1.3.0", 267 | "function-bind": "^1.1.2" 268 | }, 269 | "engines": { 270 | "node": ">= 0.4" 271 | } 272 | }, 273 | "node_modules/call-bound": { 274 | "version": "1.0.4", 275 | "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", 276 | "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", 277 | "license": "MIT", 278 | "dependencies": { 279 | "call-bind-apply-helpers": "^1.0.2", 280 | "get-intrinsic": "^1.3.0" 281 | }, 282 | "engines": { 283 | "node": ">= 0.4" 284 | }, 285 | "funding": { 286 | "url": "https://github.com/sponsors/ljharb" 287 | } 288 | }, 289 | "node_modules/combined-stream": { 290 | "version": "1.0.8", 291 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 292 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 293 | "license": "MIT", 294 | "dependencies": { 295 | "delayed-stream": "~1.0.0" 296 | }, 297 | "engines": { 298 | "node": ">= 0.8" 299 | } 300 | }, 301 | "node_modules/content-disposition": { 302 | "version": "1.0.0", 303 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz", 304 | "integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==", 305 | "license": "MIT", 306 | "dependencies": { 307 | "safe-buffer": "5.2.1" 308 | }, 309 | "engines": { 310 | "node": ">= 0.6" 311 | } 312 | }, 313 | "node_modules/content-type": { 314 | "version": "1.0.5", 315 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", 316 | "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", 317 | "license": "MIT", 318 | "engines": { 319 | "node": ">= 0.6" 320 | } 321 | }, 322 | "node_modules/cookie": { 323 | "version": "0.7.1", 324 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", 325 | "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", 326 | "license": "MIT", 327 | "engines": { 328 | "node": ">= 0.6" 329 | } 330 | }, 331 | "node_modules/cookie-signature": { 332 | "version": "1.2.2", 333 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", 334 | "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", 335 | "license": "MIT", 336 | "engines": { 337 | "node": ">=6.6.0" 338 | } 339 | }, 340 | "node_modules/cors": { 341 | "version": "2.8.5", 342 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", 343 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", 344 | "license": "MIT", 345 | "dependencies": { 346 | "object-assign": "^4", 347 | "vary": "^1" 348 | }, 349 | "engines": { 350 | "node": ">= 0.10" 351 | } 352 | }, 353 | "node_modules/debug": { 354 | "version": "4.3.6", 355 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", 356 | "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", 357 | "license": "MIT", 358 | "dependencies": { 359 | "ms": "2.1.2" 360 | }, 361 | "engines": { 362 | "node": ">=6.0" 363 | }, 364 | "peerDependenciesMeta": { 365 | "supports-color": { 366 | "optional": true 367 | } 368 | } 369 | }, 370 | "node_modules/delayed-stream": { 371 | "version": "1.0.0", 372 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 373 | "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", 374 | "license": "MIT", 375 | "engines": { 376 | "node": ">=0.4.0" 377 | } 378 | }, 379 | "node_modules/depd": { 380 | "version": "2.0.0", 381 | "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", 382 | "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", 383 | "license": "MIT", 384 | "engines": { 385 | "node": ">= 0.8" 386 | } 387 | }, 388 | "node_modules/destroy": { 389 | "version": "1.2.0", 390 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", 391 | "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", 392 | "license": "MIT", 393 | "engines": { 394 | "node": ">= 0.8", 395 | "npm": "1.2.8000 || >= 1.4.16" 396 | } 397 | }, 398 | "node_modules/dunder-proto": { 399 | "version": "1.0.1", 400 | "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", 401 | "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", 402 | "license": "MIT", 403 | "dependencies": { 404 | "call-bind-apply-helpers": "^1.0.1", 405 | "es-errors": "^1.3.0", 406 | "gopd": "^1.2.0" 407 | }, 408 | "engines": { 409 | "node": ">= 0.4" 410 | } 411 | }, 412 | "node_modules/ee-first": { 413 | "version": "1.1.1", 414 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 415 | "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", 416 | "license": "MIT" 417 | }, 418 | "node_modules/encodeurl": { 419 | "version": "2.0.0", 420 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", 421 | "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", 422 | "license": "MIT", 423 | "engines": { 424 | "node": ">= 0.8" 425 | } 426 | }, 427 | "node_modules/es-define-property": { 428 | "version": "1.0.1", 429 | "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", 430 | "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", 431 | "license": "MIT", 432 | "engines": { 433 | "node": ">= 0.4" 434 | } 435 | }, 436 | "node_modules/es-errors": { 437 | "version": "1.3.0", 438 | "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", 439 | "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", 440 | "license": "MIT", 441 | "engines": { 442 | "node": ">= 0.4" 443 | } 444 | }, 445 | "node_modules/es-object-atoms": { 446 | "version": "1.1.1", 447 | "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", 448 | "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", 449 | "license": "MIT", 450 | "dependencies": { 451 | "es-errors": "^1.3.0" 452 | }, 453 | "engines": { 454 | "node": ">= 0.4" 455 | } 456 | }, 457 | "node_modules/es-set-tostringtag": { 458 | "version": "2.1.0", 459 | "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", 460 | "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", 461 | "license": "MIT", 462 | "dependencies": { 463 | "es-errors": "^1.3.0", 464 | "get-intrinsic": "^1.2.6", 465 | "has-tostringtag": "^1.0.2", 466 | "hasown": "^2.0.2" 467 | }, 468 | "engines": { 469 | "node": ">= 0.4" 470 | } 471 | }, 472 | "node_modules/escape-html": { 473 | "version": "1.0.3", 474 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 475 | "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", 476 | "license": "MIT" 477 | }, 478 | "node_modules/etag": { 479 | "version": "1.8.1", 480 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 481 | "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", 482 | "license": "MIT", 483 | "engines": { 484 | "node": ">= 0.6" 485 | } 486 | }, 487 | "node_modules/eventsource": { 488 | "version": "3.0.5", 489 | "resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.5.tgz", 490 | "integrity": "sha512-LT/5J605bx5SNyE+ITBDiM3FxffBiq9un7Vx0EwMDM3vg8sWKx/tO2zC+LMqZ+smAM0F2hblaDZUVZF0te2pSw==", 491 | "license": "MIT", 492 | "dependencies": { 493 | "eventsource-parser": "^3.0.0" 494 | }, 495 | "engines": { 496 | "node": ">=18.0.0" 497 | } 498 | }, 499 | "node_modules/eventsource-parser": { 500 | "version": "3.0.0", 501 | "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.0.0.tgz", 502 | "integrity": "sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA==", 503 | "license": "MIT", 504 | "engines": { 505 | "node": ">=18.0.0" 506 | } 507 | }, 508 | "node_modules/express": { 509 | "version": "5.0.1", 510 | "resolved": "https://registry.npmjs.org/express/-/express-5.0.1.tgz", 511 | "integrity": "sha512-ORF7g6qGnD+YtUG9yx4DFoqCShNMmUKiXuT5oWMHiOvt/4WFbHC6yCwQMTSBMno7AqntNCAzzcnnjowRkTL9eQ==", 512 | "license": "MIT", 513 | "dependencies": { 514 | "accepts": "^2.0.0", 515 | "body-parser": "^2.0.1", 516 | "content-disposition": "^1.0.0", 517 | "content-type": "~1.0.4", 518 | "cookie": "0.7.1", 519 | "cookie-signature": "^1.2.1", 520 | "debug": "4.3.6", 521 | "depd": "2.0.0", 522 | "encodeurl": "~2.0.0", 523 | "escape-html": "~1.0.3", 524 | "etag": "~1.8.1", 525 | "finalhandler": "^2.0.0", 526 | "fresh": "2.0.0", 527 | "http-errors": "2.0.0", 528 | "merge-descriptors": "^2.0.0", 529 | "methods": "~1.1.2", 530 | "mime-types": "^3.0.0", 531 | "on-finished": "2.4.1", 532 | "once": "1.4.0", 533 | "parseurl": "~1.3.3", 534 | "proxy-addr": "~2.0.7", 535 | "qs": "6.13.0", 536 | "range-parser": "~1.2.1", 537 | "router": "^2.0.0", 538 | "safe-buffer": "5.2.1", 539 | "send": "^1.1.0", 540 | "serve-static": "^2.1.0", 541 | "setprototypeof": "1.2.0", 542 | "statuses": "2.0.1", 543 | "type-is": "^2.0.0", 544 | "utils-merge": "1.0.1", 545 | "vary": "~1.1.2" 546 | }, 547 | "engines": { 548 | "node": ">= 18" 549 | } 550 | }, 551 | "node_modules/express-rate-limit": { 552 | "version": "7.5.0", 553 | "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-7.5.0.tgz", 554 | "integrity": "sha512-eB5zbQh5h+VenMPM3fh+nw1YExi5nMr6HUCR62ELSP11huvxm/Uir1H1QEyTkk5QX6A58pX6NmaTMceKZ0Eodg==", 555 | "license": "MIT", 556 | "engines": { 557 | "node": ">= 16" 558 | }, 559 | "funding": { 560 | "url": "https://github.com/sponsors/express-rate-limit" 561 | }, 562 | "peerDependencies": { 563 | "express": "^4.11 || 5 || ^5.0.0-beta.1" 564 | } 565 | }, 566 | "node_modules/finalhandler": { 567 | "version": "2.1.0", 568 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz", 569 | "integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==", 570 | "license": "MIT", 571 | "dependencies": { 572 | "debug": "^4.4.0", 573 | "encodeurl": "^2.0.0", 574 | "escape-html": "^1.0.3", 575 | "on-finished": "^2.4.1", 576 | "parseurl": "^1.3.3", 577 | "statuses": "^2.0.1" 578 | }, 579 | "engines": { 580 | "node": ">= 0.8" 581 | } 582 | }, 583 | "node_modules/finalhandler/node_modules/debug": { 584 | "version": "4.4.0", 585 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", 586 | "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", 587 | "license": "MIT", 588 | "dependencies": { 589 | "ms": "^2.1.3" 590 | }, 591 | "engines": { 592 | "node": ">=6.0" 593 | }, 594 | "peerDependenciesMeta": { 595 | "supports-color": { 596 | "optional": true 597 | } 598 | } 599 | }, 600 | "node_modules/finalhandler/node_modules/ms": { 601 | "version": "2.1.3", 602 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 603 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 604 | "license": "MIT" 605 | }, 606 | "node_modules/follow-redirects": { 607 | "version": "1.15.9", 608 | "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", 609 | "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", 610 | "funding": [ 611 | { 612 | "type": "individual", 613 | "url": "https://github.com/sponsors/RubenVerborgh" 614 | } 615 | ], 616 | "license": "MIT", 617 | "engines": { 618 | "node": ">=4.0" 619 | }, 620 | "peerDependenciesMeta": { 621 | "debug": { 622 | "optional": true 623 | } 624 | } 625 | }, 626 | "node_modules/form-data": { 627 | "version": "4.0.2", 628 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", 629 | "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", 630 | "license": "MIT", 631 | "dependencies": { 632 | "asynckit": "^0.4.0", 633 | "combined-stream": "^1.0.8", 634 | "es-set-tostringtag": "^2.1.0", 635 | "mime-types": "^2.1.12" 636 | }, 637 | "engines": { 638 | "node": ">= 6" 639 | } 640 | }, 641 | "node_modules/form-data/node_modules/mime-db": { 642 | "version": "1.52.0", 643 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 644 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 645 | "license": "MIT", 646 | "engines": { 647 | "node": ">= 0.6" 648 | } 649 | }, 650 | "node_modules/form-data/node_modules/mime-types": { 651 | "version": "2.1.35", 652 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 653 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 654 | "license": "MIT", 655 | "dependencies": { 656 | "mime-db": "1.52.0" 657 | }, 658 | "engines": { 659 | "node": ">= 0.6" 660 | } 661 | }, 662 | "node_modules/forwarded": { 663 | "version": "0.2.0", 664 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", 665 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", 666 | "license": "MIT", 667 | "engines": { 668 | "node": ">= 0.6" 669 | } 670 | }, 671 | "node_modules/fresh": { 672 | "version": "2.0.0", 673 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", 674 | "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", 675 | "license": "MIT", 676 | "engines": { 677 | "node": ">= 0.8" 678 | } 679 | }, 680 | "node_modules/function-bind": { 681 | "version": "1.1.2", 682 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 683 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 684 | "license": "MIT", 685 | "funding": { 686 | "url": "https://github.com/sponsors/ljharb" 687 | } 688 | }, 689 | "node_modules/get-intrinsic": { 690 | "version": "1.3.0", 691 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", 692 | "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", 693 | "license": "MIT", 694 | "dependencies": { 695 | "call-bind-apply-helpers": "^1.0.2", 696 | "es-define-property": "^1.0.1", 697 | "es-errors": "^1.3.0", 698 | "es-object-atoms": "^1.1.1", 699 | "function-bind": "^1.1.2", 700 | "get-proto": "^1.0.1", 701 | "gopd": "^1.2.0", 702 | "has-symbols": "^1.1.0", 703 | "hasown": "^2.0.2", 704 | "math-intrinsics": "^1.1.0" 705 | }, 706 | "engines": { 707 | "node": ">= 0.4" 708 | }, 709 | "funding": { 710 | "url": "https://github.com/sponsors/ljharb" 711 | } 712 | }, 713 | "node_modules/get-proto": { 714 | "version": "1.0.1", 715 | "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", 716 | "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", 717 | "license": "MIT", 718 | "dependencies": { 719 | "dunder-proto": "^1.0.1", 720 | "es-object-atoms": "^1.0.0" 721 | }, 722 | "engines": { 723 | "node": ">= 0.4" 724 | } 725 | }, 726 | "node_modules/gopd": { 727 | "version": "1.2.0", 728 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", 729 | "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", 730 | "license": "MIT", 731 | "engines": { 732 | "node": ">= 0.4" 733 | }, 734 | "funding": { 735 | "url": "https://github.com/sponsors/ljharb" 736 | } 737 | }, 738 | "node_modules/has-symbols": { 739 | "version": "1.1.0", 740 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", 741 | "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", 742 | "license": "MIT", 743 | "engines": { 744 | "node": ">= 0.4" 745 | }, 746 | "funding": { 747 | "url": "https://github.com/sponsors/ljharb" 748 | } 749 | }, 750 | "node_modules/has-tostringtag": { 751 | "version": "1.0.2", 752 | "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", 753 | "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", 754 | "license": "MIT", 755 | "dependencies": { 756 | "has-symbols": "^1.0.3" 757 | }, 758 | "engines": { 759 | "node": ">= 0.4" 760 | }, 761 | "funding": { 762 | "url": "https://github.com/sponsors/ljharb" 763 | } 764 | }, 765 | "node_modules/hasown": { 766 | "version": "2.0.2", 767 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", 768 | "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", 769 | "license": "MIT", 770 | "dependencies": { 771 | "function-bind": "^1.1.2" 772 | }, 773 | "engines": { 774 | "node": ">= 0.4" 775 | } 776 | }, 777 | "node_modules/http-errors": { 778 | "version": "2.0.0", 779 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", 780 | "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", 781 | "license": "MIT", 782 | "dependencies": { 783 | "depd": "2.0.0", 784 | "inherits": "2.0.4", 785 | "setprototypeof": "1.2.0", 786 | "statuses": "2.0.1", 787 | "toidentifier": "1.0.1" 788 | }, 789 | "engines": { 790 | "node": ">= 0.8" 791 | } 792 | }, 793 | "node_modules/iconv-lite": { 794 | "version": "0.5.2", 795 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.5.2.tgz", 796 | "integrity": "sha512-kERHXvpSaB4aU3eANwidg79K8FlrN77m8G9V+0vOR3HYaRifrlwMEpT7ZBJqLSEIHnEgJTHcWK82wwLwwKwtag==", 797 | "license": "MIT", 798 | "dependencies": { 799 | "safer-buffer": ">= 2.1.2 < 3" 800 | }, 801 | "engines": { 802 | "node": ">=0.10.0" 803 | } 804 | }, 805 | "node_modules/inherits": { 806 | "version": "2.0.4", 807 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 808 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 809 | "license": "ISC" 810 | }, 811 | "node_modules/ipaddr.js": { 812 | "version": "1.9.1", 813 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 814 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", 815 | "license": "MIT", 816 | "engines": { 817 | "node": ">= 0.10" 818 | } 819 | }, 820 | "node_modules/is-promise": { 821 | "version": "4.0.0", 822 | "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", 823 | "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", 824 | "license": "MIT" 825 | }, 826 | "node_modules/math-intrinsics": { 827 | "version": "1.1.0", 828 | "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", 829 | "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", 830 | "license": "MIT", 831 | "engines": { 832 | "node": ">= 0.4" 833 | } 834 | }, 835 | "node_modules/media-typer": { 836 | "version": "1.1.0", 837 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", 838 | "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", 839 | "license": "MIT", 840 | "engines": { 841 | "node": ">= 0.8" 842 | } 843 | }, 844 | "node_modules/merge-descriptors": { 845 | "version": "2.0.0", 846 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", 847 | "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", 848 | "license": "MIT", 849 | "engines": { 850 | "node": ">=18" 851 | }, 852 | "funding": { 853 | "url": "https://github.com/sponsors/sindresorhus" 854 | } 855 | }, 856 | "node_modules/methods": { 857 | "version": "1.1.2", 858 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 859 | "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", 860 | "license": "MIT", 861 | "engines": { 862 | "node": ">= 0.6" 863 | } 864 | }, 865 | "node_modules/mime-db": { 866 | "version": "1.54.0", 867 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", 868 | "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", 869 | "license": "MIT", 870 | "engines": { 871 | "node": ">= 0.6" 872 | } 873 | }, 874 | "node_modules/mime-types": { 875 | "version": "3.0.0", 876 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.0.tgz", 877 | "integrity": "sha512-XqoSHeCGjVClAmoGFG3lVFqQFRIrTVw2OH3axRqAcfaw+gHWIfnASS92AV+Rl/mk0MupgZTRHQOjxY6YVnzK5w==", 878 | "license": "MIT", 879 | "dependencies": { 880 | "mime-db": "^1.53.0" 881 | }, 882 | "engines": { 883 | "node": ">= 0.6" 884 | } 885 | }, 886 | "node_modules/ms": { 887 | "version": "2.1.2", 888 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 889 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 890 | "license": "MIT" 891 | }, 892 | "node_modules/negotiator": { 893 | "version": "1.0.0", 894 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", 895 | "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", 896 | "license": "MIT", 897 | "engines": { 898 | "node": ">= 0.6" 899 | } 900 | }, 901 | "node_modules/object-assign": { 902 | "version": "4.1.1", 903 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 904 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", 905 | "license": "MIT", 906 | "engines": { 907 | "node": ">=0.10.0" 908 | } 909 | }, 910 | "node_modules/object-inspect": { 911 | "version": "1.13.4", 912 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", 913 | "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", 914 | "license": "MIT", 915 | "engines": { 916 | "node": ">= 0.4" 917 | }, 918 | "funding": { 919 | "url": "https://github.com/sponsors/ljharb" 920 | } 921 | }, 922 | "node_modules/on-finished": { 923 | "version": "2.4.1", 924 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", 925 | "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", 926 | "license": "MIT", 927 | "dependencies": { 928 | "ee-first": "1.1.1" 929 | }, 930 | "engines": { 931 | "node": ">= 0.8" 932 | } 933 | }, 934 | "node_modules/once": { 935 | "version": "1.4.0", 936 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 937 | "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", 938 | "license": "ISC", 939 | "dependencies": { 940 | "wrappy": "1" 941 | } 942 | }, 943 | "node_modules/parseurl": { 944 | "version": "1.3.3", 945 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 946 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", 947 | "license": "MIT", 948 | "engines": { 949 | "node": ">= 0.8" 950 | } 951 | }, 952 | "node_modules/path-to-regexp": { 953 | "version": "8.2.0", 954 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", 955 | "integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==", 956 | "license": "MIT", 957 | "engines": { 958 | "node": ">=16" 959 | } 960 | }, 961 | "node_modules/pkce-challenge": { 962 | "version": "4.1.0", 963 | "resolved": "https://registry.npmjs.org/pkce-challenge/-/pkce-challenge-4.1.0.tgz", 964 | "integrity": "sha512-ZBmhE1C9LcPoH9XZSdwiPtbPHZROwAnMy+kIFQVrnMCxY4Cudlz3gBOpzilgc0jOgRaiT3sIWfpMomW2ar2orQ==", 965 | "license": "MIT", 966 | "engines": { 967 | "node": ">=16.20.0" 968 | } 969 | }, 970 | "node_modules/prettier": { 971 | "version": "3.5.3", 972 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", 973 | "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", 974 | "license": "MIT", 975 | "bin": { 976 | "prettier": "bin/prettier.cjs" 977 | }, 978 | "engines": { 979 | "node": ">=14" 980 | }, 981 | "funding": { 982 | "url": "https://github.com/prettier/prettier?sponsor=1" 983 | } 984 | }, 985 | "node_modules/proxy-addr": { 986 | "version": "2.0.7", 987 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", 988 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", 989 | "license": "MIT", 990 | "dependencies": { 991 | "forwarded": "0.2.0", 992 | "ipaddr.js": "1.9.1" 993 | }, 994 | "engines": { 995 | "node": ">= 0.10" 996 | } 997 | }, 998 | "node_modules/proxy-from-env": { 999 | "version": "1.1.0", 1000 | "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", 1001 | "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", 1002 | "license": "MIT" 1003 | }, 1004 | "node_modules/qs": { 1005 | "version": "6.13.0", 1006 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", 1007 | "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", 1008 | "license": "BSD-3-Clause", 1009 | "dependencies": { 1010 | "side-channel": "^1.0.6" 1011 | }, 1012 | "engines": { 1013 | "node": ">=0.6" 1014 | }, 1015 | "funding": { 1016 | "url": "https://github.com/sponsors/ljharb" 1017 | } 1018 | }, 1019 | "node_modules/range-parser": { 1020 | "version": "1.2.1", 1021 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 1022 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", 1023 | "license": "MIT", 1024 | "engines": { 1025 | "node": ">= 0.6" 1026 | } 1027 | }, 1028 | "node_modules/raw-body": { 1029 | "version": "3.0.0", 1030 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.0.tgz", 1031 | "integrity": "sha512-RmkhL8CAyCRPXCE28MMH0z2PNWQBNk2Q09ZdxM9IOOXwxwZbN+qbWaatPkdkWIKL2ZVDImrN/pK5HTRz2PcS4g==", 1032 | "license": "MIT", 1033 | "dependencies": { 1034 | "bytes": "3.1.2", 1035 | "http-errors": "2.0.0", 1036 | "iconv-lite": "0.6.3", 1037 | "unpipe": "1.0.0" 1038 | }, 1039 | "engines": { 1040 | "node": ">= 0.8" 1041 | } 1042 | }, 1043 | "node_modules/raw-body/node_modules/iconv-lite": { 1044 | "version": "0.6.3", 1045 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", 1046 | "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", 1047 | "license": "MIT", 1048 | "dependencies": { 1049 | "safer-buffer": ">= 2.1.2 < 3.0.0" 1050 | }, 1051 | "engines": { 1052 | "node": ">=0.10.0" 1053 | } 1054 | }, 1055 | "node_modules/router": { 1056 | "version": "2.1.0", 1057 | "resolved": "https://registry.npmjs.org/router/-/router-2.1.0.tgz", 1058 | "integrity": "sha512-/m/NSLxeYEgWNtyC+WtNHCF7jbGxOibVWKnn+1Psff4dJGOfoXP+MuC/f2CwSmyiHdOIzYnYFp4W6GxWfekaLA==", 1059 | "license": "MIT", 1060 | "dependencies": { 1061 | "is-promise": "^4.0.0", 1062 | "parseurl": "^1.3.3", 1063 | "path-to-regexp": "^8.0.0" 1064 | }, 1065 | "engines": { 1066 | "node": ">= 18" 1067 | } 1068 | }, 1069 | "node_modules/safe-buffer": { 1070 | "version": "5.2.1", 1071 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 1072 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", 1073 | "funding": [ 1074 | { 1075 | "type": "github", 1076 | "url": "https://github.com/sponsors/feross" 1077 | }, 1078 | { 1079 | "type": "patreon", 1080 | "url": "https://www.patreon.com/feross" 1081 | }, 1082 | { 1083 | "type": "consulting", 1084 | "url": "https://feross.org/support" 1085 | } 1086 | ], 1087 | "license": "MIT" 1088 | }, 1089 | "node_modules/safer-buffer": { 1090 | "version": "2.1.2", 1091 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 1092 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", 1093 | "license": "MIT" 1094 | }, 1095 | "node_modules/send": { 1096 | "version": "1.1.0", 1097 | "resolved": "https://registry.npmjs.org/send/-/send-1.1.0.tgz", 1098 | "integrity": "sha512-v67WcEouB5GxbTWL/4NeToqcZiAWEq90N888fczVArY8A79J0L4FD7vj5hm3eUMua5EpoQ59wa/oovY6TLvRUA==", 1099 | "license": "MIT", 1100 | "dependencies": { 1101 | "debug": "^4.3.5", 1102 | "destroy": "^1.2.0", 1103 | "encodeurl": "^2.0.0", 1104 | "escape-html": "^1.0.3", 1105 | "etag": "^1.8.1", 1106 | "fresh": "^0.5.2", 1107 | "http-errors": "^2.0.0", 1108 | "mime-types": "^2.1.35", 1109 | "ms": "^2.1.3", 1110 | "on-finished": "^2.4.1", 1111 | "range-parser": "^1.2.1", 1112 | "statuses": "^2.0.1" 1113 | }, 1114 | "engines": { 1115 | "node": ">= 18" 1116 | } 1117 | }, 1118 | "node_modules/send/node_modules/fresh": { 1119 | "version": "0.5.2", 1120 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 1121 | "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", 1122 | "license": "MIT", 1123 | "engines": { 1124 | "node": ">= 0.6" 1125 | } 1126 | }, 1127 | "node_modules/send/node_modules/mime-db": { 1128 | "version": "1.52.0", 1129 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 1130 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 1131 | "license": "MIT", 1132 | "engines": { 1133 | "node": ">= 0.6" 1134 | } 1135 | }, 1136 | "node_modules/send/node_modules/mime-types": { 1137 | "version": "2.1.35", 1138 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 1139 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 1140 | "license": "MIT", 1141 | "dependencies": { 1142 | "mime-db": "1.52.0" 1143 | }, 1144 | "engines": { 1145 | "node": ">= 0.6" 1146 | } 1147 | }, 1148 | "node_modules/send/node_modules/ms": { 1149 | "version": "2.1.3", 1150 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 1151 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 1152 | "license": "MIT" 1153 | }, 1154 | "node_modules/serve-static": { 1155 | "version": "2.1.0", 1156 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.1.0.tgz", 1157 | "integrity": "sha512-A3We5UfEjG8Z7VkDv6uItWw6HY2bBSBJT1KtVESn6EOoOr2jAxNhxWCLY3jDE2WcuHXByWju74ck3ZgLwL8xmA==", 1158 | "license": "MIT", 1159 | "dependencies": { 1160 | "encodeurl": "^2.0.0", 1161 | "escape-html": "^1.0.3", 1162 | "parseurl": "^1.3.3", 1163 | "send": "^1.0.0" 1164 | }, 1165 | "engines": { 1166 | "node": ">= 18" 1167 | } 1168 | }, 1169 | "node_modules/setprototypeof": { 1170 | "version": "1.2.0", 1171 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", 1172 | "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", 1173 | "license": "ISC" 1174 | }, 1175 | "node_modules/side-channel": { 1176 | "version": "1.1.0", 1177 | "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", 1178 | "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", 1179 | "license": "MIT", 1180 | "dependencies": { 1181 | "es-errors": "^1.3.0", 1182 | "object-inspect": "^1.13.3", 1183 | "side-channel-list": "^1.0.0", 1184 | "side-channel-map": "^1.0.1", 1185 | "side-channel-weakmap": "^1.0.2" 1186 | }, 1187 | "engines": { 1188 | "node": ">= 0.4" 1189 | }, 1190 | "funding": { 1191 | "url": "https://github.com/sponsors/ljharb" 1192 | } 1193 | }, 1194 | "node_modules/side-channel-list": { 1195 | "version": "1.0.0", 1196 | "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", 1197 | "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", 1198 | "license": "MIT", 1199 | "dependencies": { 1200 | "es-errors": "^1.3.0", 1201 | "object-inspect": "^1.13.3" 1202 | }, 1203 | "engines": { 1204 | "node": ">= 0.4" 1205 | }, 1206 | "funding": { 1207 | "url": "https://github.com/sponsors/ljharb" 1208 | } 1209 | }, 1210 | "node_modules/side-channel-map": { 1211 | "version": "1.0.1", 1212 | "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", 1213 | "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", 1214 | "license": "MIT", 1215 | "dependencies": { 1216 | "call-bound": "^1.0.2", 1217 | "es-errors": "^1.3.0", 1218 | "get-intrinsic": "^1.2.5", 1219 | "object-inspect": "^1.13.3" 1220 | }, 1221 | "engines": { 1222 | "node": ">= 0.4" 1223 | }, 1224 | "funding": { 1225 | "url": "https://github.com/sponsors/ljharb" 1226 | } 1227 | }, 1228 | "node_modules/side-channel-weakmap": { 1229 | "version": "1.0.2", 1230 | "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", 1231 | "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", 1232 | "license": "MIT", 1233 | "dependencies": { 1234 | "call-bound": "^1.0.2", 1235 | "es-errors": "^1.3.0", 1236 | "get-intrinsic": "^1.2.5", 1237 | "object-inspect": "^1.13.3", 1238 | "side-channel-map": "^1.0.1" 1239 | }, 1240 | "engines": { 1241 | "node": ">= 0.4" 1242 | }, 1243 | "funding": { 1244 | "url": "https://github.com/sponsors/ljharb" 1245 | } 1246 | }, 1247 | "node_modules/statuses": { 1248 | "version": "2.0.1", 1249 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", 1250 | "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", 1251 | "license": "MIT", 1252 | "engines": { 1253 | "node": ">= 0.8" 1254 | } 1255 | }, 1256 | "node_modules/toidentifier": { 1257 | "version": "1.0.1", 1258 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", 1259 | "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", 1260 | "license": "MIT", 1261 | "engines": { 1262 | "node": ">=0.6" 1263 | } 1264 | }, 1265 | "node_modules/type-is": { 1266 | "version": "2.0.0", 1267 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.0.tgz", 1268 | "integrity": "sha512-gd0sGezQYCbWSbkZr75mln4YBidWUN60+devscpLF5mtRDUpiaTvKpBNrdaCvel1NdR2k6vclXybU5fBd2i+nw==", 1269 | "license": "MIT", 1270 | "dependencies": { 1271 | "content-type": "^1.0.5", 1272 | "media-typer": "^1.1.0", 1273 | "mime-types": "^3.0.0" 1274 | }, 1275 | "engines": { 1276 | "node": ">= 0.6" 1277 | } 1278 | }, 1279 | "node_modules/typescript": { 1280 | "version": "5.8.2", 1281 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", 1282 | "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", 1283 | "license": "Apache-2.0", 1284 | "bin": { 1285 | "tsc": "bin/tsc", 1286 | "tsserver": "bin/tsserver" 1287 | }, 1288 | "engines": { 1289 | "node": ">=14.17" 1290 | } 1291 | }, 1292 | "node_modules/undici-types": { 1293 | "version": "6.20.0", 1294 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", 1295 | "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", 1296 | "dev": true, 1297 | "license": "MIT" 1298 | }, 1299 | "node_modules/unpipe": { 1300 | "version": "1.0.0", 1301 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 1302 | "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", 1303 | "license": "MIT", 1304 | "engines": { 1305 | "node": ">= 0.8" 1306 | } 1307 | }, 1308 | "node_modules/utils-merge": { 1309 | "version": "1.0.1", 1310 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 1311 | "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", 1312 | "license": "MIT", 1313 | "engines": { 1314 | "node": ">= 0.4.0" 1315 | } 1316 | }, 1317 | "node_modules/vary": { 1318 | "version": "1.1.2", 1319 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 1320 | "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", 1321 | "license": "MIT", 1322 | "engines": { 1323 | "node": ">= 0.8" 1324 | } 1325 | }, 1326 | "node_modules/wrappy": { 1327 | "version": "1.0.2", 1328 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 1329 | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", 1330 | "license": "ISC" 1331 | }, 1332 | "node_modules/ws": { 1333 | "version": "8.18.1", 1334 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz", 1335 | "integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==", 1336 | "license": "MIT", 1337 | "engines": { 1338 | "node": ">=10.0.0" 1339 | }, 1340 | "peerDependencies": { 1341 | "bufferutil": "^4.0.1", 1342 | "utf-8-validate": ">=5.0.2" 1343 | }, 1344 | "peerDependenciesMeta": { 1345 | "bufferutil": { 1346 | "optional": true 1347 | }, 1348 | "utf-8-validate": { 1349 | "optional": true 1350 | } 1351 | } 1352 | }, 1353 | "node_modules/zod": { 1354 | "version": "3.24.2", 1355 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", 1356 | "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", 1357 | "license": "MIT", 1358 | "funding": { 1359 | "url": "https://github.com/sponsors/colinhacks" 1360 | } 1361 | }, 1362 | "node_modules/zod-to-json-schema": { 1363 | "version": "3.24.5", 1364 | "resolved": "https://registry.npmjs.org/zod-to-json-schema/-/zod-to-json-schema-3.24.5.tgz", 1365 | "integrity": "sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g==", 1366 | "license": "ISC", 1367 | "peerDependencies": { 1368 | "zod": "^3.24.1" 1369 | } 1370 | } 1371 | } 1372 | } 1373 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mcp-figma-to-react", 3 | "version": "1.0.0", 4 | "description": "MCP server for converting Figma designs to React components", 5 | "main": "dist/index.js", 6 | "type": "module", 7 | "scripts": { 8 | "build": "tsc", 9 | "start": "node dist/index.js", 10 | "dev": "tsc -w & node --watch dist/index.js", 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "keywords": [ 14 | "figma", 15 | "react", 16 | "mcp", 17 | "component-generator" 18 | ], 19 | "author": "", 20 | "license": "ISC", 21 | "dependencies": { 22 | "@modelcontextprotocol/sdk": "1.10.2", 23 | "axios": "^1.8.4", 24 | "express": "5.1.0", 25 | "prettier": "^3.5.3", 26 | "typescript": "5.8.3", 27 | "ws": "^8.18.1", 28 | "zod": "3.24.3" 29 | }, 30 | "devDependencies": { 31 | "@types/express": "^5.0.1", 32 | "@types/node": "22.14.1", 33 | "@types/ws": "8.18.1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/accessibility.ts: -------------------------------------------------------------------------------- 1 | import { FigmaNode } from './figma-client.js'; 2 | 3 | // Determine the likely heading level based on font size and other properties 4 | function determineLikelyHeadingLevel(figmaNode: any): number { 5 | if (!figmaNode.style) return 2; // Default to h2 if no style information 6 | 7 | const { fontSize, fontWeight } = figmaNode.style; 8 | 9 | // Use font size as the primary indicator 10 | if (fontSize >= 32) return 1; 11 | if (fontSize >= 24) return 2; 12 | if (fontSize >= 20) return 3; 13 | if (fontSize >= 18) return 4; 14 | if (fontSize >= 16) return 5; 15 | return 6; 16 | } 17 | 18 | // Check if a node is likely a button based on its properties 19 | function isLikelyButton(figmaNode: FigmaNode): boolean { 20 | // Check name for button-related keywords 21 | const nameLower = figmaNode.name.toLowerCase(); 22 | if (nameLower.includes('button') || nameLower.includes('btn')) return true; 23 | 24 | // Check for common button styles 25 | if (figmaNode.cornerRadius && figmaNode.cornerRadius > 0) { 26 | // Buttons often have rounded corners 27 | if (figmaNode.fills && figmaNode.fills.length > 0) { 28 | // Buttons typically have a background fill 29 | return true; 30 | } 31 | } 32 | 33 | return false; 34 | } 35 | 36 | // Check if a node is likely an image 37 | function isLikelyImage(figmaNode: FigmaNode): boolean { 38 | if (figmaNode.type === 'IMAGE') return true; 39 | 40 | const nameLower = figmaNode.name.toLowerCase(); 41 | if (nameLower.includes('image') || nameLower.includes('img') || nameLower.includes('icon')) return true; 42 | 43 | // Check for image fills 44 | if (figmaNode.fills) { 45 | for (const fill of figmaNode.fills) { 46 | if (fill.type === 'IMAGE') return true; 47 | } 48 | } 49 | 50 | return false; 51 | } 52 | 53 | // Check if a node is likely an input field 54 | function isLikelyInputField(figmaNode: FigmaNode): boolean { 55 | const nameLower = figmaNode.name.toLowerCase(); 56 | return nameLower.includes('input') || 57 | nameLower.includes('field') || 58 | nameLower.includes('text field') || 59 | nameLower.includes('form field'); 60 | } 61 | 62 | // Generate appropriate alt text for an image 63 | function generateAltText(figmaNode: FigmaNode): string { 64 | // Start with the node name 65 | let altText = figmaNode.name; 66 | 67 | // Remove common prefixes/suffixes that aren't useful in alt text 68 | altText = altText.replace(/^(img|image|icon|pic|picture)[-_\s]*/i, ''); 69 | altText = altText.replace(/[-_\s]*(img|image|icon|pic|picture)$/i, ''); 70 | 71 | // If the alt text is empty or just contains "image" or similar, use a more generic description 72 | if (!altText || /^(img|image|icon|pic|picture)$/i.test(altText)) { 73 | altText = 'Image'; 74 | } 75 | 76 | return altText; 77 | } 78 | 79 | export function enhanceWithAccessibility(jsx: string, figmaNode: FigmaNode): string { 80 | let enhancedJsx = jsx; 81 | 82 | // Add appropriate ARIA attributes based on component type 83 | if (figmaNode.type === 'TEXT' || (figmaNode.characters && figmaNode.characters.length > 0)) { 84 | // For text elements, check if they might be headings 85 | if (figmaNode.style && figmaNode.style.fontSize >= 16) { 86 | const headingLevel = determineLikelyHeadingLevel(figmaNode); 87 | enhancedJsx = enhancedJsx.replace(/]*)>(.*?)<\/div>/g, `$2`); 88 | } 89 | } 90 | 91 | // Add alt text to images 92 | if (isLikelyImage(figmaNode)) { 93 | const altText = generateAltText(figmaNode); 94 | if (enhancedJsx.includes(']*)>/g, ``); 96 | } else if (enhancedJsx.includes(']*)>/g, ``); 98 | } else { 99 | // If it's a div with a background image, add role="img" and aria-label 100 | enhancedJsx = enhancedJsx.replace( 101 | /]*)>/g, 102 | `` 103 | ); 104 | } 105 | } 106 | 107 | // Add appropriate role attributes for interactive elements 108 | if (isLikelyButton(figmaNode)) { 109 | if (!enhancedJsx.includes(']*)>/g, 112 | ' e.key === "Enter" && onClick && onClick(e)}>' 113 | ); 114 | 115 | // If there's an onClick handler, make sure it's keyboard accessible 116 | enhancedJsx = enhancedJsx.replace( 117 | /onClick={([^}]+)}/g, 118 | 'onClick={$1}' 119 | ); 120 | } 121 | } 122 | 123 | // Add label and appropriate attributes for input fields 124 | if (isLikelyInputField(figmaNode)) { 125 | const inputId = `input-${figmaNode.id.replace(/[^a-zA-Z0-9]/g, '-')}`; 126 | const labelText = figmaNode.name.replace(/input|field|text field|form field/gi, '').trim() || 'Input'; 127 | 128 | if (enhancedJsx.includes(']*)>/g, 131 | `` 132 | ); 133 | } else { 134 | // If it's a div that should be an input, transform it 135 | enhancedJsx = enhancedJsx.replace( 136 | /]*)>(.*?)<\/div>/g, 137 | `` 138 | ); 139 | } 140 | } 141 | 142 | return enhancedJsx; 143 | } -------------------------------------------------------------------------------- /src/component-generator.ts: -------------------------------------------------------------------------------- 1 | import * as prettier from 'prettier'; 2 | import { FigmaNode } from './figma-client.js'; 3 | import { convertFigmaStylesToTailwind } from './figma-tailwind-converter.js'; 4 | import { enhanceWithAccessibility } from './accessibility.js'; 5 | 6 | interface PropDefinition { 7 | name: string; 8 | type: string; 9 | defaultValue?: string; 10 | description?: string; 11 | } 12 | 13 | interface ReactComponentParts { 14 | jsx: string; 15 | imports: string[]; 16 | props: PropDefinition[]; 17 | styles?: Record; 18 | } 19 | 20 | // Helper function to convert Figma node name to a valid React component name 21 | function toComponentName(name: string): string { 22 | // Remove invalid characters and convert to PascalCase 23 | return name 24 | .replace(/[^\w\s-]/g, '') 25 | .split(/[-_\s]+/) 26 | .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) 27 | .join(''); 28 | } 29 | 30 | // Helper function to convert Figma node name to a valid prop name 31 | function toPropName(name: string): string { 32 | // Convert to camelCase 33 | const parts = name 34 | .replace(/[^\w\s-]/g, '') 35 | .split(/[-_\s]+/); 36 | 37 | return parts[0].toLowerCase() + 38 | parts.slice(1) 39 | .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) 40 | .join(''); 41 | } 42 | 43 | // Extract potential props from Figma node 44 | function extractProps(node: FigmaNode): PropDefinition[] { 45 | const props: PropDefinition[] = []; 46 | 47 | // Text content could be a prop 48 | if (node.type === 'TEXT' && node.characters) { 49 | const propName = toPropName(node.name) || 'text'; 50 | props.push({ 51 | name: propName, 52 | type: 'string', 53 | defaultValue: JSON.stringify(node.characters), 54 | description: `Text content for ${node.name}` 55 | }); 56 | } 57 | 58 | // If node has a "variant" property, it could be a prop 59 | if (node.name.toLowerCase().includes('variant')) { 60 | props.push({ 61 | name: 'variant', 62 | type: "'primary' | 'secondary' | 'outline' | 'text'", 63 | defaultValue: "'primary'", 64 | description: 'Visual variant of the component' 65 | }); 66 | } 67 | 68 | // If node looks like a button, add onClick prop 69 | if (node.name.toLowerCase().includes('button') || node.name.toLowerCase().includes('btn')) { 70 | props.push({ 71 | name: 'onClick', 72 | type: '() => void', 73 | description: 'Function called when button is clicked' 74 | }); 75 | } 76 | 77 | // If node has children that could be dynamic, add children prop 78 | if (node.children && node.children.length > 0) { 79 | // Check if it has a container-like name 80 | if ( 81 | node.name.toLowerCase().includes('container') || 82 | node.name.toLowerCase().includes('wrapper') || 83 | node.name.toLowerCase().includes('layout') || 84 | node.name.toLowerCase().includes('section') 85 | ) { 86 | props.push({ 87 | name: 'children', 88 | type: 'React.ReactNode', 89 | description: 'Child elements to render inside the component' 90 | }); 91 | } 92 | } 93 | 94 | // Add className prop for styling customization 95 | props.push({ 96 | name: 'className', 97 | type: 'string', 98 | description: 'Additional CSS classes to apply' 99 | }); 100 | 101 | return props; 102 | } 103 | 104 | // Convert a Figma node to JSX 105 | function figmaNodeToJSX(node: FigmaNode, level = 0): ReactComponentParts { 106 | const imports: string[] = []; 107 | const allProps: PropDefinition[] = []; 108 | 109 | // Default result 110 | let result: ReactComponentParts = { 111 | jsx: '', 112 | imports: [], 113 | props: [] 114 | }; 115 | 116 | // Handle different node types 117 | switch (node.type) { 118 | case 'TEXT': 119 | // Extract text content and convert to JSX 120 | const textContent = node.characters || ''; 121 | const tailwindClasses = convertFigmaStylesToTailwind(node); 122 | const textProps = extractProps(node); 123 | 124 | result = { 125 | jsx: `

{${textProps[0]?.name || 'text'}}

`, 126 | imports: [], 127 | props: textProps 128 | }; 129 | break; 130 | 131 | case 'RECTANGLE': 132 | case 'ELLIPSE': 133 | case 'POLYGON': 134 | case 'STAR': 135 | case 'VECTOR': 136 | case 'LINE': 137 | // Convert to a div with appropriate styling 138 | const shapeClasses = convertFigmaStylesToTailwind(node); 139 | 140 | result = { 141 | jsx: `
`, 142 | imports: [], 143 | props: [] 144 | }; 145 | break; 146 | 147 | case 'COMPONENT': 148 | case 'INSTANCE': 149 | case 'FRAME': 150 | case 'GROUP': 151 | // These are container elements that might have children 152 | const containerClasses = convertFigmaStylesToTailwind(node); 153 | const containerProps = extractProps(node); 154 | 155 | // Process children if they exist 156 | let childrenJSX = ''; 157 | if (node.children && node.children.length > 0) { 158 | for (const child of node.children) { 159 | const childResult = figmaNodeToJSX(child, level + 1); 160 | childrenJSX += `\n${' '.repeat(level + 1)}${childResult.jsx}`; 161 | 162 | // Collect imports and props from children 163 | imports.push(...childResult.imports); 164 | allProps.push(...childResult.props); 165 | } 166 | childrenJSX += `\n${' '.repeat(level)}`; 167 | } 168 | 169 | // If this is a component that looks like a button 170 | if (node.name.toLowerCase().includes('button') || node.name.toLowerCase().includes('btn')) { 171 | result = { 172 | jsx: ``, 176 | imports: imports, 177 | props: [...containerProps, ...allProps] 178 | }; 179 | } else { 180 | // Check if we should use children prop 181 | const hasChildrenProp = containerProps.some(p => p.name === 'children'); 182 | 183 | result = { 184 | jsx: `
${hasChildrenProp ? '{children}' : childrenJSX}
`, 187 | imports: imports, 188 | props: [...containerProps, ...(hasChildrenProp ? [] : allProps)] 189 | }; 190 | } 191 | break; 192 | 193 | case 'IMAGE': 194 | // Convert to an img tag 195 | const imageClasses = convertFigmaStylesToTailwind(node); 196 | 197 | result = { 198 | jsx: `${node.name}`, 203 | imports: [], 204 | props: [{ 205 | name: 'src', 206 | type: 'string', 207 | description: 'Image source URL' 208 | }] 209 | }; 210 | break; 211 | 212 | default: 213 | // Default to a simple div 214 | result = { 215 | jsx: `
`, 216 | imports: [], 217 | props: [] 218 | }; 219 | } 220 | 221 | return result; 222 | } 223 | 224 | export class ComponentGenerator { 225 | async generateReactComponent(componentName: string, figmaNode: FigmaNode): Promise { 226 | // Extract styles, structure, and props from Figma node 227 | const componentParts = figmaNodeToJSX(figmaNode); 228 | 229 | // Enhance with accessibility features 230 | const enhancedJSX = enhanceWithAccessibility(componentParts.jsx, figmaNode); 231 | 232 | // Deduplicate props 233 | const uniqueProps = componentParts.props.filter((prop, index, self) => 234 | index === self.findIndex(p => p.name === prop.name) 235 | ); 236 | 237 | // Create component template 238 | const componentCode = ` 239 | import React from 'react'; 240 | ${componentParts.imports.join('\n')} 241 | 242 | interface ${componentName}Props { 243 | ${uniqueProps.map(prop => 244 | `/** ${prop.description || ''} */ 245 | ${prop.name}${prop.type.includes('?') || prop.defaultValue ? '?' : ''}: ${prop.type};` 246 | ).join('\n ')} 247 | } 248 | 249 | export const ${componentName} = ({ 250 | ${uniqueProps.map(p => 251 | p.defaultValue 252 | ? `${p.name} = ${p.defaultValue}` 253 | : p.name 254 | ).join(', ')} 255 | }: ${componentName}Props) => { 256 | return ( 257 | ${enhancedJSX} 258 | ); 259 | }; 260 | `; 261 | 262 | // Format the code 263 | try { 264 | return await prettier.format(componentCode, { 265 | parser: 'typescript', 266 | singleQuote: true, 267 | trailingComma: 'es5', 268 | tabWidth: 2 269 | }); 270 | } catch (error) { 271 | console.error('Error formatting component code:', error); 272 | return componentCode; 273 | } 274 | } 275 | 276 | async generateComponentLibrary(components: Array<{ name: string, node: FigmaNode }>): Promise> { 277 | const generatedComponents: Record = {}; 278 | 279 | for (const { name, node } of components) { 280 | const componentName = toComponentName(name); 281 | generatedComponents[componentName] = await this.generateReactComponent(componentName, node); 282 | } 283 | 284 | return generatedComponents; 285 | } 286 | } -------------------------------------------------------------------------------- /src/figma-client.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | // Define types for Figma API responses 4 | export interface FigmaNode { 5 | id: string; 6 | name: string; 7 | type: string; 8 | [key: string]: any; 9 | } 10 | 11 | export interface GetFileResponse { 12 | document: { 13 | children: FigmaNode[]; 14 | [key: string]: any; 15 | }; 16 | components: Record; 17 | styles: Record; 18 | [key: string]: any; 19 | } 20 | 21 | export interface GetFileNodesResponse { 22 | nodes: Record; 25 | styles?: Record; 26 | [key: string]: any; 27 | }>; 28 | } 29 | 30 | export class FigmaClient { 31 | private token: string; 32 | private baseUrl = 'https://api.figma.com/v1'; 33 | 34 | constructor(token: string) { 35 | this.token = token; 36 | } 37 | 38 | async getFile(fileKey: string): Promise { 39 | try { 40 | const response = await axios.get( 41 | `${this.baseUrl}/files/${fileKey}`, 42 | { 43 | headers: { 44 | 'X-Figma-Token': this.token 45 | } 46 | } 47 | ); 48 | return response.data; 49 | } catch (error) { 50 | if (axios.isAxiosError(error)) { 51 | throw new Error(`Figma API error: ${error.response?.data?.message || error.message}`); 52 | } 53 | throw error; 54 | } 55 | } 56 | 57 | async getFileNodes(fileKey: string, nodeIds: string[]): Promise { 58 | try { 59 | const response = await axios.get( 60 | `${this.baseUrl}/files/${fileKey}/nodes`, 61 | { 62 | params: { ids: nodeIds.join(',') }, 63 | headers: { 64 | 'X-Figma-Token': this.token 65 | } 66 | } 67 | ); 68 | return response.data; 69 | } catch (error) { 70 | if (axios.isAxiosError(error)) { 71 | throw new Error(`Figma API error: ${error.response?.data?.message || error.message}`); 72 | } 73 | throw error; 74 | } 75 | } 76 | 77 | async getImageFills(fileKey: string, nodeIds: string[]): Promise> { 78 | try { 79 | const response = await axios.get( 80 | `${this.baseUrl}/images/${fileKey}`, 81 | { 82 | params: { ids: nodeIds.join(','), format: 'png' }, 83 | headers: { 84 | 'X-Figma-Token': this.token 85 | } 86 | } 87 | ); 88 | return response.data.images || {}; 89 | } catch (error) { 90 | if (axios.isAxiosError(error)) { 91 | throw new Error(`Figma API error: ${error.response?.data?.message || error.message}`); 92 | } 93 | throw error; 94 | } 95 | } 96 | 97 | async getComponentSets(fileKey: string): Promise { 98 | try { 99 | const response = await axios.get( 100 | `${this.baseUrl}/files/${fileKey}/component_sets`, 101 | { 102 | headers: { 103 | 'X-Figma-Token': this.token 104 | } 105 | } 106 | ); 107 | return response.data; 108 | } catch (error) { 109 | if (axios.isAxiosError(error)) { 110 | throw new Error(`Figma API error: ${error.response?.data?.message || error.message}`); 111 | } 112 | throw error; 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /src/figma-react-tools.ts: -------------------------------------------------------------------------------- 1 | import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; 2 | import { z } from 'zod'; 3 | import { ComponentGenerator } from './component-generator.js'; 4 | import { FigmaClient, FigmaNode } from './figma-client.js'; 5 | import * as fs from 'fs/promises'; 6 | import * as path from 'path'; 7 | 8 | export function registerReactTools(server: McpServer, componentGenerator: ComponentGenerator, figmaClient: FigmaClient): void { 9 | // Register generateReactComponent tool 10 | server.tool( 11 | 'generateReactComponent', 12 | { 13 | componentName: z.string().describe('Name for the React component'), 14 | figmaNodeId: z.string().describe('Figma node ID'), 15 | fileKey: z.string().describe('Figma file key') 16 | }, 17 | async ({ componentName, figmaNodeId, fileKey }) => { 18 | try { 19 | // Get the Figma node data 20 | const nodeData = await figmaClient.getFileNodes(fileKey, [figmaNodeId]); 21 | const figmaNode = nodeData.nodes[figmaNodeId]?.document; 22 | 23 | if (!figmaNode) { 24 | return { 25 | isError: true, 26 | content: [ 27 | { 28 | type: 'text', 29 | text: `Figma node with ID ${figmaNodeId} not found` 30 | } 31 | ] 32 | }; 33 | } 34 | 35 | // Generate the React component 36 | const componentCode = await componentGenerator.generateReactComponent(componentName, figmaNode); 37 | 38 | return { 39 | content: [ 40 | { 41 | type: 'text', 42 | text: componentCode 43 | } 44 | ] 45 | }; 46 | } catch (error) { 47 | return { 48 | isError: true, 49 | content: [ 50 | { 51 | type: 'text', 52 | text: `Failed to generate React component: ${error instanceof Error ? error.message : String(error)}` 53 | } 54 | ] 55 | }; 56 | } 57 | } 58 | ); 59 | 60 | // Register generateComponentLibrary tool 61 | server.tool( 62 | 'generateComponentLibrary', 63 | { 64 | components: z.array( 65 | z.object({ 66 | name: z.string(), 67 | nodeId: z.string() 68 | }) 69 | ).describe('Components to generate'), 70 | fileKey: z.string().describe('Figma file key') 71 | }, 72 | async ({ components, fileKey }) => { 73 | try { 74 | // Get all node IDs 75 | const nodeIds = components.map(comp => comp.nodeId); 76 | 77 | // Get the Figma node data for all components 78 | const nodesData = await figmaClient.getFileNodes(fileKey, nodeIds); 79 | 80 | // Prepare the components for generation 81 | const componentsForGeneration = components 82 | .filter(comp => nodesData.nodes[comp.nodeId]?.document) 83 | .map(comp => ({ 84 | name: comp.name, 85 | node: nodesData.nodes[comp.nodeId].document 86 | })); 87 | 88 | // Generate the component library 89 | const generatedComponents = await componentGenerator.generateComponentLibrary(componentsForGeneration); 90 | 91 | return { 92 | content: [ 93 | { 94 | type: 'text', 95 | text: JSON.stringify( 96 | Object.entries(generatedComponents).map(([name, code]) => ({ 97 | name, 98 | code 99 | })), 100 | null, 101 | 2 102 | ) 103 | } 104 | ] 105 | }; 106 | } catch (error) { 107 | return { 108 | isError: true, 109 | content: [ 110 | { 111 | type: 'text', 112 | text: `Failed to generate component library: ${error instanceof Error ? error.message : String(error)}` 113 | } 114 | ] 115 | }; 116 | } 117 | } 118 | ); 119 | 120 | // Register writeComponentsToFiles tool 121 | server.tool( 122 | 'writeComponentsToFiles', 123 | { 124 | components: z.array( 125 | z.object({ 126 | name: z.string(), 127 | code: z.string() 128 | }) 129 | ).describe('Components to write to files'), 130 | outputDir: z.string().describe('Output directory') 131 | }, 132 | async ({ components, outputDir }) => { 133 | try { 134 | // Create the output directory if it doesn't exist 135 | await fs.mkdir(outputDir, { recursive: true }); 136 | 137 | // Write each component to a file 138 | const results = await Promise.all( 139 | components.map(async (component) => { 140 | const fileName = `${component.name}.tsx`; 141 | const filePath = path.join(outputDir, fileName); 142 | 143 | await fs.writeFile(filePath, component.code, 'utf-8'); 144 | 145 | return { 146 | name: component.name, 147 | path: filePath 148 | }; 149 | }) 150 | ); 151 | 152 | return { 153 | content: [ 154 | { 155 | type: 'text', 156 | text: JSON.stringify({ results }, null, 2) 157 | } 158 | ] 159 | }; 160 | } catch (error) { 161 | return { 162 | isError: true, 163 | content: [ 164 | { 165 | type: 'text', 166 | text: `Failed to write components to files: ${error instanceof Error ? error.message : String(error)}` 167 | } 168 | ] 169 | }; 170 | } 171 | } 172 | ); 173 | 174 | // Register figmaToReactWorkflow tool 175 | server.tool( 176 | 'figmaToReactWorkflow', 177 | { 178 | fileKey: z.string().describe('Figma file key'), 179 | outputDir: z.string().describe('Output directory for components') 180 | }, 181 | async ({ fileKey, outputDir }) => { 182 | try { 183 | // Step 1: Extract components from Figma file 184 | const fileData = await figmaClient.getFile(fileKey); 185 | 186 | // Find all components in the file 187 | const components: Array<{ id: string, name: string, type: string }> = []; 188 | 189 | // Helper function to recursively traverse the document 190 | function findComponents(node: any) { 191 | if (node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') { 192 | components.push({ 193 | id: node.id, 194 | name: node.name, 195 | type: node.type 196 | }); 197 | } 198 | 199 | if (node.children) { 200 | for (const child of node.children) { 201 | findComponents(child); 202 | } 203 | } 204 | } 205 | 206 | // Start traversal from the document root 207 | findComponents(fileData.document); 208 | 209 | // Step 2: Get the Figma node data for all components 210 | const nodeIds = components.map(comp => comp.id); 211 | const nodesData = await figmaClient.getFileNodes(fileKey, nodeIds); 212 | 213 | // Step 3: Prepare the components for generation 214 | const componentsForGeneration = components 215 | .filter(comp => nodesData.nodes[comp.id]?.document) 216 | .map(comp => ({ 217 | name: comp.name, 218 | node: nodesData.nodes[comp.id].document 219 | })); 220 | 221 | // Step 4: Generate the component library 222 | const generatedComponents = await componentGenerator.generateComponentLibrary(componentsForGeneration); 223 | 224 | // Step 5: Create the output directory if it doesn't exist 225 | await fs.mkdir(outputDir, { recursive: true }); 226 | 227 | // Step 6: Write each component to a file 228 | const results = await Promise.all( 229 | Object.entries(generatedComponents).map(async ([name, code]) => { 230 | const fileName = `${name}.tsx`; 231 | const filePath = path.join(outputDir, fileName); 232 | 233 | await fs.writeFile(filePath, code, 'utf-8'); 234 | 235 | return { 236 | name, 237 | path: filePath 238 | }; 239 | }) 240 | ); 241 | 242 | return { 243 | content: [ 244 | { 245 | type: 'text', 246 | text: JSON.stringify({ 247 | componentsFound: components.length, 248 | componentsGenerated: results.length, 249 | results 250 | }, null, 2) 251 | } 252 | ] 253 | }; 254 | } catch (error) { 255 | return { 256 | isError: true, 257 | content: [ 258 | { 259 | type: 'text', 260 | text: `Failed to execute Figma to React workflow: ${error instanceof Error ? error.message : String(error)}` 261 | } 262 | ] 263 | }; 264 | } 265 | } 266 | ); 267 | } -------------------------------------------------------------------------------- /src/figma-tailwind-converter.ts: -------------------------------------------------------------------------------- 1 | // Helper functions for color conversion 2 | function rgbToHex(r: number, g: number, b: number): string { 3 | return '#' + [r, g, b] 4 | .map(x => Math.round(x).toString(16).padStart(2, '0')) 5 | .join(''); 6 | } 7 | 8 | // Map RGB color to closest Tailwind color 9 | function mapToTailwindColor(hexColor: string): string { 10 | // This is a simplified implementation 11 | // In a real-world scenario, you would have a more comprehensive mapping 12 | const tailwindColors: Record = { 13 | '#000000': 'text-black', 14 | '#ffffff': 'text-white', 15 | '#ef4444': 'text-red-500', 16 | '#3b82f6': 'text-blue-500', 17 | '#10b981': 'text-green-500', 18 | '#f59e0b': 'text-yellow-500', 19 | '#6366f1': 'text-indigo-500', 20 | '#8b5cf6': 'text-purple-500', 21 | '#ec4899': 'text-pink-500', 22 | '#6b7280': 'text-gray-500', 23 | // Add more color mappings as needed 24 | }; 25 | 26 | // Find the closest color by calculating the distance in RGB space 27 | let minDistance = Number.MAX_VALUE; 28 | let closestColor = 'text-black'; 29 | 30 | const r1 = parseInt(hexColor.slice(1, 3), 16); 31 | const g1 = parseInt(hexColor.slice(3, 5), 16); 32 | const b1 = parseInt(hexColor.slice(5, 7), 16); 33 | 34 | for (const [color, className] of Object.entries(tailwindColors)) { 35 | const r2 = parseInt(color.slice(1, 3), 16); 36 | const g2 = parseInt(color.slice(3, 5), 16); 37 | const b2 = parseInt(color.slice(5, 7), 16); 38 | 39 | const distance = Math.sqrt( 40 | Math.pow(r1 - r2, 2) + Math.pow(g1 - g2, 2) + Math.pow(b1 - b2, 2) 41 | ); 42 | 43 | if (distance < minDistance) { 44 | minDistance = distance; 45 | closestColor = className; 46 | } 47 | } 48 | 49 | return closestColor; 50 | } 51 | 52 | // Map font size to Tailwind class 53 | function mapFontSizeToTailwind(fontSize: number): string { 54 | if (fontSize <= 12) return 'text-xs'; 55 | if (fontSize <= 14) return 'text-sm'; 56 | if (fontSize <= 16) return 'text-base'; 57 | if (fontSize <= 18) return 'text-lg'; 58 | if (fontSize <= 20) return 'text-xl'; 59 | if (fontSize <= 24) return 'text-2xl'; 60 | if (fontSize <= 30) return 'text-3xl'; 61 | if (fontSize <= 36) return 'text-4xl'; 62 | if (fontSize <= 48) return 'text-5xl'; 63 | return 'text-6xl'; 64 | } 65 | 66 | // Map font weight to Tailwind class 67 | function mapFontWeightToTailwind(fontWeight: number): string { 68 | if (fontWeight < 400) return 'font-light'; 69 | if (fontWeight < 500) return 'font-normal'; 70 | if (fontWeight < 600) return 'font-medium'; 71 | if (fontWeight < 700) return 'font-semibold'; 72 | return 'font-bold'; 73 | } 74 | 75 | // Map size values to Tailwind size classes 76 | function mapToTailwindSize(size: number): string { 77 | // This is a simplified implementation 78 | if (size <= 4) return '1'; 79 | if (size <= 8) return '2'; 80 | if (size <= 12) return '3'; 81 | if (size <= 16) return '4'; 82 | if (size <= 20) return '5'; 83 | if (size <= 24) return '6'; 84 | if (size <= 32) return '8'; 85 | if (size <= 40) return '10'; 86 | if (size <= 48) return '12'; 87 | if (size <= 64) return '16'; 88 | if (size <= 80) return '20'; 89 | if (size <= 96) return '24'; 90 | if (size <= 128) return '32'; 91 | if (size <= 160) return '40'; 92 | if (size <= 192) return '48'; 93 | if (size <= 256) return '64'; 94 | if (size <= 320) return '80'; 95 | if (size <= 384) return '96'; 96 | return 'full'; 97 | } 98 | 99 | export function convertFigmaStylesToTailwind(figmaStyles: any): string[] { 100 | const tailwindClasses: string[] = []; 101 | 102 | // Convert colors 103 | if (figmaStyles.fills && figmaStyles.fills.length > 0) { 104 | const fill = figmaStyles.fills[0]; 105 | if (fill && fill.type === 'SOLID') { 106 | const { r, g, b } = fill.color; 107 | // Convert RGB to hex and find closest Tailwind color 108 | const hexColor = rgbToHex(r * 255, g * 255, b * 255); 109 | const tailwindColor = mapToTailwindColor(hexColor); 110 | tailwindClasses.push(tailwindColor); 111 | 112 | // Add opacity if needed 113 | if (fill.opacity && fill.opacity < 1) { 114 | const opacityValue = Math.round(fill.opacity * 100); 115 | tailwindClasses.push(`opacity-${opacityValue}`); 116 | } 117 | } 118 | } 119 | 120 | // Convert typography 121 | if (figmaStyles.style) { 122 | const { fontSize, fontWeight, lineHeight, letterSpacing } = figmaStyles.style; 123 | 124 | // Map font size to Tailwind classes 125 | if (fontSize) { 126 | tailwindClasses.push(mapFontSizeToTailwind(fontSize)); 127 | } 128 | 129 | // Map font weight 130 | if (fontWeight) { 131 | tailwindClasses.push(mapFontWeightToTailwind(fontWeight)); 132 | } 133 | 134 | // Map line height 135 | if (lineHeight) { 136 | // Simplified mapping 137 | if (lineHeight <= 1) tailwindClasses.push('leading-none'); 138 | else if (lineHeight <= 1.25) tailwindClasses.push('leading-tight'); 139 | else if (lineHeight <= 1.5) tailwindClasses.push('leading-normal'); 140 | else if (lineHeight <= 1.75) tailwindClasses.push('leading-relaxed'); 141 | else tailwindClasses.push('leading-loose'); 142 | } 143 | 144 | // Map letter spacing 145 | if (letterSpacing) { 146 | // Simplified mapping 147 | if (letterSpacing <= -0.05) tailwindClasses.push('tracking-tighter'); 148 | else if (letterSpacing <= 0) tailwindClasses.push('tracking-tight'); 149 | else if (letterSpacing <= 0.05) tailwindClasses.push('tracking-normal'); 150 | else if (letterSpacing <= 0.1) tailwindClasses.push('tracking-wide'); 151 | else tailwindClasses.push('tracking-wider'); 152 | } 153 | } 154 | 155 | // Convert layout properties 156 | if (figmaStyles.absoluteBoundingBox) { 157 | const { width, height } = figmaStyles.absoluteBoundingBox; 158 | tailwindClasses.push(`w-${mapToTailwindSize(width)}`); 159 | tailwindClasses.push(`h-${mapToTailwindSize(height)}`); 160 | } 161 | 162 | // Convert border radius 163 | if (figmaStyles.cornerRadius) { 164 | if (figmaStyles.cornerRadius <= 2) tailwindClasses.push('rounded-sm'); 165 | else if (figmaStyles.cornerRadius <= 4) tailwindClasses.push('rounded'); 166 | else if (figmaStyles.cornerRadius <= 6) tailwindClasses.push('rounded-md'); 167 | else if (figmaStyles.cornerRadius <= 8) tailwindClasses.push('rounded-lg'); 168 | else if (figmaStyles.cornerRadius <= 12) tailwindClasses.push('rounded-xl'); 169 | else if (figmaStyles.cornerRadius <= 16) tailwindClasses.push('rounded-2xl'); 170 | else if (figmaStyles.cornerRadius <= 24) tailwindClasses.push('rounded-3xl'); 171 | else tailwindClasses.push('rounded-full'); 172 | } 173 | 174 | // Convert borders 175 | if (figmaStyles.strokes && figmaStyles.strokes.length > 0) { 176 | const stroke = figmaStyles.strokes[0]; 177 | if (stroke && stroke.type === 'SOLID') { 178 | const { r, g, b } = stroke.color; 179 | const hexColor = rgbToHex(r * 255, g * 255, b * 255); 180 | const tailwindColor = mapToTailwindColor(hexColor).replace('text-', 'border-'); 181 | tailwindClasses.push(tailwindColor); 182 | 183 | // Border width 184 | if (figmaStyles.strokeWeight) { 185 | if (figmaStyles.strokeWeight <= 1) tailwindClasses.push('border'); 186 | else if (figmaStyles.strokeWeight <= 2) tailwindClasses.push('border-2'); 187 | else if (figmaStyles.strokeWeight <= 4) tailwindClasses.push('border-4'); 188 | else tailwindClasses.push('border-8'); 189 | } 190 | } 191 | } 192 | 193 | // Convert shadows 194 | if (figmaStyles.effects) { 195 | const shadowEffect = figmaStyles.effects.find((effect: any) => effect.type === 'DROP_SHADOW'); 196 | if (shadowEffect) { 197 | if (shadowEffect.offset.x === 0 && shadowEffect.offset.y === 1 && shadowEffect.radius <= 2) { 198 | tailwindClasses.push('shadow-sm'); 199 | } else if (shadowEffect.offset.y <= 3 && shadowEffect.radius <= 4) { 200 | tailwindClasses.push('shadow'); 201 | } else if (shadowEffect.offset.y <= 8 && shadowEffect.radius <= 10) { 202 | tailwindClasses.push('shadow-md'); 203 | } else if (shadowEffect.offset.y <= 15 && shadowEffect.radius <= 15) { 204 | tailwindClasses.push('shadow-lg'); 205 | } else { 206 | tailwindClasses.push('shadow-xl'); 207 | } 208 | } 209 | } 210 | 211 | return tailwindClasses; 212 | } -------------------------------------------------------------------------------- /src/figma-tools.ts: -------------------------------------------------------------------------------- 1 | import { FigmaClient } from './figma-client.js'; 2 | import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; 3 | import { z } from 'zod'; 4 | 5 | export function registerFigmaTools(server: McpServer, figmaClient: FigmaClient): void { 6 | // Register getFigmaProject tool 7 | server.tool( 8 | 'getFigmaProject', 9 | { 10 | fileKey: z.string().describe('Figma file key') 11 | }, 12 | async ({ fileKey }) => { 13 | try { 14 | const fileData = await figmaClient.getFile(fileKey); 15 | return { 16 | content: [ 17 | { 18 | type: 'text', 19 | text: JSON.stringify({ 20 | name: fileData.name, 21 | documentId: fileData.document.id, 22 | lastModified: fileData.lastModified, 23 | version: fileData.version, 24 | componentCount: Object.keys(fileData.components || {}).length, 25 | styleCount: Object.keys(fileData.styles || {}).length 26 | }, null, 2) 27 | } 28 | ] 29 | }; 30 | } catch (error) { 31 | return { 32 | isError: true, 33 | content: [ 34 | { 35 | type: 'text', 36 | text: `Failed to get Figma project: ${error instanceof Error ? error.message : String(error)}` 37 | } 38 | ] 39 | }; 40 | } 41 | } 42 | ); 43 | 44 | // Register getFigmaComponentNodes tool 45 | server.tool( 46 | 'getFigmaComponentNodes', 47 | { 48 | fileKey: z.string().describe('Figma file key'), 49 | nodeIds: z.array(z.string()).describe('Node IDs to fetch') 50 | }, 51 | async ({ fileKey, nodeIds }) => { 52 | try { 53 | const nodesData = await figmaClient.getFileNodes(fileKey, nodeIds); 54 | return { 55 | content: [ 56 | { 57 | type: 'text', 58 | text: JSON.stringify(nodesData.nodes, null, 2) 59 | } 60 | ] 61 | }; 62 | } catch (error) { 63 | return { 64 | isError: true, 65 | content: [ 66 | { 67 | type: 'text', 68 | text: `Failed to get Figma component nodes: ${error instanceof Error ? error.message : String(error)}` 69 | } 70 | ] 71 | }; 72 | } 73 | } 74 | ); 75 | 76 | // Register extractFigmaComponents tool 77 | server.tool( 78 | 'extractFigmaComponents', 79 | { 80 | fileKey: z.string().describe('Figma file key') 81 | }, 82 | async ({ fileKey }) => { 83 | try { 84 | const fileData = await figmaClient.getFile(fileKey); 85 | 86 | // Find all components in the file 87 | const components: Array<{ id: string, name: string, type: string }> = []; 88 | 89 | // Helper function to recursively traverse the document 90 | function findComponents(node: any) { 91 | if (node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') { 92 | components.push({ 93 | id: node.id, 94 | name: node.name, 95 | type: node.type 96 | }); 97 | } 98 | 99 | if (node.children) { 100 | for (const child of node.children) { 101 | findComponents(child); 102 | } 103 | } 104 | } 105 | 106 | // Start traversal from the document root 107 | findComponents(fileData.document); 108 | 109 | return { 110 | content: [ 111 | { 112 | type: 'text', 113 | text: JSON.stringify({ components }, null, 2) 114 | } 115 | ] 116 | }; 117 | } catch (error) { 118 | return { 119 | isError: true, 120 | content: [ 121 | { 122 | type: 'text', 123 | text: `Failed to extract Figma components: ${error instanceof Error ? error.message : String(error)}` 124 | } 125 | ] 126 | }; 127 | } 128 | } 129 | ); 130 | 131 | // Register getFigmaComponentSets tool 132 | server.tool( 133 | 'getFigmaComponentSets', 134 | { 135 | fileKey: z.string().describe('Figma file key') 136 | }, 137 | async ({ fileKey }) => { 138 | try { 139 | const componentSets = await figmaClient.getComponentSets(fileKey); 140 | return { 141 | content: [ 142 | { 143 | type: 'text', 144 | text: JSON.stringify(componentSets, null, 2) 145 | } 146 | ] 147 | }; 148 | } catch (error) { 149 | return { 150 | isError: true, 151 | content: [ 152 | { 153 | type: 'text', 154 | text: `Failed to get Figma component sets: ${error instanceof Error ? error.message : String(error)}` 155 | } 156 | ] 157 | }; 158 | } 159 | } 160 | ); 161 | } -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; 3 | import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; 4 | import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js'; 5 | import express from 'express'; 6 | import { FigmaClient } from './figma-client.js'; 7 | import { registerFigmaTools } from './figma-tools.js'; 8 | import { ComponentGenerator } from './component-generator.js'; 9 | import { registerReactTools } from './figma-react-tools.js'; 10 | 11 | // Get Figma API token from environment variable 12 | const FIGMA_API_TOKEN = process.env.FIGMA_API_TOKEN; 13 | if (!FIGMA_API_TOKEN) { 14 | console.error('FIGMA_API_TOKEN environment variable is required'); 15 | process.exit(1); 16 | } 17 | 18 | // Create the MCP server 19 | const server = new McpServer({ 20 | name: 'Figma to React Converter', 21 | version: '1.0.0', 22 | description: 'MCP server for converting Figma designs to React components' 23 | }); 24 | 25 | // Initialize Figma client and component generator 26 | const figmaClient = new FigmaClient(FIGMA_API_TOKEN); 27 | const componentGenerator = new ComponentGenerator(); 28 | 29 | // Register tools with the server 30 | registerFigmaTools(server, figmaClient); 31 | registerReactTools(server, componentGenerator, figmaClient); 32 | 33 | // Determine the transport to use based on command-line arguments 34 | const transportArg = process.argv.find(arg => arg.startsWith('--transport=')); 35 | const transportType = transportArg ? transportArg.split('=')[1] : 'stdio'; 36 | 37 | async function main() { 38 | try { 39 | if (transportType === 'stdio') { 40 | // Use stdio transport for local MCP server 41 | const transport = new StdioServerTransport(); 42 | await server.connect(transport); 43 | console.error('Figma to React MCP server running on stdio'); 44 | } else if (transportType === 'sse') { 45 | // Set up Express server 46 | const app = express(); 47 | const port = process.env.PORT ? parseInt(process.env.PORT) : 3000; 48 | 49 | app.use(express.json()); 50 | 51 | // Health check endpoint 52 | app.get('/health', (_req, res) => { 53 | res.status(200).send('OK'); 54 | }); 55 | 56 | // SSE endpoint 57 | app.get('/sse', async (req: express.Request, res: express.Response) => { 58 | res.setHeader('Content-Type', 'text/event-stream'); 59 | res.setHeader('Cache-Control', 'no-cache'); 60 | res.setHeader('Connection', 'keep-alive'); 61 | 62 | const transport = new SSEServerTransport('/messages', res); 63 | await server.connect(transport); 64 | 65 | req.on('close', async () => { 66 | await server.close(); 67 | }); 68 | }); 69 | 70 | // Message endpoint 71 | app.post('/messages', express.json(), async (req: express.Request, res: express.Response) => { 72 | // This endpoint would be used by the client to send messages to the server 73 | res.status(200).json({ status: 'ok' }); 74 | }); 75 | 76 | // Start the Express server 77 | const httpServer = app.listen(port, () => { 78 | console.error(`Figma to React MCP server running on port ${port}`); 79 | }); 80 | 81 | // Handle server shutdown 82 | process.on('SIGINT', async () => { 83 | console.error('Shutting down server...'); 84 | await server.close(); 85 | httpServer.close(); 86 | process.exit(0); 87 | }); 88 | } else { 89 | console.error(`Unsupported transport type: ${transportType}`); 90 | process.exit(1); 91 | } 92 | } catch (error) { 93 | console.error('Error starting server:', error); 94 | process.exit(1); 95 | } 96 | } 97 | 98 | // Start the server 99 | main().catch(console.error); -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "NodeNext", 5 | "moduleResolution": "NodeNext", 6 | "esModuleInterop": true, 7 | "strict": true, 8 | "outDir": "dist", 9 | "sourceMap": true, 10 | "declaration": true, 11 | "resolveJsonModule": true, 12 | "skipLibCheck": true, 13 | "forceConsistentCasingInFileNames": true 14 | }, 15 | "include": ["src/**/*"], 16 | "exclude": ["node_modules", "dist"] 17 | } --------------------------------------------------------------------------------