## Figma-Framework MCP Since [Figma Context MCP](https://github.com/gLips/Figma-Context-MCP/) is framework‑agnostic, it does not output code or artifacts tailored to React, Angular, Vue, Flutter, etc. This repository adds a concrete implementation for Flutter (see `docs/figma-flutter-mcp.md`) and documents how to adapt the same architecture to any other framework. ### What you get out of the box - **Extractors (framework‑agnostic):** Parse Figma nodes into consistent, rich, typed models for components, screens, colors, and typography. - **Framework tools (Flutter today):** Wrap extractors, add framework‑specific heuristics, asset export, guidance, and code generation. - **CLI/MCP entry points:** Commands and tools to analyze Figma nodes and generate artifacts into a project. ## Architecture overview ### 1) Extractors (framework‑agnostic core) Extractors live under `src/extractors/` and work the same regardless of the target framework. They are responsible for traversing Figma nodes and producing structured analysis results that downstream tools can consume. - **Components:** `src/extractors/components/` - Entry points: `analyzeComponent`, `analyzeComponentWithVariants` - Outputs `ComponentAnalysis` with metadata, layout, styling, children, nested components, and variants when applicable. - **Screens:** `src/extractors/screens/` - Entry point: `analyzeScreen` - Outputs `ScreenAnalysis` with sections (header/content/footer/navigation), assets, and nested components. - **Colors:** `src/extractors/colors/` - Entry points: `extractThemeColors`, `extractColorsFromThemeFrame` - Outputs normalized theme color swatches. - **Typography:** `src/extractors/typography/` - Entry point: `extractThemeTypography` - Outputs normalized text styles with font family, size, weight, and line height. These modules use Figma API types (e.g., `FigmaNode`, `FigmaColor`, `FigmaEffect`) and heuristics (e.g., `node.type === 'TEXT' | 'FRAME' | 'COMPONENT'`) to create consistent data across frameworks. The output types are intentionally neutral so they can be mapped to any target tech stack. > ⚠️ You can add more in the list if the targeted framework needs it. ### 2) Framework tools (target‑specific glue) Tools live under `src/tools//` and are responsible for turning extractor outputs into actionable, framework‑specific results (code, guidance, assets, configuration). For Flutter these are under `src/tools/flutter/`. Tools typically do the following: - **Orchestrate extractors** (call `analyzeComponent`, `analyzeScreen`, etc.). - **Apply classification** (e.g., treat `COMPONENT`/`INSTANCE` as reusable widgets; treat `FRAME` as a screen). - **Map design semantics** to framework widgets/components (containers, text, icons, layout primitives). - **Generate code or guidance** (e.g., Flutter widget tree suggestions in `src/tools/flutter/components/helpers.mts`). - **Export assets** and update project manifests (images, SVGs, `pubspec.yaml` for Flutter). - **Integrate theming** by referencing color schemes and text themes rather than hardcoding styles when possible. In other words, extractors give you high‑quality design insights; tools translate those insights into framework‑specific outputs. ## 📝 Porting to a new framework (React, React Native, Angular, Vue) The fastest path is to keep the extractors intact and replace the Flutter‑specific tools with your framework’s equivalents. ### Folder layout - Create `src/tools/react/` (or `react-native`, `angular`, `vue`). - Add submodules as needed, mirroring the Flutter structure: - `components/` (analyze and generate component code) - `screens/` (analyze frames as screens/pages) - `assets/` (export images/SVGs and manage paths) - `theme/` (map colors/typography to your framework’s theming system) - `helpers.mts` (framework‑specific guidance and code snippets) ### Minimal tool set to implement - A tool to analyze a component or component set (wraps `analyzeComponent` and optionally variant handling). - A tool to analyze a full screen (wraps `analyzeScreen`). - Optional generators to emit framework code: - React: `.tsx` components in `src/components/`, pages in `src/pages/` or routes. - React Native: `.tsx` components using `View`, `Text`, `Image`, `StyleSheet`. - Angular: `.ts/.html/.scss` with schematics for components and modules. - Vue: `.vue` Single File Components with `