FigLens
by sharad-77
README.md
# FigLens
**FigLens** is a high-speed Linux desktop visual `.fig` inspector and local **MCP (Model Context Protocol) server** powered by a **Hybrid Rust Core + CanvasKit WASM** engine for massive Figma exports (`200+ MB`, `500,000+` nodes, `500+` embedded images).
Designed to solve the context-bloat and freeze/OOM issues of working with huge local `.fig` exports alongside AI coding agents: open the full design canvas smoothly, click or box-select the exact components you care about, inspect JSX/CSS/design tokens, and expose only that targeted selection to your coding agent via Figma-compatible MCP tools.
## Features
- **Native Rust Engine & Memory-Mapped Cache (`figlens-core`):** Static `x86_64-linux-musl` Rust daemon indexes `220 MB` / `543k`-node `.fig` files in **~4s**, reloads warm files via `mmap` in **~230 ms** (`~100 MB` RSS), searches `500k+` nodes in **~5 ms**, and extracts isolated `<1 MB` screen slices in **~60 ms** without re-reading the full archive.
- **Full Design View Like Figma + Focus Mode:** Pan and zoom across entire Figma pages (`SECTION` regions + `900+` screens laid out at true `(x, y)` coordinates) with viewport-virtualized progressive CanvasKit rendering, or toggle **Focus Screen** to isolate a single frame.
- **Figma-Style Multi-Mode Canvas Cursor Dock:**
- **`V` Select / Inspect:** Click any card, frame, or text layer (`Shift+Click` toggles multi-selection; repeat-click cycles through stacked overlapping layers).
- **`H` Hand Pan (`Space` hold / Middle or Right drag):** Pan smoothly across the full page board.
- **`I` Measure / Redlines (`Alt` hold):** Hover any element to render live pixel distance rulers (`top`, `right`, `bottom`, `left`, sibling gaps) relative to the selected element or container.
- **`M` Box Multi-Select:** Drag a marquee rectangle to select multiple elements at once; Inspector & MCP combine all selected nodes cleanly.
- **Zoom Controls:** `Shift+1` Fit Page, `F` Fit Selection, `1` Zoom `100%`, wheel zoom.
- **Pristine Layout Inspection + Isolated Render Pass:** Preserves exact Figma node geometry while running `@open-pencil/core` CanvasKit + Yoga rendering on an isolated graph copy.
- **Built-In MCP Server (`127.0.0.1:7600/mcp` + `--mcp-stdio`):** Exposes 13 Figma/OpenPencil-compatible MCP tools: `get_selection`, `get_design_context`, `get_screenshot`, `get_node`, `get_jsx`, `get_metadata`, `get_variable_defs`, `find_nodes`, `list_pages`, `list_screens`, `get_page_tree`, `select_nodes`, `open_file`.
- **Cross-Distro Portable `.AppImage`:** Bundles Electron (`GLIBC_2.25` baseline) + statically linked `musl` Rust binary so a single `.AppImage` runs identically on Ubuntu (`20.04`/`22.04`/`24.04+`), Debian, Fedora, and Manjaro/Arch.
## Download & Install (AppImage)
Download the latest `FigLens-x86_64.AppImage` from [GitHub Releases](https://github.com/sharad-77/fig-lens/releases):
```bash
chmod +x FigLens-x86_64.AppImage
./FigLens-x86_64.AppImage /path/to/design.fig
```
Or install it into `~/Applications/FigLens.AppImage`, `~/.local/bin/fig-lens`, and your desktop menu:
```bash
chmod +x packaging/install.sh
./packaging/install.sh /path/to/FigLens-x86_64.AppImage
```
Pass `--no-mcp` to skip automatic CLI MCP registration.
## Connecting Coding Agents (MCP)
While FigLens GUI is open, a local Streamable HTTP MCP server listens at **`http://127.0.0.1:7600/mcp`** (recommended so your agent shares live UI selection & screenshots):
### Claude Code
```bash
claude mcp add --transport http fig-lens http://127.0.0.1:7600/mcp
```
### Cursor / Windsurf / VS Code / Generic MCP JSON
```json
{
"mcpServers": {
"fig-lens": {
"url": "http://127.0.0.1:7600/mcp"
}
}
}
```
### Headless `--mcp-stdio` Mode (No X11 Required)
For agents spawning FigLens via stdio (such as Antigravity CLI, registered automatically by `packaging/install.sh`):
```json
{
"mcpServers": {
"fig-lens": {
"command": "fig-lens",
"args": ["--mcp-stdio"]
}
}
}
```
## Build From Source
### Requirements
- **Node.js** `20+` & `npm`
- **Rust toolchain** (`cargo` + `rustc`, plus `musl` C compiler for static AppImage builds)
On **Ubuntu / Debian**:
```bash
sudo apt install -y nodejs npm clang llvm musl-tools curl
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
On **Arch / Manjaro**:
```bash
sudo pacman -S --needed nodejs npm rust clang lld llvm curl
```
### Build & Test Commands
```bash
# 1. Install Node dependencies & CanvasKit runtime safety patch
npm install
# 2. Build static native Rust engine -> resources/bin/figlens-core
npm run build:rust
# 3. Run Rust, CanvasKit render, isolation & MCP end-to-end tests
npm test
# 4. Run FigLens locally
npm start -- /path/to/design.fig
# 5. Build portable Linux AppImage -> dist/FigLens-x86_64.AppImage
npm run build:appimage
```
To run the test suite against your own large `.fig` file:
```bash
FIG_LENS_TEST_FILE=/path/to/large-design.fig npm test
```
## Architecture
Further engineering notes for human & AI maintainers are documented in [PLAN.md](./PLAN.md) and [CHANGELOG.md](./CHANGELOG.md).
## License
MIT — see [LICENSE](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues