figma-design-system-mcp
by mfaizanatiq
README.md
# figma-design-system-mcp
An MCP server that works alongside Figma’s MCP to produce component specification Markdown and help AI agents understand and build components. Run both servers together: Figma MCP reads the canvas; this server turns that context into durable specs, token lookups, validation gates and implementation briefs.
## Why / the component-spec mindset
One Markdown file per component is the shared contract for designers, developers, content writers and AI tools. Specs are the source of truth; Figma is an input; code is an output. Prefer a TODO over an invented value. See [docs/component-spec-mindset.md](docs/component-spec-mindset.md).
## Tools
| Tool | Read-only | Description |
| --- | --- | --- |
| `list_components` | yes | List specs (id, name, status, category, summary) |
| `get_component_spec` | yes | Full Markdown, or one named section |
| `get_tokens_by_role` | yes | Filter tokens by role / component / category / prefix |
| `scaffold_spec` | yes | Empty standard-format draft for a new name |
| `generate_spec_from_figma` | yes | Figma MCP outputs (JSON, `get_metadata` XML, `get_design_context` code/markdown, optional `variables`) → draft; returns JSON `{ id, missing, markdown }` (TODOs for gaps; heuristic — review) |
| `validate_spec` | yes | Section, front matter, token, state, a11y, content gates |
| `get_implementation_brief` | yes | Spec → props, states, tokens, tests, acceptance |
| `write_spec` | no | Write Markdown into `DS_SPEC_ROOT/specs` (path-guarded) |
Resources: `spec://format`, `spec://tokens`, `spec://{id}` (e.g. `spec://button`).
Prompts:
- `spec-from-figma` — optional argument `component`
- `build-component-from-spec` — required `id`, optional `framework`
## Quick start
Clone and run locally:
```bash
git clone https://github.com/mfaizanatiq/figma-design-system-mcp.git
cd figma-design-system-mcp
npm install
npm run build
node dist/index.js
```
Or, once the package is on npm:
```bash
npx -y figma-design-system-mcp
```
Point your MCP client at the bin over stdio (see examples below).
## Configuration
| Variable | Required | Description |
| --- | --- | --- |
| `DS_SPEC_ROOT` | no | Folder with `specs/` and `tokens/`. Defaults to the bundled examples. Replace the placeholder path in example configs with a real absolute path, or omit/unset the variable to use the bundled examples. Whitespace-only values are treated as unset. |
| `FIGMA_TOKEN` | no | Figma personal access token for optional REST node fetch. |
Copy [.env.example](.env.example). Never commit `.env`.
JSON MCP configs cannot hold comments: the `/absolute/path/to/your/design-system` value in the examples below is a placeholder — replace it, or remove `DS_SPEC_ROOT` so the server uses the bundled `specs/` and `tokens/`. Leaving the placeholder as-is points at a missing folder and yields empty component lists.
## Cursor + Claude Desktop (alongside Figma MCP)
**Cursor** — merge with your MCP config (see [examples/cursor-mcp.json](examples/cursor-mcp.json)):
```json
{
"mcpServers": {
"figma": {
"type": "http",
"url": "https://mcp.figma.com/mcp"
},
"figma-design-system-mcp": {
"command": "npx",
"args": ["-y", "figma-design-system-mcp"],
"env": {
"DS_SPEC_ROOT": "/absolute/path/to/your/design-system",
"FIGMA_TOKEN": ""
}
}
}
}
```
**Claude Desktop** — merge into `claude_desktop_config.json` (see [examples/claude_desktop_config.json](examples/claude_desktop_config.json)):
```json
{
"mcpServers": {
"figma": {
"command": "npx",
"args": ["-y", "figma-developer-mcp", "--stdio"],
"env": { "FIGMA_API_KEY": "" }
},
"figma-design-system-mcp": {
"command": "npx",
"args": ["-y", "figma-design-system-mcp"],
"env": {
"DS_SPEC_ROOT": "/absolute/path/to/your/design-system",
"FIGMA_TOKEN": ""
}
}
}
}
```
For local development, replace the `npx` command with `node` and `args: ["/absolute/path/to/figma-design-system-mcp/dist/index.js"]`.
## Example prompts
- “Using Figma MCP: call `get_metadata`, `get_design_context`, and `get_variable_defs` on the selection, then `generate_spec_from_figma` with that `context` (and `variables`). Pass the returned `markdown` to `validate_spec`.”
- “Run the `spec-from-figma` prompt with `component` set to Button.”
- “Run `build-component-from-spec` with `id` `button` and `framework` `react`.”
- “List components, get the Button spec’s Accessibility section, then give me a React implementation brief.”
- “Scaffold a spec for Search field, fill Token bindings from `get_tokens_by_role`, validate, then write it.”
## Spec format summary
Required H2 sections in order: Purpose → Anatomy → Variants and props → States → Token bindings → Content rules → Accessibility → Code mapping → Acceptance criteria.
Front matter must include `library`, `component`, `componentVersion`, `specRevision`, `updated`, `status`, `category`, `summary`. Full rules: [docs/spec-format.md](docs/spec-format.md).
Bundled examples: Button, Text field, Checkbox, Card, Dialog under `specs/`, with a neutral token set in `tokens/base.json`.
## Architecture / extending
Pluggable sources: `LocalSource` for disk Markdown + W3C-style tokens; `FigmaSource` to normalise Figma MCP outputs — structured JSON, `get_metadata` XML, `get_design_context` code/markdown, MCP text envelopes, and `get_variable_defs` maps (and optionally fetch via REST). Add Storybook or Tokens Studio adapters behind the same `Source` interface. Details: [docs/architecture.md](docs/architecture.md) and [docs/using-with-figma-mcp.md](docs/using-with-figma-mcp.md).
## Scripts
```bash
npm run build # tsc → dist/
npm run typecheck
npm test # vitest
npm run smoke # stdio tools/list + one tool call
```
## Contributing
Issues and pull requests welcome. Keep docs in British English (write “colour” in prose; keep `color` in token names). Do not commit secrets. Add tests for parser, validator, generator and brief changes.
## Licence
MIT — see [LICENSE](LICENSE).
## Author
Mohammad Faizan Atiq, Design Systems Lead · [mfaizanatiq.com](https://www.mfaizanatiq.com)
AI-native design systems leader focused on component specs that designers, developers, content and AI tools all build from.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues