openfig-mcp
v0.4.0MCP server that turns Figma .fig files into LLM-ready design specs: frames, HTML/CSS, tokens, components, hover states, animations, SVG icons, images and fonts.
Built on OpenFig's .fig parser (openfig-core). Images and SVGs are drawn from the geometry Figma itself stored in the file: glyph outlines for text (so renders show the real typeface without the font installed), precomputed vector and stroke outlines, and the override-resolved component tree. 1. Save your Figma file into the project as design.fig (Figma: *Main menu → File → Save local copy…*, or *Download* on a Community file). 2.
Summary extracted from the README.
openfig-mcp
Figma .fig files → LLM-ready design data, over MCP. No Figma account, API token or plugin: point it
at a downloaded .fig file and your coding agent (GitHub Copilot, Claude, Cursor, …) can list the
screens, pull any frame as HTML + CSS, see it as an image, and get the design tokens, components,
hover/press states, animations, prototype links, icons (SVG), images and fonts.
Built on OpenFig's .fig parser (openfig-core).
Images and SVGs are drawn from the geometry Figma itself stored in the file: glyph outlines for text
(so renders show the real typeface without the font installed), precomputed vector and stroke
outlines, and the override-resolved component tree.
Quick start — VS Code + GitHub Copilot
- Save your Figma file into the project as
design.fig(Figma: Main menu → File → Save local copy…, or Download on a Community file). - Add
.mcp.jsonat the root of your workspace (the portablemcpServersformat that VS Code's Copilot agent reads):
{
"mcpServers": {
"openfig": {
"type": "stdio",
"command": "npx",
"args": ["-y", "openfig-mcp", "design.fig"],
"tools": ["*"]
}
}
}
A relative path like design.fig is resolved against the server's working directory and then the
workspace folders the client reports. An absolute path always works.
- Open Copilot Chat in Agent mode and describe what you want built. For example:
Implement the "Login" screen from the design in React + Tailwind.
Use openfig to build
https://www.figma.com/design/…?node-id=12-345as a Vue component.
These are only examples: ask in your own words, for your own stack.
The file given in args is the default for every tool. Frames can be referenced by name ("Login"),
id ("12:345") or a Figma URL with node-id. Working with several files? Pass a folder
("designs") instead, and name the file in the prompt ("…from designs/app.fig").
Other clients
{
"mcpServers": {
"openfig": { "command": "npx", "args": ["-y", "openfig-mcp", "/absolute/path/to/your-project/design.fig"] }
}
}
Claude Code: claude mcp add openfig -- npx -y openfig-mcp ./design.fig
Tools
| Tool | What the agent gets |
|---|---|
list_fig_files |
.fig files in the workspace |
list_frames |
pages → sections → screens / frames / component sets, with ids, sizes, prototype start points |
get_frame |
the main tool. Summary (fonts, components + variants, tokens, :hover/:active states, auto-playing animations, navigation & modals) plus an HTML + CSS reproduction. Writes an export folder (below) |
render_frame |
optional PNG of any frame/node for a quick visual overview (not needed to implement: get_frame has the exact values) |
get_design_tokens |
color / text / effect styles and Figma Variables (all modes, e.g. light/dark) as CSS custom properties + typography classes, or JSON |
list_components |
components & variant sets with their properties (State=Hover, Size=lg…) and usage counts |
get_component |
every variant, the CSS diff between interactive states, HTML/CSS of the set |
search_nodes |
find layers by name or text ("Sign in", "price") |
get_prototype_flows |
flows and every click/hover/timer link between screens, overlays (modals), URLs |
export_svg |
any icon / logo / vector as SVG |
check_fonts |
the fonts a frame or file needs, the file found for each, and which are missing |
verify_implementation |
checks the agent's result against the design: opens the running page (URL or .html), compares every element tagged data-figma-id="<id>" with Figma's stored position, size and style (radius, background, border, shadow, opacity, typography — catches UI-library defaults overriding the design), checks the text, compares pixels with the design and writes a diff image. The agent calls it at the end and fixes what it lists |
Plus an MCP prompt implement_frame (in VS Code: /mcp.openfig.implement_frame).
What get_frame writes
<OS temp>/openfig-mcp/<file>/<frame>-<id>/ (or the outDir you pass; nothing is written into your workspace by default)
DESIGN.md summary: fonts, components, states, animations, links, modals
index.html HTML reproduction (flex where Figma used auto-layout, absolute elsewhere)
styles.css one class per unique style + :hover / :active rules from variant interactions
tokens.css CSS variables for the tokens this frame uses (styles + variables, per mode)
spec.json full tree: box, style, text runs, constraints, component/variant info, interactions
preview.png rendering of the frame (visual overview only)
assets/ SVG icons & vectors, images (png/jpg/gif/webp), masked groups as PNG
Response size
Each tool response is kept within a character budget, 40,000 by default. get_frame and
get_component fit inside it by collapsing deep subtrees (with a pointer to drill in: get_frame on a
section id). Other tools are cut off with a note. The full files are always written to disk.
Set the budget to match your model's context window:
| Where | Example | Scope |
|---|---|---|
| server args | "args": ["-y", "openfig-mcp", "design.fig", "--max-chars", "120000"] |
every response |
| env | "env": { "OPENFIG_MCP_MAX_CHARS": "120k" } |
every response |
| tool argument | get_frame with "maxChars": 200000 |
that one call (overrides the above) |
Use a lower value (for example 16000) for small-context models, and a higher one (120k–400k)
for large-context models that should get a whole screen in one response.
What is extracted
| Figma | Output |
|---|---|
| Auto layout (direction, gap, padding, alignment, wrap, hug / fill / fixed, absolute children, margins) | display:flex, gap, padding, justify-content, align-items, flex: 1, align-self, fit-content |
| Frames without auto layout, constraints | absolute positioning (+ constraints in spec.json) |
| Fills: solid, linear/radial/angular gradients, images (fill/fit/tile/crop), multiple layers | background (stacked), <img object-fit> |
| Strokes (inside/center/outside, per-side, dashed), corner radii (per corner) | outline/border-*, border-radius |
| Effects: drop/inner shadow, layer & background blur | box-shadow, text-shadow, filter, backdrop-filter |
| Opacity, blend modes, clip content, scrolling frames | opacity, mix-blend-mode, overflow |
| Text: font, weight, size, line height, letter spacing, case, decoration, alignment, truncation, mixed-style runs, links | full typography, <span> runs, <a> |
| Color / text / effect styles, Figma Variables + modes | var(--color-primary-600), .ts-text-md-semibold, [data-theme="dark"] blocks |
| Components, variants, instance overrides, component properties (text / boolean / instance swap) | resolved per instance; data-component / data-variant attributes |
| Prototype interactions, variants, states | see Interactivity |
| Vectors, icons, boolean ops, masks | SVG files (icons deduplicated), masked groups → PNG |
| Fonts | reported, not bundled: family, weights and styles of every font used, with a warning to add them to the project (and whether each is installed locally) |
Ids of nodes inside component instances use Figma's own format (I<instance>;<child>).
Interactivity
Everything Figma's prototype model can express is extracted, and turned into CSS where CSS can express it:
| Figma | Output |
|---|---|
Triggers: on click, while hovering, while pressing, mouse enter / leave / down / up, after delay, key press (key names, e.g. Escape), drag, video events |
per element in spec.json, data-on-click="…" / data-on-hover="…" / data-on-key="…" attributes, and a plain-English list in the summary |
| Navigate to another frame, back, scroll to a layer (+ offset), open URL (new tab or not) | "click → navigates to "Checkout" (12:34) [smart animate 300ms ease-out]" |
| Overlays / modals: open, swap, close; position, backdrop color, close-on-outside-click | "click → opens overlay/modal "Share" — position center, closes on outside click, backdrop rgba(0,0,0,0.5)" |
| Variant swaps ("change to") | CSS diff between the two variants, plus exactly which layers appear and disappear (shows "Dropdown menu", hides "Badge") |
Variables: set variable (with expressions like !menuOpen), set mode (theme / language), conditionals (if / else) |
"click → sets menuOpen = !menuOpen → toggles visibility of "Dropdown menu" (hidden by default)" (layers whose visibility is bound to the variable are resolved) |
| Pseudo-classes | :hover, :active (from hover / press interactions, chains like Default → Hover → Pressed included) and, from variant naming (State=Hover / Pressed / Focused / Disabled, Selected / Checked / Open = True, State=Error / Loading): :hover, :active, :focus-visible, :disabled + [aria-disabled], [aria-selected], :checked + [aria-checked], [aria-expanded], [aria-invalid], [aria-busy]. Layers hidden in the target state get display: none; layers that only exist in the target state are listed so they can be rendered conditionally |
| Timers (after delay → change variant) | grouped into auto-playing animations (carousels, marquees, loaders) with each step's delay, transition and easing |
| Transitions | type (instant, dissolve, slide/push/move in/out, smart animate), duration, easing as cubic-bezier() |
| Scrolling: scroll direction, fixed and sticky layers | overflow, `data-scroll="fixed |
| Prototype flows | get_prototype_flows: starting points and every link between screens |
Hover and press states become CSS rules. Click toggles, key handlers, variables and conditionals are described precisely (trigger, effect, timing) for the agent to implement in the app's framework.
How the agent works with it
The server tells the agent (and the implement_frame prompt spells out) this workflow:
- Build from the data, not from the picture or the HTML.
get_frame's summary andspec.jsonhold the exact values from the file: every layer's box, auto-layout, padding, gap, colors, typography, text and component properties. The HTML reproduction matches Figma's layout and serves as a reference; a few Figma features have no exact CSS equivalent (angular/diamond gradients, gradient strokes, background blur, some blend modes) and are approximated there. - Tag the elements it builds with the Figma ids:
data-figma-id="<id>"(thedata-idvalues in the export). - Override UI-library defaults that differ from the design. When the project uses a component library
(MUI, Ant Design, Chakra, Mantine, Bootstrap, Vuetify, shadcn/ui…), the agent compares each component's
defaults with the Figma values (radius, padding, height, gap, background, border, shadow, typography,
icon size) and overrides the ones that differ, for example a dialog that is square by default but
rounded in Figma. Overrides go in the project's own code (theme overrides, style props/classes or a
local wrapper component), never in
node_modulesor the library's files. - Verify at the end with
verify_implementation: the tool opens the running page, compares every tagged element with Figma's stored geometry (default tolerance 0.5 px) and its computed style with Figma's (corner radius, background, border, shadow, opacity, text color, size, weight, line height and letter spacing), checks the text and compares pixels with the design, then lists what is off. A style difference on a library component usually means a library default is winning. The agent fixes those items from the data and verifies again until it matches. - Reports at the end which library defaults it overrode (component, property, library default → Figma value, file changed) and which fonts are missing (they fall back to system fonts meanwhile).
Verification needs Edge or Chrome installed (or CHROME_PATH).
Fidelity
npm run fidelity -- <file.fig> opens every generated index.html in a real browser and compares each
element's box with the position and size Figma stored in the file for that layer (layers inside
rotated or skewed groups are compared in their unrotated coordinates, as Figma stores them). It also
checks every text string and asset reference.
Results on two community files: 8 Interactive UI Designs (38 screens, 5,802 elements) and Figma's Simple Design System (8 frames, 453 elements, with variables, modes and component properties):
| Export | Elements within 0.1 px of Figma | within 2 px | Text present | Broken assets |
|---|---|---|---|---|
default (textSizing: "exact") |
100 % (6,255 / 6,255) | 100 % | 100 % | 0 |
textSizing: "fluid", with the designs' fonts installed |
71 % / 81 % | 98.5 % / 91 % (Whyte missing) | 100 % | 0 |
Text sizing
Text that "hugs" its content in Figma gets its size from the font. Browsers measure text slightly differently from Figma (kerning, rounding), and very differently when the design's font isn't installed, so CSS that lets the browser size such text can't match Figma exactly, and the difference moves everything next to it in auto layout.
exact(default): every text box gets the width and height Figma measured, so the exported layout matches the file to 0.1 px. Text that hugs its content in Figma is marked in the CSS (/* sizing: hugs its text in Figma … */), so an agent knows to let it size to its content in the real implementation.fluid: hug-sized text is left to the browser, like hand-written CSS would. Exact only with the same fonts and text rendering as Figma.get_frametakestextSizing, the CLI takes--fluid-text.
Per-element reports (with every deviation listed) are written to the --out folder.
CLI
The same package is a CLI (handy for CI or a quick look):
npx -y openfig-mcp frames design.fig # list frames
npx -y openfig-mcp export design.fig "Login" -o out/ # export bundle
npx -y openfig-mcp render design.fig 12:345 -o login.png
npx -y openfig-mcp tokens design.fig [--json]
npx -y openfig-mcp components design.fig [query]
npx -y openfig-mcp search design.fig "Sign in"
npx -y openfig-mcp flows design.fig
Library
import { FigFile } from 'openfig-mcp';
const fig = await FigFile.open('design.fig');
fig.listFrames(); // [{ id, name, kind, page, size, ... }]
const r = await fig.getFrame('Login', { outDir: 'out/login' });
r.summary; r.fullHtml; r.fullCss; r.spec; r.meta.states;
const { png } = await fig.render('12:345');
fig.tokens().css;
Configuration
| Option | |
|---|---|
--max-chars <n> / OPENFIG_MCP_MAX_CHARS=<n> |
character budget for one tool response (default 40000; 120k style values work). See Response size |
OPENFIG_MCP_EXPORT_DIR=<dir> |
root folder for get_frame exports when no outDir is given (default: <OS temp>/openfig-mcp) |
OPENFIG_MCP_FONT_DIRS=dir1;dir2 |
extra folders searched for the design's font files (after fonts/ next to the .fig and in the workspace). See Fonts |
Fonts
Renders and SVG exports don't need fonts. A .fig file stores the outline of every glyph Figma laid
out, so render_frame, preview.png, export_svg and the SVG assets draw text exactly as Figma did:
the real typeface, weights, kerning and line breaks, with no font installed.
The HTML export uses the design's fonts when it can find them. For every font a frame uses (family and style, as Figma names them), openfig-mcp looks for the file, in this order:
- a
fonts/folder next to the.figfile (e.g.design.fig+fonts/) fonts/in the workspace foldersOPENFIG_MCP_FONT_DIRS- the fonts installed on the machine
Fonts are matched by their PostScript name, family, style, weight and italic flag (variable fonts by
their weight range). Found fonts are copied to the export's assets/fonts/ and declared in
fonts.css with @font-face, so index.html renders in the real typefaces.
Missing fonts never block the work. The CSS falls back to a system font of the same kind
('Clash Display', sans-serif, 'Crimson Text', serif, 'Roboto Mono', monospace), and layout stays
exact because text boxes use Figma's measured sizes. The response lists the missing fonts, and the agent
is told to keep going and mention them to you when it finishes, with where to put the files. Add them to
fonts/ and the next export includes them. check_fonts lists what a frame or the whole file needs and
what was found.
openfig-mcp never downloads fonts: they are licensed separately.
Limitations
.figis Figma's private format. openfig follows it closely, but a new Figma release can add fields before the parser knows them. Everything unknown is passed through tospec.jsonas-is.- Renders use Figma's stored geometry, so shapes, icons and text match Figma. Approximated: angular and diamond gradients, background blur, noise/glass/progressive-blur effects, image filters (exposure, contrast…). Text whose content changed without Figma re-laying it out (rare) falls back to installed fonts.
- Components from unpublished external libraries only exist in the file as the copies Figma embeds (that is usually all that is needed).
- Smart-animate transitions are described (from/to state, duration, easing). The generated CSS covers hover/press states. Click toggles, carousels and page transitions are listed for the agent to implement in JS.
- Figma Variables (aliases, collections, modes, per-frame mode overrides) are resolved in renders and exported as CSS custom properties with one block per mode.
Development
npm install
npm test # unit + end-to-end MCP tests (FIG_SAMPLE=/path/to.fig for the big ones)
npm run fidelity -- design.fig [frameId…] # browser-based fidelity report (needs Edge/Chrome or CHROME_PATH)
npm run compare-figma -- design.fig figma-exports/ # compare renders + HTML with PNGs exported from Figma (1x, named like the frames)
MIT. Figma is a trademark of Figma, Inc. This project is not affiliated with Figma.