figma-console-mcp 1.44.1 → 1.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -11
- package/dist/core/code-layer-tools.d.ts +14 -0
- package/dist/core/code-layer-tools.d.ts.map +1 -0
- package/dist/core/code-layer-tools.js +57 -0
- package/dist/core/code-layer-tools.js.map +1 -0
- package/dist/core/motion-tools.d.ts +43 -0
- package/dist/core/motion-tools.d.ts.map +1 -0
- package/dist/core/motion-tools.js +621 -0
- package/dist/core/motion-tools.js.map +1 -0
- package/dist/core/tokens/figma-converter.d.ts +16 -3
- package/dist/core/tokens/figma-converter.d.ts.map +1 -1
- package/dist/core/tokens/figma-converter.js +28 -5
- package/dist/core/tokens/figma-converter.js.map +1 -1
- package/dist/core/tokens-tools.d.ts +7 -32
- package/dist/core/tokens-tools.d.ts.map +1 -1
- package/dist/core/tokens-tools.js +79 -29
- package/dist/core/tokens-tools.js.map +1 -1
- package/dist/core/write-tools.d.ts +6 -0
- package/dist/core/write-tools.d.ts.map +1 -1
- package/dist/core/write-tools.js +66 -14
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +4 -0
- package/dist/local.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
> **Your design system as an API.** A design-system-focused Model Context Protocol server for Figma. It works in both directions (Figma ⇄ code), **writes to Figma**, and runs **deterministic checks** for design-code parity, accessibility, and design-system health. It hands the AI exact tokens, variants, bindings, and states as structured data rather than prescribing a framework or house style, so generated code follows your team's own stack and conventions.
|
|
10
10
|
|
|
11
|
-
> **🆕
|
|
11
|
+
> **🆕 Motion tools and motion tokens, code layers, plus a shared local server, comment threads and security updates (latest v1.45.0):** animate layers with Figma Motion presets, custom animation styles or keyframes, bind easing and duration to Timing and Easing tokens, sync motion tokens to and from code, export animations as MP4, GIF or WebM, and find code layers in a file (v1.45.0). set `FIGMA_MCP_HTTP_PORT` and several local MCP clients can share one server and its Figma connection over Streamable HTTP, loopback only (v1.44.0). The MCP SDK and zod are upgraded to clear seven security advisories, with no change to how tools behave (v1.43.0). Commands fail fast instead of piling up behind a plugin stuck on a timed-out script, and a new server no longer shuts down one a thread is using (v1.42.1). `figma_get_comments` returns compact comment threads with node, thread and date filters and paging, so a busy file no longer floods the conversation (v1.42.0). Cloud Mode sign-in is hardened: each session uses only its own Figma token, authorization codes are single-use and bound to the client that asked for them, and the accessibility scanner no longer runs scripts from the HTML it checks. Two data-loss fixes: `figma_import_tokens` refuses an import that read no token files (it used to plan deleting every variable) and `replace` only deletes inside the collections you import; arranging a component set no longer deletes the other arranged sets on the page. Token export and import read variables live, so renames show up immediately. Abandoned servers exit on Windows, batch-created variables accept aliases, and the Slots tools take `fileKey`. v1.41.1–v1.41.5 make component-set analysis report real variant differences, including changes inside nested layers (an icon swap, a token on a nested vector), the variant's own background and opacity, auto-layout, gradients, corner radius, typography and swapped tokens, stop component loading from timing out on large files, and fix variable paging. Re-import the plugin for the component fixes. [See what's new →](CHANGELOG.md#1450---2026-10-28)
|
|
12
12
|
|
|
13
13
|
## What is this?
|
|
14
14
|
|
|
@@ -59,9 +59,9 @@ Figma Console MCP connects AI assistants (like Claude) to Figma, enabling:
|
|
|
59
59
|
| Codebase → design system extraction (`figma_ds_*`) | ✅ | ❌ | ❌ |
|
|
60
60
|
| Desktop Bridge plugin | ✅ | ✅ | ❌ |
|
|
61
61
|
| Requires Node.js | Yes | **No** | No |
|
|
62
|
-
| **Total tools available** | **
|
|
62
|
+
| **Total tools available** | **127** | **102** after pairing | Read-only subset |
|
|
63
63
|
|
|
64
|
-
> **Bottom line:** Remote SSE is **read-only** until you pair the plugin. **Cloud Mode** unlocks write access (
|
|
64
|
+
> **Bottom line:** Remote SSE is **read-only** until you pair the plugin. **Cloud Mode** unlocks write access (102 tools) from web AI clients without Node.js. NPX/Local Git gives the full 127 tools with real-time monitoring.
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
@@ -69,7 +69,7 @@ Figma Console MCP connects AI assistants (like Claude) to Figma, enabling:
|
|
|
69
69
|
|
|
70
70
|
**Best for:** Designers who want full AI-assisted design capabilities.
|
|
71
71
|
|
|
72
|
-
**What you get:** All
|
|
72
|
+
**What you get:** All 127 tools including design creation, variable management, and component instantiation.
|
|
73
73
|
|
|
74
74
|
#### Prerequisites
|
|
75
75
|
|
|
@@ -184,7 +184,7 @@ Create a simple frame with a blue background
|
|
|
184
184
|
|
|
185
185
|
**Best for:** Developers who want to modify source code or contribute to the project.
|
|
186
186
|
|
|
187
|
-
**What you get:** Same
|
|
187
|
+
**What you get:** Same 127 tools as NPX, plus full source code access.
|
|
188
188
|
|
|
189
189
|
#### Quick Setup
|
|
190
190
|
|
|
@@ -273,7 +273,7 @@ Ready for design creation? Follow the [NPX Setup](#-npx-setup-recommended) guide
|
|
|
273
273
|
|
|
274
274
|
**Best for:** Using Claude.ai, v0, Replit, or Lovable to create and modify Figma designs — no Node.js required.
|
|
275
275
|
|
|
276
|
-
**What you get:**
|
|
276
|
+
**What you get:** 102 tools including full write access — design creation, variable management, component instantiation, and all REST API tools. Only real-time monitoring (console logs, selection tracking, document changes) requires Local Mode.
|
|
277
277
|
|
|
278
278
|
#### Prerequisites
|
|
279
279
|
|
|
@@ -330,7 +330,7 @@ AI Client → Cloud MCP Server → Durable Object Relay → Desktop Bridge Plugi
|
|
|
330
330
|
| Feature | NPX (Recommended) | Cloud Mode | Local Git | Remote SSE |
|
|
331
331
|
|---------|-------------------|------------|-----------|------------|
|
|
332
332
|
| **Setup time** | ~10 minutes | ~5 minutes | ~15 minutes | ~2 minutes |
|
|
333
|
-
| **Total tools** | **
|
|
333
|
+
| **Total tools** | **127** | **102** after pairing | **127** (Local Git) | Read-only subset |
|
|
334
334
|
| **Design creation** | ✅ | ✅ | ✅ | ❌ |
|
|
335
335
|
| **Variable management** | ✅ | ✅ | ✅ | ❌ |
|
|
336
336
|
| **Component instantiation** | ✅ | ✅ | ✅ | ❌ |
|
|
@@ -345,7 +345,7 @@ AI Client → Cloud MCP Server → Durable Object Relay → Desktop Bridge Plugi
|
|
|
345
345
|
| **Automatic updates** | ✅ (`@latest`) | ✅ | Manual (`git pull`) | ✅ |
|
|
346
346
|
| **Source code access** | ❌ | ❌ | ✅ | ❌ |
|
|
347
347
|
|
|
348
|
-
> **Key insight:** Remote SSE is read-only. Cloud Mode adds write access for web AI clients without Node.js. NPX/Local Git give the full
|
|
348
|
+
> **Key insight:** Remote SSE is read-only. Cloud Mode adds write access for web AI clients without Node.js. NPX/Local Git give the full 127 tools.
|
|
349
349
|
|
|
350
350
|
**📖 [Complete Feature Comparison](docs/mode-comparison.md)**
|
|
351
351
|
|
|
@@ -472,6 +472,17 @@ When you first use design system tools:
|
|
|
472
472
|
- `figma_reset_slot` - Clear a slot's content on an instance
|
|
473
473
|
- `figma_add_slot_property` - Retrofit an existing frame as a slot via a manual SLOT property binding, with `description` and `preferredValues`
|
|
474
474
|
|
|
475
|
+
### 🎬 Motion (Local Mode + Cloud Mode)
|
|
476
|
+
Figma Motion (Plugin API beta). Animations play in Figma's preview and in video export, not in static screenshots.
|
|
477
|
+
- `figma_get_animations` - Read a layer's animation styles, keyframe tracks and timeline, with CSS easings and token bindings
|
|
478
|
+
- `figma_apply_animation` - **Animate a layer** with a Figma preset (Opacity, Scale, Position, Rotation, Size, Path, TextStagger), a custom animation style, or manual keyframes for any animatable property, paint color or effect. Easing and duration can bind to EASING/TIMING variables
|
|
479
|
+
- `figma_remove_animation` - Remove one animation style, one keyframe track, or everything
|
|
480
|
+
- `figma_manage_animation_styles` - **Build reusable motion styles**: list Figma's presets and their options, and create, update or delete custom animation styles
|
|
481
|
+
- `figma_export_animation` - Export an animated frame as MP4, GIF or WebM
|
|
482
|
+
|
|
483
|
+
### 🧱 Code Layers (Local Mode + Cloud Mode)
|
|
484
|
+
- `figma_get_code_layers` - Find Figma code layers on a page or across the file, with position, size and linked dev resources. Figma's APIs don't expose code-layer source, so creating and editing them stays in Figma or Figma's own MCP (`send_code_to_figma`)
|
|
485
|
+
|
|
475
486
|
### 🔍 Design-Code Parity (All Modes)
|
|
476
487
|
- `figma_check_design_parity` - Compare Figma component specs against code implementation, producing a scored diff report with actionable fix items
|
|
477
488
|
- `figma_generate_component_doc` - Generate platform-agnostic markdown documentation by merging Figma design data with code-side info; the optional `history` parameter adds a changelog from Figma version history and `git log`
|
|
@@ -750,7 +761,7 @@ The **Figma Desktop Bridge** plugin is the recommended way to connect Figma to t
|
|
|
750
761
|
- The MCP server communicates via **WebSocket** through the Desktop Bridge plugin
|
|
751
762
|
- The server tries port 9223 first, then automatically falls back through ports 9224–9232 if needed
|
|
752
763
|
- The plugin scans all ports in the range and connects to every active server it finds
|
|
753
|
-
- All
|
|
764
|
+
- All 127 tools work through the WebSocket transport
|
|
754
765
|
|
|
755
766
|
**Multiple files:** The WebSocket server supports multiple simultaneous plugin connections — one per open Figma file. Each connection is tracked by file key with independent state (selection, document changes, console logs).
|
|
756
767
|
|
|
@@ -893,7 +904,7 @@ The architecture supports adding new apps with minimal boilerplate — each app
|
|
|
893
904
|
|
|
894
905
|
The two servers are complementary, and both can run in the same MCP client.
|
|
895
906
|
|
|
896
|
-
**Figma's official MCP server** is hosted by Figma. It focuses on design-to-code context (`get_design_context`), Code Connect, library search, and creating content in Figma: it writes through `use_figma`, creates files, generates FigJam diagrams, and works with
|
|
907
|
+
**Figma's official MCP server** is hosted by Figma. It focuses on design-to-code context (`get_design_context`), Code Connect, library search, and creating content in Figma: it writes through `use_figma`, creates files, generates FigJam diagrams, generates code layers, and works with shaders.
|
|
897
908
|
|
|
898
909
|
**Figma Console MCP** focuses on design-system operations:
|
|
899
910
|
- Deterministic checks: design-code parity, accessibility (canvas and code), and design-system health
|
|
@@ -909,9 +920,11 @@ The two servers are complementary, and both can run in the same MCP client.
|
|
|
909
920
|
|
|
910
921
|
## 🛤️ Roadmap
|
|
911
922
|
|
|
912
|
-
**Current Status:** v1.44.1 (Stable) - Production-ready. Latest: Cloud Mode accepts personal access tokens without the Current user scope, 403 errors name the missing scope, and setup guides for Codex, Gemini CLI and Antigravity (server-only). On top of v1.44.0's opt-in Streamable HTTP endpoint for Local Mode (`FIGMA_MCP_HTTP_PORT`, loopback only, optional bearer token) so several local clients share one server and its Figma connection (server-only). On top of v1.43.0's `@modelcontextprotocol/sdk` 1.32.1 and `zod` 4 clear all seven production security advisories, with tool behavior unchanged and Gemini-safe schemas (server-only). On top of v1.42.1's commands to a plugin stuck on a timed-out script fail fast with a busy message instead of queuing behind it, port-exhaustion eviction ends the least recently used server instead of the oldest, and `figma_execute` accepts up to a 300 s timeout (server-only). On top of v1.42.0's `figma_get_comments` returning compact threads (root + replies, newest activity first) with `node_id`, `thread_id` and `since` filters and `limit`/`offset` paging, 30 threads by default; summary counts are per thread (server-only, PR #139). On top of v1.41.5's component-set analysis reporting gradient/image/paint-opacity, corner radius, typography and label text, swapped spacing tokens, nested layer geometry and vector shape changes (re-import the plugin). On top of v1.41.4's variant background/stroke and auto-layout changes. On top of v1.41.3's component-set analysis reporting changes inside nested layers (instance swaps, nested token changes, opacity on the variant itself) and no longer reports a layer hidden in every variant as a change (re-import the plugin). On top of v1.41.2's design-system summary and `figma_get_token_values` report the file's tokens (they always reported 0) (server-only). On top of v1.41.1's component-set analysis reports real variant differences (Figma's default variant, size and layer changes), component loading no longer times out on large files (throttled plugin timers), relevance-ranked component search, and `figma_get_variables` paging that works with `format: "full"` (re-import the plugin for the component fixes). On top of v1.41.0's Cloud Mode sign-in hardening (per-session tokens on `/sse`, single-use authorization codes bound to client, redirect URI and PKCE, a consent page for unrecognized destinations), a script-execution fix in the accessibility scanner, `figma_import_tokens` refusing empty imports and scoping `replace` deletes to imported collections, `figma_arrange_component_set` no longer deleting other arranged sets, live variable reads for token export/import, Windows orphan-server exit (PR #140), and `fileKey` for the Slots tools (PR #112) (server-only, no plugin re-import). On top of v1.40.9's composed colors (a color variable set to another color at an opacity, "grey/900 at 50%") export and import with the link to the primitive intact — `color-mix()` in CSS/Tailwind v4, `rgba()` in SCSS, an alpha modifier in Tokens Studio, the resolved color plus the composition in DTCG — where the export previously failed or wrote `[object Object]` (server-only, no plugin re-import). On top of v1.40.8's min/max width and height survive every way of extracting a component as JSON — the design system kit, the reconstruction format and `figma_get_file_data` now carry them, design-code parity compares them, and the reconstruction format returns real geometry again instead of 50×50 placeholders when the plugin is connected (server-only, no plugin re-import). On top of v1.40.7's clearer Color Tokens table in generated docs — layers revealed by a boolean property are printed once under that property, and stroke/fill rows name the nested instance they belong to (server-only, no plugin re-import). On top of v1.40.6's overrides in extended variable collections are visible (previously reported as nonexistent), and a third round of generated-doc fidelity fixes — radius tokens read per corner, boolean props compared in Design-Code Parity, source links pinned to a commit, hidden layers linked to the property that shows them (server-only, no plugin re-import). On top of v1.40.5's clean dependency audit for the npm package — Worker-only dependencies (`@cloudflare/puppeteer`, which pulled in a high-severity `extract-zip` advisory with no upstream fix, and `agents`) no longer install for npm users, so `npm install figma-console-mcp` audits at 0 vulnerabilities and is 64 MB instead of 173 MB; the server also reports its real version to MCP clients instead of `0.1.0` (server-only, no plugin re-import). On top of v1.40.4's fixes found by live-testing v1.40.3 on hard production components — tools given a `fileUrl` now read variables, descriptions and annotations from THAT file rather than whichever file is active (previously every token name could vanish, or on an id collision come from the wrong file; `figma_get_component` could return a different component), a tool result over 16 MB no longer disconnects the server, anatomy labels sizing by the layout's real axes, and the icon/typography/anatomy output stays readable on large components (server-only, no plugin re-import). On top of v1.40.3's fidelity fixes for generated component docs on harder components — hidden layers are labeled instead of documented as rendered, one-sided borders report the weight that actually renders, typography and layer structure are compared across every variant instead of read from the first, gradients/shadows/opacity are no longer silently dropped, truncated trees say so, and `SLOT` properties are listed (server-only, no plugin re-import). On top of v1.40.2's data-loss fix for `figma_export_tokens` — with a different file active in Figma than intended, an export could replace a real token file with an empty one (or with another file's tokens) and report success; exports now refuse to write when a requested collection is missing, when the export is empty, when the target was generated from a different Figma file, or when overwriting would destroy tokens the export doesn't manage, and `strategy: "merge"` — documented as preserving code-only tokens but never implemented — is now a genuinely safe default (server-only, no plugin re-import). On top of v1.40.1's accuracy fixes for generated component docs across variants — a descendant's fill (typically an icon's) could be documented as a variant's Background, Color Token headings kept only a property literally named `Variant`, spacing was read from the first variant alone, and icons were only detected by layer name — plus `figma_export_tokens` accepting a file path as `outputPath` instead of failing with a raw `EEXIST` or silently creating a directory (server-only, no plugin re-import). On top of v1.40.0's design system extraction from production codebases — seven Local-Mode `figma_ds_*` tools that scan one or more apps (framework/styling/vendor detection, usage-ranked component inventory classified vendored/wrapped/pure-vendor/bespoke, variant inference from real call sites, duplicate detection, and an architecture pass separating UI-kit specializations from the missing generic primitives), mine the de-facto styling into DTCG tokens with per-token provenance (multi-mode CSS custom properties, SCSS, Tailwind config, shadcn HSL triples, utility-class frequency mining valued from the app's own theme), scaffold the design-system package with showcase docs pages, wire a fresh Storybook workshop to the app's real theme layers and fonts, deep-extract components for porting with CSF3 story scaffolds, verify with deterministic fidelity evals, and persist porting progress across sessions — the extracted tokens import straight into Figma variables via `figma_import_tokens`. On top of v1.39.1's fix for a plugin-update banner that could never be cleared — an older server instance nagging a newer plugin to re-import, which only ever installs the same or a newer plugin. On top of v1.39.0's multi-file execution — `figma_execute_across_files` runs one script against several Desktop Bridge-connected files concurrently (four files x 2s of work in ~3s, not ~8s), and `figma_execute` takes an optional `fileKey` to target a single file without moving the active file or releasing target lock; targeting must be explicit (`fileKeys` or `allFiles: true`), so nothing fans out to files you did not name. From community PR #107 by @Wolfr. Ships with a relay fix: `handleResult()` in the plugin's ui.html rebuilt each response field by field and silently dropped `resultAnalysis` and `fileContext`, so the `resultAnalysis.warning` check that `figma_execute`'s own description tells callers to perform has never been possible (re-import `manifest.json` for those two fields; everything else works without it). On top of v1.38.2's connection-stability fix — the server's own orphan reaper was terminating healthy MCP servers because its liveness probe used an IPv4 literal while the server binds the IPv6 loopback, which turned every kill-safety gate into a rubber stamp; this was the cause of recurring "Server disconnected" errors across all MCP clients. Alongside v1.38.1's fix for the shared-library variable tools, which had silently reported zero collections since v1.29.0 and reported failed imports as successes. On top of v1.38.0's ongoing component changelogs in generated docs — `figma_generate_component_doc` takes an opt-in `history` parameter that pulls per-component **design history** from Figma version history (each version diffed and scoped to that component, so renames, added properties, and token bindings show up as rows) alongside **code history** from `git log` on the component's source files, rendered as a `## History` section with design, code, and release-note tables. Prefers labeled versions, falls back to auto-saves when a file has none, and is off by default so existing calls are unchanged (server-only, no plugin re-import). On top of v1.37.x's design-system health audit for every client — `figma_audit_design_system_report` runs the dashboard's deterministic six-category scoring engine and returns the report as data with per-finding remediation, live-first fileKey-verified data (source disclosed), chunked per-category drill-down, and a 5-minute cache (server-only, no plugin re-import). On top of v1.36.0's target lock for multi-file parallel work — — `figma_navigate` takes a `lock: true` flag that pins the active file so an AI agent can work in one file while you work in another without commands routing to the wrong file. On top of v1.35.0's Figma Slots write support — create, inspect, populate, and reset Slots (GA at Config 2026) via 5 new tools (`figma_create_slot`, `figma_get_slots`, `figma_append_to_slot`, `figma_reset_slot`, `figma_add_slot_property`), live-validated against the GA Plugin API and based on community PR #77. On top of v1.34.0's Bidirectional Token Sync v2 + DTCG 2025.10 — `figma_import_tokens` applies the complete diff plan (creates missing collections/variables, applies renames, writes real `VARIABLE_ALIAS` references, and deletes only under explicit `replace`), `figma_export_tokens` speaks the DTCG 2025.10 dialect on request (legacy default byte-identical), variable scopes/codeSyntax round-trip via `$extensions`, `figma_setup_design_tokens` accepts alias values via DTCG brace references, and `figma_create_component_set` builds a full variant set from an axes matrix in one call. On top of the v1.33.x line: version-handshake fix (re-import banner only fires when plugin files actually changed), security dependency sweep, and the v1.33.0 connection UX overhaul (honest status pill derived from live connection state, `/health` auto-discovery with self-healing reconnect) + a 33-fix full-codebase audit (lossless DTCG multi-mode round-trips, cross-collection alias resolution, branch-URL correctness across REST tools, cache-poisoning and CSWSH fixes, bridge-first screenshots). Built on WCAG-accurate accessibility auditing (line height below 1.5× is no longer mis-flagged as a failure; readability hints decoupled from conformance checks and scoped to multi-line text; code-side WCAG 1.4.12 check), a self-healing Desktop Bridge connection (zombie-process reaper + auto-reconnect watchdog — fixes the recurring "not connected until restart" bug), native variable binding on fills/strokes + typography control in the write tools, shared-library inspection (key-based component resolution + library variable read/import without Enterprise plan), 10-format token export pipeline (DTCG, CSS, Tailwind v4, Tailwind v3, SCSS, TS module, JSON flat/nested, Style Dictionary v3, Tokens Studio), bidirectional Figma↔code token sync, version history & time-series awareness, FigJam + Slides support, Cloud Write Relay, Design System Kit, WebSocket-only connectivity, smart multi-file tracking, **121 tools** (Local) / **96 tools** (Cloud) / read-only subset (Remote), Comments API, cross-MCP identity disambiguation, and MCP Apps.
|
|
923
|
+
**Current Status:** v1.45.0 (Stable) - Production-ready. Latest: Motion tools — apply, read, remove and export Figma Motion animations, manage custom animation styles, write Timing and Easing variables from token files, and find code layers (server-only). On top of v1.44.2's Cloud sign-in requests `library_assets:read`, so component lookups by key work over OAuth (server-only). On top of v1.44.1's Cloud Mode accepting personal access tokens without the Current user scope, 403 errors name the missing scope, and setup guides for Codex, Gemini CLI and Antigravity (server-only). On top of v1.44.0's opt-in Streamable HTTP endpoint for Local Mode (`FIGMA_MCP_HTTP_PORT`, loopback only, optional bearer token) so several local clients share one server and its Figma connection (server-only). On top of v1.43.0's `@modelcontextprotocol/sdk` 1.32.1 and `zod` 4 clear all seven production security advisories, with tool behavior unchanged and Gemini-safe schemas (server-only). On top of v1.42.1's commands to a plugin stuck on a timed-out script fail fast with a busy message instead of queuing behind it, port-exhaustion eviction ends the least recently used server instead of the oldest, and `figma_execute` accepts up to a 300 s timeout (server-only). On top of v1.42.0's `figma_get_comments` returning compact threads (root + replies, newest activity first) with `node_id`, `thread_id` and `since` filters and `limit`/`offset` paging, 30 threads by default; summary counts are per thread (server-only, PR #139). On top of v1.41.5's component-set analysis reporting gradient/image/paint-opacity, corner radius, typography and label text, swapped spacing tokens, nested layer geometry and vector shape changes (re-import the plugin). On top of v1.41.4's variant background/stroke and auto-layout changes. On top of v1.41.3's component-set analysis reporting changes inside nested layers (instance swaps, nested token changes, opacity on the variant itself) and no longer reports a layer hidden in every variant as a change (re-import the plugin). On top of v1.41.2's design-system summary and `figma_get_token_values` report the file's tokens (they always reported 0) (server-only). On top of v1.41.1's component-set analysis reports real variant differences (Figma's default variant, size and layer changes), component loading no longer times out on large files (throttled plugin timers), relevance-ranked component search, and `figma_get_variables` paging that works with `format: "full"` (re-import the plugin for the component fixes). On top of v1.41.0's Cloud Mode sign-in hardening (per-session tokens on `/sse`, single-use authorization codes bound to client, redirect URI and PKCE, a consent page for unrecognized destinations), a script-execution fix in the accessibility scanner, `figma_import_tokens` refusing empty imports and scoping `replace` deletes to imported collections, `figma_arrange_component_set` no longer deleting other arranged sets, live variable reads for token export/import, Windows orphan-server exit (PR #140), and `fileKey` for the Slots tools (PR #112) (server-only, no plugin re-import). On top of v1.40.9's composed colors (a color variable set to another color at an opacity, "grey/900 at 50%") export and import with the link to the primitive intact — `color-mix()` in CSS/Tailwind v4, `rgba()` in SCSS, an alpha modifier in Tokens Studio, the resolved color plus the composition in DTCG — where the export previously failed or wrote `[object Object]` (server-only, no plugin re-import). On top of v1.40.8's min/max width and height survive every way of extracting a component as JSON — the design system kit, the reconstruction format and `figma_get_file_data` now carry them, design-code parity compares them, and the reconstruction format returns real geometry again instead of 50×50 placeholders when the plugin is connected (server-only, no plugin re-import). On top of v1.40.7's clearer Color Tokens table in generated docs — layers revealed by a boolean property are printed once under that property, and stroke/fill rows name the nested instance they belong to (server-only, no plugin re-import). On top of v1.40.6's overrides in extended variable collections are visible (previously reported as nonexistent), and a third round of generated-doc fidelity fixes — radius tokens read per corner, boolean props compared in Design-Code Parity, source links pinned to a commit, hidden layers linked to the property that shows them (server-only, no plugin re-import). On top of v1.40.5's clean dependency audit for the npm package — Worker-only dependencies (`@cloudflare/puppeteer`, which pulled in a high-severity `extract-zip` advisory with no upstream fix, and `agents`) no longer install for npm users, so `npm install figma-console-mcp` audits at 0 vulnerabilities and is 64 MB instead of 173 MB; the server also reports its real version to MCP clients instead of `0.1.0` (server-only, no plugin re-import). On top of v1.40.4's fixes found by live-testing v1.40.3 on hard production components — tools given a `fileUrl` now read variables, descriptions and annotations from THAT file rather than whichever file is active (previously every token name could vanish, or on an id collision come from the wrong file; `figma_get_component` could return a different component), a tool result over 16 MB no longer disconnects the server, anatomy labels sizing by the layout's real axes, and the icon/typography/anatomy output stays readable on large components (server-only, no plugin re-import). On top of v1.40.3's fidelity fixes for generated component docs on harder components — hidden layers are labeled instead of documented as rendered, one-sided borders report the weight that actually renders, typography and layer structure are compared across every variant instead of read from the first, gradients/shadows/opacity are no longer silently dropped, truncated trees say so, and `SLOT` properties are listed (server-only, no plugin re-import). On top of v1.40.2's data-loss fix for `figma_export_tokens` — with a different file active in Figma than intended, an export could replace a real token file with an empty one (or with another file's tokens) and report success; exports now refuse to write when a requested collection is missing, when the export is empty, when the target was generated from a different Figma file, or when overwriting would destroy tokens the export doesn't manage, and `strategy: "merge"` — documented as preserving code-only tokens but never implemented — is now a genuinely safe default (server-only, no plugin re-import). On top of v1.40.1's accuracy fixes for generated component docs across variants — a descendant's fill (typically an icon's) could be documented as a variant's Background, Color Token headings kept only a property literally named `Variant`, spacing was read from the first variant alone, and icons were only detected by layer name — plus `figma_export_tokens` accepting a file path as `outputPath` instead of failing with a raw `EEXIST` or silently creating a directory (server-only, no plugin re-import). On top of v1.40.0's design system extraction from production codebases — seven Local-Mode `figma_ds_*` tools that scan one or more apps (framework/styling/vendor detection, usage-ranked component inventory classified vendored/wrapped/pure-vendor/bespoke, variant inference from real call sites, duplicate detection, and an architecture pass separating UI-kit specializations from the missing generic primitives), mine the de-facto styling into DTCG tokens with per-token provenance (multi-mode CSS custom properties, SCSS, Tailwind config, shadcn HSL triples, utility-class frequency mining valued from the app's own theme), scaffold the design-system package with showcase docs pages, wire a fresh Storybook workshop to the app's real theme layers and fonts, deep-extract components for porting with CSF3 story scaffolds, verify with deterministic fidelity evals, and persist porting progress across sessions — the extracted tokens import straight into Figma variables via `figma_import_tokens`. On top of v1.39.1's fix for a plugin-update banner that could never be cleared — an older server instance nagging a newer plugin to re-import, which only ever installs the same or a newer plugin. On top of v1.39.0's multi-file execution — `figma_execute_across_files` runs one script against several Desktop Bridge-connected files concurrently (four files x 2s of work in ~3s, not ~8s), and `figma_execute` takes an optional `fileKey` to target a single file without moving the active file or releasing target lock; targeting must be explicit (`fileKeys` or `allFiles: true`), so nothing fans out to files you did not name. From community PR #107 by @Wolfr. Ships with a relay fix: `handleResult()` in the plugin's ui.html rebuilt each response field by field and silently dropped `resultAnalysis` and `fileContext`, so the `resultAnalysis.warning` check that `figma_execute`'s own description tells callers to perform has never been possible (re-import `manifest.json` for those two fields; everything else works without it). On top of v1.38.2's connection-stability fix — the server's own orphan reaper was terminating healthy MCP servers because its liveness probe used an IPv4 literal while the server binds the IPv6 loopback, which turned every kill-safety gate into a rubber stamp; this was the cause of recurring "Server disconnected" errors across all MCP clients. Alongside v1.38.1's fix for the shared-library variable tools, which had silently reported zero collections since v1.29.0 and reported failed imports as successes. On top of v1.38.0's ongoing component changelogs in generated docs — `figma_generate_component_doc` takes an opt-in `history` parameter that pulls per-component **design history** from Figma version history (each version diffed and scoped to that component, so renames, added properties, and token bindings show up as rows) alongside **code history** from `git log` on the component's source files, rendered as a `## History` section with design, code, and release-note tables. Prefers labeled versions, falls back to auto-saves when a file has none, and is off by default so existing calls are unchanged (server-only, no plugin re-import). On top of v1.37.x's design-system health audit for every client — `figma_audit_design_system_report` runs the dashboard's deterministic six-category scoring engine and returns the report as data with per-finding remediation, live-first fileKey-verified data (source disclosed), chunked per-category drill-down, and a 5-minute cache (server-only, no plugin re-import). On top of v1.36.0's target lock for multi-file parallel work — — `figma_navigate` takes a `lock: true` flag that pins the active file so an AI agent can work in one file while you work in another without commands routing to the wrong file. On top of v1.35.0's Figma Slots write support — create, inspect, populate, and reset Slots (GA at Config 2026) via 5 new tools (`figma_create_slot`, `figma_get_slots`, `figma_append_to_slot`, `figma_reset_slot`, `figma_add_slot_property`), live-validated against the GA Plugin API and based on community PR #77. On top of v1.34.0's Bidirectional Token Sync v2 + DTCG 2025.10 — `figma_import_tokens` applies the complete diff plan (creates missing collections/variables, applies renames, writes real `VARIABLE_ALIAS` references, and deletes only under explicit `replace`), `figma_export_tokens` speaks the DTCG 2025.10 dialect on request (legacy default byte-identical), variable scopes/codeSyntax round-trip via `$extensions`, `figma_setup_design_tokens` accepts alias values via DTCG brace references, and `figma_create_component_set` builds a full variant set from an axes matrix in one call. On top of the v1.33.x line: version-handshake fix (re-import banner only fires when plugin files actually changed), security dependency sweep, and the v1.33.0 connection UX overhaul (honest status pill derived from live connection state, `/health` auto-discovery with self-healing reconnect) + a 33-fix full-codebase audit (lossless DTCG multi-mode round-trips, cross-collection alias resolution, branch-URL correctness across REST tools, cache-poisoning and CSWSH fixes, bridge-first screenshots). Built on WCAG-accurate accessibility auditing (line height below 1.5× is no longer mis-flagged as a failure; readability hints decoupled from conformance checks and scoped to multi-line text; code-side WCAG 1.4.12 check), a self-healing Desktop Bridge connection (zombie-process reaper + auto-reconnect watchdog — fixes the recurring "not connected until restart" bug), native variable binding on fills/strokes + typography control in the write tools, shared-library inspection (key-based component resolution + library variable read/import without Enterprise plan), 10-format token export pipeline (DTCG, CSS, Tailwind v4, Tailwind v3, SCSS, TS module, JSON flat/nested, Style Dictionary v3, Tokens Studio), bidirectional Figma↔code token sync, version history & time-series awareness, FigJam + Slides support, Cloud Write Relay, Design System Kit, WebSocket-only connectivity, smart multi-file tracking, **127 tools** (Local) / **102 tools** (Cloud) / read-only subset (Remote), Comments API, cross-MCP identity disambiguation, and MCP Apps.
|
|
913
924
|
|
|
914
925
|
**Recent Releases:**
|
|
926
|
+
- [x] **v1.45.0** - Motion tools (apply, read, remove, export MP4/GIF/WebM, custom animation styles), Timing/Easing token import and writes, easing export fix, and `figma_get_code_layers` (#147). Server-only.
|
|
927
|
+
- [x] **v1.44.2** - Cloud sign-in requests `library_assets:read`; component lookups by key work over OAuth. Server-only.
|
|
915
928
|
- [x] **v1.44.1** - Cloud Mode accepts PATs without `current_user:read`; 403s name the missing scope; complete token scopes and Codex/Gemini CLI/Antigravity setup. Server-only.
|
|
916
929
|
- [x] **v1.44.0** - Opt-in Streamable HTTP endpoint for Local Mode (`FIGMA_MCP_HTTP_PORT`) so local clients can share one server (#48). Server-only.
|
|
917
930
|
- [x] **v1.43.0** - `@modelcontextprotocol/sdk` 1.32.1 and `zod` 4: 0 production advisories (#141). Server-only.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code layer discovery (Figma code layers, open beta Oct 2026).
|
|
3
|
+
*
|
|
4
|
+
* Code layers are React components rendered on the canvas. The Plugin API
|
|
5
|
+
* exposes them as `CODE_INSTANCE` nodes with layout, export, dev resources
|
|
6
|
+
* and related links, but not their source or props, and neither the Plugin
|
|
7
|
+
* API nor REST can create one. Creating and editing code layers goes
|
|
8
|
+
* through Figma (UI, GitHub import, or Figma's own MCP `send_code_to_figma`).
|
|
9
|
+
* This tool finds them so agents can screenshot, position, or document them.
|
|
10
|
+
*/
|
|
11
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
12
|
+
export declare const GET_CODE_LAYERS_SCRIPT: (scope: "page" | "file", limit: number) => string;
|
|
13
|
+
export declare function registerCodeLayerTools(server: McpServer, getDesktopConnector: () => Promise<any>): void;
|
|
14
|
+
//# sourceMappingURL=code-layer-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-layer-tools.d.ts","sourceRoot":"","sources":["../../src/core/code-layer-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,eAAO,MAAM,sBAAsB,GAAI,OAAO,MAAM,GAAG,MAAM,EAAE,OAAO,MAAM,WAiB3E,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CA2BvG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code layer discovery (Figma code layers, open beta Oct 2026).
|
|
3
|
+
*
|
|
4
|
+
* Code layers are React components rendered on the canvas. The Plugin API
|
|
5
|
+
* exposes them as `CODE_INSTANCE` nodes with layout, export, dev resources
|
|
6
|
+
* and related links, but not their source or props, and neither the Plugin
|
|
7
|
+
* API nor REST can create one. Creating and editing code layers goes
|
|
8
|
+
* through Figma (UI, GitHub import, or Figma's own MCP `send_code_to_figma`).
|
|
9
|
+
* This tool finds them so agents can screenshot, position, or document them.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { createChildLogger } from "./logger.js";
|
|
13
|
+
const logger = createChildLogger({ component: "code-layer-tools" });
|
|
14
|
+
export const GET_CODE_LAYERS_SCRIPT = (scope, limit) => `
|
|
15
|
+
const limit = ${JSON.stringify(limit)};
|
|
16
|
+
const pages = ${JSON.stringify(scope)} === 'file' ? figma.root.children : [figma.currentPage];
|
|
17
|
+
const layers = [];
|
|
18
|
+
let truncated = false;
|
|
19
|
+
for (const page of pages) {
|
|
20
|
+
if (page !== figma.currentPage) await page.loadAsync();
|
|
21
|
+
for (const n of page.findAll(x => x.type === 'CODE_INSTANCE')) {
|
|
22
|
+
if (layers.length >= limit) { truncated = true; break; }
|
|
23
|
+
const item = { id: n.id, name: n.name, page: page.name, pageId: page.id, x: n.x, y: n.y, width: n.width, height: n.height, visible: n.visible, locked: n.locked, parent: n.parent ? { id: n.parent.id, type: n.parent.type } : null };
|
|
24
|
+
try { item.devResources = (await n.getDevResourcesAsync()).map(r => ({ name: r.name, url: r.url })); } catch (e) {}
|
|
25
|
+
try { item.relatedLinks = (await n.getRelatedLinksAsync()).map(r => ({ name: r.name, url: r.url })); } catch (e) {}
|
|
26
|
+
layers.push(item);
|
|
27
|
+
}
|
|
28
|
+
if (truncated) break;
|
|
29
|
+
}
|
|
30
|
+
return { scope: ${JSON.stringify(scope)}, count: layers.length, truncated, codeLayers: layers };
|
|
31
|
+
`;
|
|
32
|
+
export function registerCodeLayerTools(server, getDesktopConnector) {
|
|
33
|
+
server.tool("figma_get_code_layers", "Find code layers (Figma's React code layers, node type CODE_INSTANCE) on the current page or across the file, with position, size, page, and any dev resources or related links (e.g. the GitHub source). The Plugin API and REST API expose code layers as rendered layers only: their source and props can't be read or edited, and new code layers can't be created through them. Create or edit code layers in Figma, through a GitHub import, or with Figma's own MCP server (send_code_to_figma). Use figma_capture_screenshot with a code layer's id to see it. Requires Desktop Bridge.", {
|
|
34
|
+
scope: z.enum(["page", "file"]).optional().default("page").describe("Search the current page (default) or every page"),
|
|
35
|
+
limit: z.number().int().min(1).max(500).optional().default(100),
|
|
36
|
+
fileKey: z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("Local Mode only. Run against this connected file instead of the active file. Rejected in Cloud Mode."),
|
|
40
|
+
}, async ({ scope, limit, fileKey }) => {
|
|
41
|
+
try {
|
|
42
|
+
const connector = await getDesktopConnector();
|
|
43
|
+
const result = await connector.executeCodeViaUI(GET_CODE_LAYERS_SCRIPT(scope, limit), scope === "file" ? 120000 : 30000, fileKey);
|
|
44
|
+
if (!result?.success)
|
|
45
|
+
throw new Error(result?.error || "Failed to list code layers");
|
|
46
|
+
return { content: [{ type: "text", text: JSON.stringify(result.result) }] };
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
logger.error({ error }, "figma_get_code_layers failed");
|
|
50
|
+
return {
|
|
51
|
+
content: [{ type: "text", text: JSON.stringify({ error: error instanceof Error ? error.message : String(error) }) }],
|
|
52
|
+
isError: true,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=code-layer-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-layer-tools.js","sourceRoot":"","sources":["../../src/core/code-layer-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAEpE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAsB,EAAE,KAAa,EAAE,EAAE,CAAC;gBACjE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;gBACrB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;;;kBAcnB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;CACtC,CAAC;AAEF,MAAM,UAAU,sBAAsB,CAAC,MAAiB,EAAE,mBAAuC;IAChG,MAAM,CAAC,IAAI,CACV,uBAAuB,EACvB,ikBAAikB,EACjkB;QACC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,iDAAiD,CAAC;QACtH,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC;QAC/D,OAAO,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,sGAAsG,CAAC;KAClH,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;QACnC,IAAI,CAAC;YACJ,MAAM,SAAS,GAAG,MAAM,mBAAmB,EAAE,CAAC;YAC9C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAClI,IAAI,CAAC,MAAM,EAAE,OAAO;gBAAE,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,KAAK,IAAI,4BAA4B,CAAC,CAAC;YACrF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;QACtF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,8BAA8B,CAAC,CAAC;YACxD,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC7H,OAAO,EAAE,IAAI;aACb,CAAC;QACH,CAAC;IACF,CAAC,CACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Figma Motion tools (Plugin API Motion, beta: Updates 130–140).
|
|
3
|
+
*
|
|
4
|
+
* Read and write animation styles (Figma presets and local custom styles),
|
|
5
|
+
* manual keyframe tracks, and export animated frames as MP4/GIF/WebM.
|
|
6
|
+
* Easing and duration can be bound to EASING/TIMING variables.
|
|
7
|
+
*
|
|
8
|
+
* Every tool builds a Plugin API script here and runs it through
|
|
9
|
+
* executeCodeViaUI, so no Desktop Bridge plugin change (or re-import) is
|
|
10
|
+
* needed. Each script checks the API exists first, so an older Figma Desktop
|
|
11
|
+
* gets a clear message instead of a TypeError.
|
|
12
|
+
*/
|
|
13
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
|
+
export declare const EASING_TYPES: readonly ["EASE_IN", "EASE_OUT", "EASE_IN_AND_OUT", "LINEAR", "EASE_IN_BACK", "EASE_OUT_BACK", "EASE_IN_AND_OUT_BACK", "CUSTOM_CUBIC_BEZIER", "GENTLE", "QUICK", "BOUNCY", "SLOW", "CUSTOM_SPRING", "HOLD"];
|
|
15
|
+
export declare const KEYFRAME_PROPERTIES: readonly ["OPACITY", "TRANSLATION_X", "TRANSLATION_Y", "TRANSLATION_XY", "ROTATION", "SCALE_X", "SCALE_Y", "SCALE_XY", "WIDTH", "HEIGHT", "CORNER_RADIUS", "RECTANGLE_TOP_LEFT_CORNER_RADIUS", "RECTANGLE_TOP_RIGHT_CORNER_RADIUS", "RECTANGLE_BOTTOM_LEFT_CORNER_RADIUS", "RECTANGLE_BOTTOM_RIGHT_CORNER_RADIUS", "STROKE_WEIGHT", "BORDER_TOP_WEIGHT", "BORDER_BOTTOM_WEIGHT", "BORDER_LEFT_WEIGHT", "BORDER_RIGHT_WEIGHT", "STACK_SPACING", "STACK_COUNTER_SPACING", "STACK_PADDING_LEFT", "STACK_PADDING_TOP", "STACK_PADDING_RIGHT", "STACK_PADDING_BOTTOM", "GRID_ROW_GAP", "GRID_COLUMN_GAP", "PATH_TRIM_START", "PATH_TRIM_END"];
|
|
16
|
+
export declare const EFFECT_KEYFRAME_FIELDS: readonly ["OFFSET_X", "OFFSET_Y", "RADIUS", "SPREAD", "COLOR", "SECONDARY_COLOR", "EFFECT_OPACITY", "REFRACTION_RADIUS", "REFRACTION_INTENSITY", "SPECULAR_ANGLE", "SPECULAR_INTENSITY", "CHROMATIC_ABERRATION", "SPLAY", "START_RADIUS", "NOISE_SIZE_X", "NOISE_SIZE_Y", "DENSITY"];
|
|
17
|
+
/** Inline (base64) exports above this many bytes must be written to disk instead. */
|
|
18
|
+
export declare const MAX_INLINE_EXPORT_BYTES: number;
|
|
19
|
+
/**
|
|
20
|
+
* Plugin-side helpers shared by every motion script: availability check,
|
|
21
|
+
* easing/value conversion in both directions, and a normalized read of a
|
|
22
|
+
* node's animations. Kept as one string so each script is self-contained.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MOTION_HELPERS = "\nconst MOTION_UNAVAILABLE = 'The Figma Motion API is not available in this Figma Desktop. Update Figma Desktop (Motion shipped in Plugin API Update 130, June 2026).';\nfunction assertMotion(node) {\n if (typeof figma.motion === 'undefined' || (node && typeof node.applyAnimationStyle !== 'function')) {\n throw new Error(MOTION_UNAVAILABLE);\n }\n}\nasync function getTarget(id) {\n const node = id ? await figma.getNodeByIdAsync(id) : figma.currentPage.selection[0];\n if (!node) throw new Error(id ? 'Node not found: ' + id : 'No nodeId given and nothing is selected');\n if (!('animationStyles' in node)) throw new Error('Node ' + node.id + ' (' + node.type + ') cannot be animated');\n return node;\n}\nfunction assertWritable(node) {\n if (node.type === 'COMPONENT' || node.type === 'COMPONENT_SET') {\n throw new Error('Figma does not allow writing animations to a main component through the Plugin API. Apply them to an instance or a frame instead.');\n }\n}\nasync function toEasing(e) {\n if (!e) return undefined;\n if (e.variableId) {\n const v = await figma.variables.getVariableByIdAsync(e.variableId);\n if (!v) throw new Error('EASING variable not found: ' + e.variableId);\n if (v.resolvedType !== 'EASING') throw new Error('Variable ' + v.name + ' is ' + v.resolvedType + ', not EASING');\n return figma.variables.createVariableAlias(v);\n }\n if (!e.type) throw new Error('easing needs a type or a variableId');\n const out = { type: e.type };\n if (e.type === 'CUSTOM_CUBIC_BEZIER') {\n if (!e.bezier) throw new Error('CUSTOM_CUBIC_BEZIER easing needs bezier {x1,y1,x2,y2}');\n out.easingFunctionCubicBezier = e.bezier;\n }\n if (e.type === 'CUSTOM_SPRING') out.easingFunctionSpring = { bounce: e.bounce === undefined ? 0.3 : e.bounce };\n return out;\n}\nasync function timingAlias(id) {\n const v = await figma.variables.getVariableByIdAsync(id);\n if (!v) throw new Error('TIMING variable not found: ' + id);\n if (v.resolvedType !== 'TIMING') throw new Error('Variable ' + v.name + ' is ' + v.resolvedType + ', not TIMING');\n return figma.variables.createVariableAlias(v);\n}\nfunction toKeyframeValue(v) {\n if (typeof v === 'number') return { type: 'FLOAT', value: v };\n if (v && typeof v === 'object' && 'r' in v) return { type: 'COLOR', value: { r: v.r, g: v.g, b: v.b, a: v.a === undefined ? 1 : v.a } };\n if (v && typeof v === 'object' && 'x' in v) return { type: 'VECTOR', value: { x: v.x, y: v.y } };\n throw new Error('Unsupported keyframe value: ' + JSON.stringify(v));\n}\nfunction toField(t) {\n const n = (t.property ? 1 : 0) + (t.paint ? 1 : 0) + (t.effect ? 1 : 0);\n if (n !== 1) throw new Error('Each keyframe track needs exactly one of property, paint or effect');\n if (t.property) return { type: 'PROPERTY', name: t.property };\n if (t.paint) return { type: 'INDEXED_ITEM', collection: t.paint.collection, index: t.paint.index };\n return { type: 'INDEXED_ITEM', collection: 'effects', index: t.effect.index, field: t.effect.field };\n}\nconst r3 = (n) => Math.round(n * 1000) / 1000;\nasync function readEasing(e) {\n if (!e) return undefined;\n if (e.type === 'VARIABLE_ALIAS') {\n const v = await figma.variables.getVariableByIdAsync(e.id);\n return { variableId: e.id, variableName: v ? v.name : undefined };\n }\n const out = { type: e.type };\n const b = e.easingFunctionCubicBezier;\n if (b) { out.bezier = { x1: r3(b.x1), y1: r3(b.y1), x2: r3(b.x2), y2: r3(b.y2) }; out.css = 'cubic-bezier(' + [b.x1, b.y1, b.x2, b.y2].map(r3).join(', ') + ')'; }\n if (e.easingFunctionSpring) out.bounce = r3(e.easingFunctionSpring.bounce);\n if (e.type === 'LINEAR') out.css = 'linear';\n if (e.type === 'HOLD') out.css = 'steps(1, end)';\n return out;\n}\nasync function readProps(props) {\n if (!props) return undefined;\n const out = {};\n for (const k of Object.keys(props)) {\n const v = props[k];\n if (v && typeof v === 'object' && v.type === 'VARIABLE_ALIAS') {\n const variable = await figma.variables.getVariableByIdAsync(v.id);\n out[k] = { variableId: v.id, variableName: variable ? variable.name : undefined };\n } else if (k === 'easing' && v && typeof v === 'object') {\n out[k] = await readEasing(v);\n } else out[k] = v;\n }\n return out;\n}\nfunction readValue(v) { return v ? v.value : undefined; }\nasync function readBinding(target, b) {\n const kfs = [];\n for (const k of b.keyframes || []) kfs.push({ time: r3(k.timelinePosition), value: readValue(k.value), easing: await readEasing(k.easing) });\n return { target, baseValue: readValue(b.baseValue), keyframes: kfs };\n}\nasync function readTracks(node) {\n const mk = node.manualKeyframeTracks || {};\n const tracks = [];\n for (const key of Object.keys(mk)) {\n const entry = mk[key];\n if (!entry) continue;\n if (key === 'fills' || key === 'strokes') {\n for (const idx of Object.keys(entry)) {\n const b = entry[idx];\n if (b && b.keyframes) tracks.push(await readBinding({ paint: { collection: key, index: Number(idx) } }, b));\n }\n } else if (key === 'effects') {\n for (const idx of Object.keys(entry)) {\n const fx = entry[idx] || {};\n for (const field of Object.keys(fx)) {\n if (field !== 'properties' && fx[field] && fx[field].keyframes) tracks.push(await readBinding({ effect: { index: Number(idx), field } }, fx[field]));\n }\n }\n } else if (entry.keyframes) {\n tracks.push(await readBinding({ property: key }, entry));\n }\n }\n return tracks;\n}\nasync function readStyle(a) {\n const out = { kind: a.type === 'CUSTOM' ? 'custom' : 'preset', appliedId: a.id, styleId: a.styleId, name: a.name };\n if (a.duration !== undefined) out.duration = r3(a.duration);\n if (a.timelineOffset !== undefined) out.timelineOffset = r3(a.timelineOffset);\n if (a.props) out.props = await readProps(a.props);\n if (a.type === 'CUSTOM') {\n try {\n const style = await figma.getStyleByIdAsync(a.styleId);\n if (style && style.animationEntries) out.entries = await Promise.all(style.animationEntries.map(readStyle));\n } catch (e) { /* remote or missing style */ }\n }\n return out;\n}\nasync function readAnimations(node) {\n const styles = [];\n for (const a of node.animationStyles || []) styles.push(await readStyle(a));\n return {\n id: node.id, name: node.name, type: node.type,\n timelines: (node.timelines || []).map(t => ({ id: t.id, duration: r3(t.duration) })),\n animationStyles: styles,\n keyframeTracks: await readTracks(node),\n };\n}\nfunction hasAnimations(node) {\n if (!('animationStyles' in node)) return false;\n if ((node.animationStyles || []).length) return true;\n return Object.keys(node.manualKeyframeTracks || {}).length > 0;\n}\nasync function readCustomStyle(s) {\n return { id: s.id, name: s.name, description: s.description, remote: s.remote, entries: await Promise.all(s.animationEntries.map(readStyle)) };\n}\n";
|
|
25
|
+
/** Wrap a script body with the shared helpers and a JSON payload `P`. */
|
|
26
|
+
export declare function motionScript(payload: unknown, body: string): string;
|
|
27
|
+
export declare const GET_ANIMATIONS_BODY = "\nconst node = await getTarget(P.nodeId);\nassertMotion(node);\nconst out = { node: await readAnimations(node), playheadPosition: figma.motion.playheadPosition };\nif (P.includeDescendants && 'findAll' in node) {\n const found = node.findAll(n => hasAnimations(n)).slice(0, P.limit);\n out.descendants = [];\n for (const n of found) out.descendants.push(await readAnimations(n));\n}\nreturn out;\n";
|
|
28
|
+
export declare const APPLY_ANIMATION_BODY = "\nconst node = await getTarget(P.nodeId);\nassertMotion(node);\nassertWritable(node);\nconst applied = [];\nif (P.preset || P.customStyleId) {\n if (P.customStyleId) {\n const config = { type: 'CUSTOM' };\n if (P.timelineOffset !== undefined) config.timelineOffset = P.timelineOffset;\n applied.push(node.applyAnimationStyle(P.customStyleId, config));\n } else {\n const presets = figma.motion.figmaAnimationStyles().map(s => s.styleId);\n if (presets.indexOf(P.preset) === -1) throw new Error('Unknown preset \"' + P.preset + '\". Available: ' + presets.join(', '));\n const config = {};\n if (P.duration !== undefined) config.duration = P.duration;\n if (P.timelineOffset !== undefined) config.timelineOffset = P.timelineOffset;\n const props = Object.assign({}, P.props || {});\n const easing = await toEasing(P.easing);\n if (easing) props.easing = easing;\n if (P.durationVariableId) props.duration = await timingAlias(P.durationVariableId);\n if (Object.keys(props).length) config.props = props;\n applied.push(node.applyAnimationStyle(P.preset, config));\n }\n}\nfor (const t of P.keyframeTracks || []) {\n const keyframes = [];\n for (const k of t.keyframes) {\n const kf = { timelinePosition: k.time, value: toKeyframeValue(k.value) };\n const easing = await toEasing(k.easing);\n if (easing) kf.easing = easing;\n keyframes.push(kf);\n }\n const track = { keyframes };\n if (t.baseValue !== undefined) track.baseValue = toKeyframeValue(t.baseValue);\n node.applyManualKeyframeTrack(toField(t), track);\n applied.push(t.property || (t.paint ? t.paint.collection + '[' + t.paint.index + ']' : 'effects[' + t.effect.index + '].' + t.effect.field));\n}\nreturn { applied, node: await readAnimations(node) };\n";
|
|
29
|
+
export declare const REMOVE_ANIMATION_BODY = "\nconst node = await getTarget(P.nodeId);\nassertMotion(node);\nassertWritable(node);\nconst removed = [];\nif (P.all) {\n for (const a of (node.animationStyles || []).slice()) { node.removeAnimationStyle(a.id); removed.push(a.id); }\n for (const t of await readTracks(node)) { node.removeManualKeyframeTrack(toField(t.target)); removed.push(JSON.stringify(t.target)); }\n} else {\n if (P.appliedId) {\n if (!(node.animationStyles || []).some(a => a.id === P.appliedId)) {\n throw new Error('No applied animation style with id ' + P.appliedId + ' on this node. Read appliedId values with figma_get_animations.');\n }\n node.removeAnimationStyle(P.appliedId);\n removed.push(P.appliedId);\n }\n if (P.keyframeTrack) { node.removeManualKeyframeTrack(toField(P.keyframeTrack)); removed.push(JSON.stringify(P.keyframeTrack)); }\n}\nreturn { removed, node: await readAnimations(node) };\n";
|
|
30
|
+
export declare const MANAGE_STYLES_BODY = "\nassertMotion(null);\nif (P.action === 'list_presets') {\n return { presets: figma.motion.figmaAnimationStyles().map(s => ({ styleId: s.styleId, name: s.name, description: s.description, props: s.props })) };\n}\nif (typeof figma.createCustomAnimationStyle !== 'function') {\n throw new Error('Custom animation styles need a newer Figma Desktop (Plugin API Update 140, September 2026).');\n}\nasync function getStyle() {\n if (!P.styleId) throw new Error('styleId is required for ' + P.action);\n const s = await figma.getStyleByIdAsync(P.styleId);\n if (!s || s.type !== 'CUSTOM_ANIMATION') throw new Error('No custom animation style with id ' + P.styleId);\n return s;\n}\nasync function entryProps(e) {\n const props = Object.assign({}, e.props || {});\n if (e.duration !== undefined) props.duration = e.duration;\n if (e.timelineOffset !== undefined) props.timelineOffset = e.timelineOffset;\n const easing = await toEasing(e.easing);\n if (easing) props.easing = easing;\n if (e.durationVariableId) props.duration = await timingAlias(e.durationVariableId);\n return props;\n}\nasync function addEntries(style, entries) {\n const presets = figma.motion.figmaAnimationStyles().map(s => s.styleId);\n for (const e of entries || []) {\n if (presets.indexOf(e.preset) === -1) throw new Error('Unknown preset \"' + e.preset + '\". Available: ' + presets.join(', '));\n await style.addAnimationEntryAsync(e.preset, await entryProps(e));\n }\n}\nif (P.action === 'list') {\n const styles = await figma.getLocalCustomAnimationStylesAsync();\n return { styles: await Promise.all(styles.map(readCustomStyle)) };\n}\nif (P.action === 'create') {\n if (!P.name) throw new Error('name is required to create a style');\n const style = figma.createCustomAnimationStyle();\n style.name = P.name;\n if (P.description !== undefined) style.description = P.description;\n try { await addEntries(style, P.entries); } catch (e) { style.remove(); throw e; }\n return { created: await readCustomStyle(style) };\n}\nconst style = await getStyle();\nif (P.action === 'update') {\n if (P.name !== undefined) style.name = P.name;\n if (P.description !== undefined) style.description = P.description;\n await addEntries(style, P.entries);\n return { updated: await readCustomStyle(style) };\n}\nif (P.action === 'remove_entry') {\n if (!P.entryId) throw new Error('entryId is required for remove_entry');\n style.removeAnimationEntry(P.entryId);\n return { updated: await readCustomStyle(style) };\n}\nif (P.action === 'delete') {\n const name = style.name;\n style.remove();\n return { deleted: { id: P.styleId, name } };\n}\nthrow new Error('Unknown action ' + P.action);\n";
|
|
31
|
+
export declare const EXPORT_ANIMATION_BODY = "\nconst node = P.nodeId ? await figma.getNodeByIdAsync(P.nodeId) : figma.currentPage.selection[0];\nif (!node) throw new Error(P.nodeId ? 'Node not found: ' + P.nodeId : 'No nodeId given and nothing is selected');\nif (typeof figma.motion === 'undefined') throw new Error(MOTION_UNAVAILABLE);\nconst settings = { format: P.format };\nif (P.fps !== undefined) settings.fps = P.fps;\nif (P.quality !== undefined && P.format !== 'GIF') settings.quality = P.quality;\nif (P.loopCount !== undefined && P.format === 'GIF') settings.loopCount = P.loopCount;\nif (P.scale !== undefined) settings.constraint = { type: 'SCALE', value: P.scale };\nelse if (P.width !== undefined) settings.constraint = { type: 'WIDTH', value: P.width };\nelse if (P.height !== undefined) settings.constraint = { type: 'HEIGHT', value: P.height };\nlet bytes;\ntry { bytes = await node.exportAsync(settings); }\ncatch (e) { throw new Error('Video export failed: ' + (e && e.message ? e.message : e) + '. Export works on a frame that has animated content (Motion); use its top-level frame.'); }\nreturn { nodeId: node.id, name: node.name, format: P.format, bytes: bytes.length, base64: figma.base64Encode(bytes) };\n";
|
|
32
|
+
/** Validate fps/scale for a video format; returns an error message or null. */
|
|
33
|
+
export declare function validateVideoSettings(args: {
|
|
34
|
+
format: string;
|
|
35
|
+
fps?: number;
|
|
36
|
+
scale?: number;
|
|
37
|
+
}): string | null;
|
|
38
|
+
export interface MotionToolsOptions {
|
|
39
|
+
/** Local Mode: figma_export_animation may write files to disk. */
|
|
40
|
+
allowFileWrite?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function registerMotionTools(server: McpServer, getDesktopConnector: () => Promise<any>, options?: MotionToolsOptions): void;
|
|
43
|
+
//# sourceMappingURL=motion-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion-tools.d.ts","sourceRoot":"","sources":["../../src/core/motion-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMzE,eAAO,MAAM,YAAY,6MAef,CAAC;AAEX,eAAO,MAAM,mBAAmB,0mBA+BtB,CAAC;AAEX,eAAO,MAAM,sBAAsB,sRAkBzB,CAAC;AAKX,qFAAqF;AACrF,eAAO,MAAM,uBAAuB,QAAkB,CAAC;AA4EvD;;;;GAIG;AACH,eAAO,MAAM,cAAc,61NAgJ1B,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED,eAAO,MAAM,mBAAmB,qZAU/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,wvDAsChC,CAAC;AAEF,eAAO,MAAM,qBAAqB,84BAmBjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,woFA4D9B,CAAC;AAEF,eAAO,MAAM,qBAAqB,uqCAejC,CAAC;AAIF,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,IAAI,CAS3G;AAqBD,MAAM,WAAW,kBAAkB;IAClC,kEAAkE;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,SAAS,EACjB,mBAAmB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EACvC,OAAO,GAAE,kBAAuB,GAC9B,IAAI,CAqKN"}
|