Bridges Paper.design's
get_jsxoutput to your codebase's named component library.
Paper solves the Figma MCP problem beautifully — its canvas is real HTML/CSS, so get_jsx returns actual Tailwind instead of absolute-positioned nonsense. But one gap remains:
Paper outputs generic HTML. Your codebase uses named components.
When an AI agent calls get_jsx on a Paper canvas, it gets:
<div className="inline-flex items-center px-4 py-2 bg-primary rounded-md text-white text-sm font-medium cursor-pointer">
Get Started
</div>But your codebase has:
import { Button } from "@/components/ui/button";
<Button variant="default" size="default">Get Started</Button>The agent has no way to know about your Button, your Card, your Input. It either generates duplicate components that diverge from your design system, or makes you correct the output manually — which defeats the point of an MCP-powered workflow.
paper-bridge closes this gap by adding a get_enriched_jsx tool to Paper's MCP that substitutes your named components before the LLM ever sees the output.
You describe your component library in a paper-components.json manifest at your project root. paper-bridge reads it, wraps Paper Desktop's MCP server, and intercepts get_jsx calls to run the substitution automatically.
paper-bridge MCP (stdio)
│
├── get_enriched_jsx ← NEW: returns named components
│ │
│ └── calls Paper's get_jsx → runs transformer → returns enriched JSX
│
├── get_selection ← pass-through to Paper
├── write_html ← pass-through to Paper
├── get_screenshot ← pass-through to Paper
└── ... all other Paper tools
The transformer uses a Babel AST to match HTML elements by their Tailwind class patterns, resolve their props, and rewrite to named imports. It's purely additive — unrecognized elements pass through unchanged.
# 1. Install
npm install -g paper-bridge
# 2. Add your component registry at project root
# (see examples/shadcn-components.json for a full shadcn/ui example)
cat > paper-components.json << 'EOF'
{
"$schema": "https://unpkg.com/paper-bridge/schemas/components-json.schema.json",
"version": "1",
"source": "shadcn/ui",
"imports": {
"Button": "@/components/ui/button",
"Card": "@/components/ui/card",
"Input": "@/components/ui/input",
"Badge": "@/components/ui/badge"
},
"components": [...]
}
EOF
# 3. Point Claude Desktop (or Cursor) at the bridge instead of Paper directlyAdd to your claude_desktop_config.json:
{
"mcpServers": {
"paper": {
"command": "paper-bridge",
"args": ["serve", "--registry", "/path/to/your/paper-components.json"]
}
}
}Make sure Paper Desktop is running. The bridge connects to it at http://127.0.0.1:29979/mcp automatically.
A minimal manifest for a single component:
{
"version": "1",
"imports": {
"Button": "@/components/ui/button"
},
"components": [
{
"name": "Button",
"match": {
"tags": ["div", "button", "a"],
"requiredClasses": ["rounded"],
"classPatterns": ["flex", "items-center", "font-medium", "px-4", "py-2"],
"excludeClasses": ["grid", "flex-col"]
},
"confidence": 0.4,
"props": [
{
"name": "variant",
"from": "className",
"map": {
"bg-primary": "default",
"bg-blue-600": "default",
"border border-input": "outline",
"bg-secondary": "secondary"
},
"default": "default"
}
],
"slot": "children"
}
]
}- Tag filter —
match.tagsrestricts which HTML elements are candidates. Omit to match any. - Required classes (AND gate) — all substrings in
requiredClassesmust be present inclassName, otherwise this element is immediately skipped. - Exclude classes — if any substring in
excludeClassesappears, the element is disqualified. - Pattern scoring — the ratio of
classPatternsmatched determinesconfidence. Must meet the component'sconfidencethreshold (default 0.5). - Winner — the highest-confidence candidate wins. Ties go to the first defined component.
from |
What it does |
|---|---|
className |
Scans the element's className string. The first key in map that appears wins; default is the fallback. |
attribute |
Reads an HTML attribute (e.g. type, placeholder, disabled). Set isBooleanProp: true for <Input disabled /> rendering. |
static |
Always emits the same value regardless of the element. |
"slot": "children"— preserves child elements inside the component"slot": null— makes the component self-closing (use for<Input />,<Separator />, etc.)
# Transform a Paper JSX file
paper-bridge transform -r ./paper-components.json -f input.jsx
# Pipe from stdin
cat input.jsx | paper-bridge transform -r ./paper-components.json
# Validate your registry
paper-bridge validate -r ./paper-components.json
# Start the MCP bridge server (for Claude Desktop / Cursor)
paper-bridge serve -r ./paper-components.jsonSee examples/input.jsx and run:
paper-bridge transform -r examples/shadcn-components.json -f examples/input.jsxInput (raw Paper get_jsx output):
<div className="rounded-lg border bg-card text-card-foreground shadow-sm">
<div className="inline-flex items-center px-4 py-2 bg-primary rounded-md text-white text-sm font-medium">
Create account
</div>
<div className="inline-flex items-center px-4 py-2 border border-input bg-background rounded-md text-sm font-medium">
Continue with Google
</div>
<input className="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm" type="email" placeholder="you@example.com" />
<div className="inline-flex items-center rounded-full border-transparent bg-secondary px-2.5 py-0.5 text-xs font-semibold">Beta</div>
</div>Output (enriched by paper-bridge):
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { Card } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
<Card>
<Button variant="default" size="default">Create account</Button>
<Button variant="outline" size="default">Continue with Google</Button>
<Input type="email" placeholder="you@example.com" />
<Badge variant="secondary">Beta</Badge>
</Card>paper-bridge addresses Gap 1 — the one that blocks every production user today. Four gaps remain as research directions:
| # | Gap | Root cause | Status |
|---|---|---|---|
| 1 | Component library mismatch | Paper knows visual shape, not your component API | ✅ paper-bridge solves this |
| 2 | Behavioral state spec | No hover/focus/loading protocol in MCP output | Open |
| 3 | Responsive intent | Single viewport, no breakpoint encoding between artboards | Open |
| 4 | Visual verification loop | No render→diff→correct cycle | Open |
| 5 | Cross-session token drift | Canvas tokens and codebase tokens diverge silently | Open |
This project is an open proposal to the Paper team. If you're from Paper.design and want to discuss making get_enriched_jsx a native feature — or building paper-components.json into Paper's MCP server — open an issue or reach out.
The components.json concept is intentionally spec-first: it should live as close to Paper's core as possible, not as external middleware.
MIT