Since 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.
- 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.
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
ComponentAnalysiswith metadata, layout, styling, children, nested components, and variants when applicable.
- Entry points:
- Screens:
src/extractors/screens/- Entry point:
analyzeScreen - Outputs
ScreenAnalysiswith sections (header/content/footer/navigation), assets, and nested components.
- Entry point:
- Colors:
src/extractors/colors/- Entry points:
extractThemeColors,extractColorsFromThemeFrame - Outputs normalized theme color swatches.
- Entry points:
- Typography:
src/extractors/typography/- Entry point:
extractThemeTypography - Outputs normalized text styles with font family, size, weight, and line height.
- Entry point:
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.
Tools live under src/tools/<framework>/ 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/INSTANCEas reusable widgets; treatFRAMEas 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.yamlfor 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.
The fastest path is to keep the extractors intact and replace the Flutter‑specific tools with your framework’s equivalents.
- Create
src/tools/react/(orreact-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)
- A tool to analyze a component or component set (wraps
analyzeComponentand optionally variant handling). - A tool to analyze a full screen (wraps
analyzeScreen). - Optional generators to emit framework code:
- React:
.tsxcomponents insrc/components/, pages insrc/pages/or routes. - React Native:
.tsxcomponents usingView,Text,Image,StyleSheet. - Angular:
.ts/.html/.scsswith schematics for components and modules. - Vue:
.vueSingle File Components with<template>,<script>, and<style>.
- React:
- Layout
- Auto‑layout (direction + spacing) → React/React Native:
display: flex; flexDirection: row|column; gap/margins; Angular/Vue: templates + CSS. - Absolute/stacked → React/React Native:
position: 'absolute'/wrapper; Angular/Vue: positioned containers.
- Auto‑layout (direction + spacing) → React/React Native:
- Styling
- Fills, strokes, corner radii, shadows → map to CSS/CSS‑in‑JS/StyleSheet equivalents.
- Effects (
DROP_SHADOW,INNER_SHADOW, blurs) → CSSbox-shadow,filter, or platform‑specific fallbacks.
- Text
- Use
textInfoto choose the right semantic component (e.g.,h1/h2,Button,Link) or apply aTextwith style.
- Use
- Components vs screens
- Treat
COMPONENT/INSTANCEas reusable components. - Treat
FRAMEas a screen/page (with a child‑count threshold if you adopt the same heuristic as Flutter tools).
- Treat
- Theming
- Reference theme tokens (colors/typography) instead of hardcoding styles. For React, prefer ThemeProvider (e.g., MUI, styled‑components, or your design system).
- Assets
- Export images/SVGs and write importable paths using your framework’s conventions (e.g.,
public/for Vite/Next.js, Android/iOS asset catalogs for React Native).
- Export images/SVGs and write importable paths using your framework’s conventions (e.g.,
Flutter’s helper (src/tools/flutter/components/helpers.mts) produces guidance like "Use Row/Column" or BoxDecoration for containers. For React, your equivalent helper would:
- Recommend
div/sectionstructure withdisplay: flexandflexDirection. - Map paddings/margins/spacing to CSS or a CSS‑in‑JS solution.
- Suggest semantic elements for headings/links/buttons.
- Show small code snippets using your preferred stack (e.g., React + CSS Modules or styled‑components).
Example guidance output snippet (React):
// Container layout
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, padding: 16 }}>
{/* ...children */}
</div>Just like the Flutter tools can emit widgets, you can add a lightweight generator to create files and wire imports:
- React
- Components →
src/components/<PascalName>/<PascalName>.tsx - Screens/Pages →
src/pages/<kebab-name>.tsx(or Next.js routes) - Styles → collocate via CSS Modules, styled‑components, Tailwind, etc.
- Components →
- React Native
- Components →
src/components/<PascalName>.tsx - Use
StyleSheet.create({...})for styles. Map shadows/radius/fills accordingly.
- Components →
- Angular
- Use schematics to scaffold
component.ts/html/scssand update module declarations.
- Use schematics to scaffold
- Vue
- Generate
.vueSFCs with<template>mapped from layout and<style>from styling info.
- Generate
- Reuse color/typography extractors to populate your theme tokens.
- Export image/SVG assets and centralize paths/constants for your framework.
- Keep asset policies explicit (e.g., which scales to export, where to write constants) and append new entries rather than overwriting existing ones.
- Create
src/tools/<framework>/withcomponents/,screens/,assets/,helpers.mts. - Wrap extractors (
analyzeComponent,analyzeScreen) and print a minimal analysis report. - Add guidance helpers that output idiomatic snippets for your framework.
- Add asset export and theme token mapping.
- (Optional) Add code generation and a small registry to prevent duplicate components.
- Register your tools in
src/tools/index.mtsso they’re available via MCP/CLI. - Update docs with usage examples and flags.
Extractors are the framework‑agnostic heart of the system. They convert Figma data into structured, typed models (components, screens, colors, typography) that downstream tools can map to any framework without re‑implementing Figma traversal.
Tools are the framework‑specific bridge. They orchestrate extractors, apply heuristics (e.g., classify component vs screen), generate guidance or code, export assets, and integrate with a project’s conventions (file layout, theming, configuration).
- Do not modify extractors.
- Create
src/tools/react/with your own helpers and generators. - Replace Flutter‑specific guidance with React guidance (flexbox, semantic HTML, CSS‑in‑JS, etc.).
- Implement asset export paths and theme references that match your React app setup.
If you’d like a concrete Flutter reference, see src/tools/flutter/components/helpers.mts and src/tools/flutter/screens/screen-tool.mts and mirror their responsibilities for your framework.
If you fork this repository to support another framework (React, React Native, Angular, Vue), please keep it open source so others can build on top of the extractor core and share improvements to the tooling layers.