figma-console-mcp 1.41.2 → 1.41.3

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 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
- > **🆕 Security & data-safety fixes (latest v1.41.2):** 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 makes component-set analysis report real variant differences, stops component loading from timing out on large files, and fixes variable paging — re-import the plugin for the component fixes. [See what's new →](CHANGELOG.md#1412---2026-10-26)
11
+ > **🆕 Security & data-safety fixes (latest v1.41.3):** 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 and v1.41.3 make component-set analysis report real variant differences, including changes inside nested layers (an icon swap, a token on a nested vector, opacity on a disabled variant), 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#1413---2026-10-26)
12
12
 
13
13
  ## What is this?
14
14
 
@@ -140,7 +140,7 @@ If you're not sure where to put the JSON configuration above, here's where each
140
140
 
141
141
  > **Heads-up on plugin updates.** Figma caches plugin files (`code.js` and `ui.html`) at the application level. The MCP server refreshes the files at `~/.figma-console-mcp/plugin/` on every startup, but Figma keeps using its cached copy until you re-import the manifest.
142
142
  >
143
- > **Re-importing is _required_ only when a release notes entry says so** — typically when the plugin adds a new method the server needs (e.g. v1.22.4, v1.10.0). The plugin files last changed in v1.41.1; if your imported plugin predates that, re-import once. The plugin shows an update banner when the server bundles a newer plugin than the one running. For most upgrades the new server stays wire-compatible with the previous plugin, and re-importing is **optional**: you'll still get every functional change, just not the cosmetic plugin-side touches (status-pill copy, `pluginVersion` reporting).
143
+ > **Re-importing is _required_ only when a release notes entry says so** — typically when the plugin adds a new method the server needs (e.g. v1.22.4, v1.10.0). The plugin files last changed in v1.41.3; if your imported plugin predates that, re-import once. The plugin shows an update banner when the server bundles a newer plugin than the one running. For most upgrades the new server stays wire-compatible with the previous plugin, and re-importing is **optional**: you'll still get every functional change, just not the cosmetic plugin-side touches (status-pill copy, `pluginVersion` reporting).
144
144
  >
145
145
  > When you do re-import: Plugins → Manage plugins → re-import `~/.figma-console-mcp/plugin/manifest.json`. The stable path never changes, so it's a one-click step.
146
146
 
@@ -874,9 +874,10 @@ The two servers are complementary, and both can run in the same MCP client.
874
874
 
875
875
  ## 🛤️ Roadmap
876
876
 
877
- **Current Status:** v1.41.2 (Stable) - Production-ready. Latest: the 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.
877
+ **Current Status:** v1.41.3 (Stable) - Production-ready. Latest: component-set analysis reports 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.
878
878
 
879
879
  **Recent Releases:**
880
+ - [x] **v1.41.3** - Component-set analysis diffs nested layers by path (instance swaps, nested fill/stroke tokens), variant-level opacity, and visibility in both directions; a layer hidden in every variant is no longer reported as a change. Plugin re-import.
880
881
  - [x] **v1.41.2** - Design-system summary and token values read the bridge's variables response correctly (always 0 tokens before). Server-only.
881
882
  - [x] **v1.41.1** - Component-set analysis finds Figma's default variant and diffs size/layers (#121); component loading drops throttled setTimeout yields and uses native search — 300s timeouts → ~1.5s (#120); summary fails loudly; search ranked by relevance; `figma_get_variables` full-format paging and one pagination shape (#98, #99); deep extraction mixed-text fix and unlimited depth (PRs #85, #86 by @DarWiM). Plugin re-import for component fixes.
882
883
  - [x] **v1.41.0** - Security & data-safety. Cloud Mode: `/sse` sessions use their own token (a shared slot let REST calls run with another user's token), authorization codes are random/single-use/10-minute and bound to client_id + redirect_uri + PKCE S256, unregistered redirects refused, consent page for other registered destinations, callback error page escaped. Local: accessibility scan no longer executes scanned scripts; `figma_import_tokens` refuses 0-token imports and scopes `replace` deletes to imported collections; `figma_arrange_component_set` replaces only its own set's arrangement; token export/import read variables live; stdin-EOF exit (PR #140 by @RomanOdokienko); Slots `fileKey` (PR #112 by @Wolfr); batch-create aliases. Server-only. Reported in #104, #122, #53, #91, #116.
@@ -81,7 +81,7 @@ export function registerDeepComponentTools(server, getDesktopConnector) {
81
81
  // -----------------------------------------------------------------------
82
82
  // Tool: figma_analyze_component_set
83
83
  // -----------------------------------------------------------------------
84
- server.tool("figma_analyze_component_set", "Analyze a Figma COMPONENT_SET to extract variant state machine and cross-variant diffs for code generation. Returns: (1) variant axes (size, state) with all values, (2) CSS pseudo-class mappings for interaction states (hover→:hover, focus→:focus-visible, disabled→:disabled, error→[aria-invalid]), (3) visual diff from default state per variant (only changed properties — fill token, stroke token, stroke weight, text color, opacity, effects, visibility), (4) component property definitions mapped to code props (BOOLEAN→boolean, TEXT→string, INSTANCE_SWAP→slot/ReactNode), and (5) slots — Figma SLOT properties (name, preferredValues = the components a slot accepts, and limitViolations) to implement as named slots / children props (React {children} or named ReactNode; Web Components <slot name>). Use this on the parent COMPONENT_SET node, not individual variants. Requires Desktop Bridge plugin.", {
84
+ server.tool("figma_analyze_component_set", "Analyze a Figma COMPONENT_SET to extract variant state machine and cross-variant diffs for code generation. Returns: (1) variant axes (size, state) with all values, (2) CSS pseudo-class mappings for interaction states (hover→:hover, focus→:focus-visible, disabled→:disabled, error→[aria-invalid]), (3) visual diff from default state per variant (only changed properties — fill token, stroke token, stroke weight, text color, opacity incl. opacity on the variant itself, effects, size, child layers, visibility, plus `layers`: changes to nested layers keyed by layer path such as 'Icons/Radio › Icon', including instance swaps), (4) component property definitions mapped to code props (BOOLEAN→boolean, TEXT→string, INSTANCE_SWAP→slot/ReactNode), and (5) slots — Figma SLOT properties (name, preferredValues = the components a slot accepts, and limitViolations) to implement as named slots / children props (React {children} or named ReactNode; Web Components <slot name>). Use this on the parent COMPONENT_SET node, not individual variants. Requires Desktop Bridge plugin.", {
85
85
  nodeId: z
86
86
  .string()
87
87
  .describe("COMPONENT_SET node ID (the parent of all variants, e.g., '214:274')"),
@@ -1 +1 @@
1
- {"version":3,"file":"deep-component-tools.js","sourceRoot":"","sources":["../../src/core/deep-component-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,CAAC,E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AChC,IAAI,EAAE,gOAAgO;6BACtO;yBACD,CAAC;qBACF;iBACD;aACD,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,+BAA+B,CAAC,CAAC;YAEzD,OAAO;gBACN,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;4BACpB,KAAK,EAAE,8BAA8B;4BACrC,OAAO,EAAE,iCAAiC,OAAO,EAAE;4BACnD,IAAI,EAAE,2JAA2J;yBACjK,CAAC;qBACF;iBACD;gBACD,OAAO,EAAE,IAAI;aACb,CAAC;QACH,CAAC;IACF,CAAC,CACD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"deep-component-tools.js","sourceRoot":"","sources":["../../src/core/deep-component-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;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,sBAAsB,EAAE,CAAC,CAAC;AAExE,MAAM,UAAU,0BAA0B,CACzC,MAAiB,EACjB,mBAAuC;IAEvC,MAAM,CAAC,IAAI,CACV,0CAA0C,EAC1C,sqBAAsqB,EACtqB;QACC,MAAM,EAAE,CAAC;aACP,MAAM,EAAE;aACR,QAAQ,CAAC,gDAAgD,CAAC;QAC5D,KAAK,EAAE,CAAC,CAAC,UAAU,CAClB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,C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AI,EAAE,2JAA2J;yBACjK,CAAC;qBACF;iBACD;gBACD,OAAO,EAAE,IAAI;aACb,CAAC;QACH,CAAC;IACF,CAAC,CACD,CAAC;AACH,CAAC"}
@@ -36,7 +36,7 @@ const logger = createChildLogger({ component: "tokens-tools" });
36
36
  * on every exported token document. Kept in sync with package.json by
37
37
  * scripts/release.sh — see step 3 of the release flow.
38
38
  */
39
- const MCP_VERSION = "1.41.2";
39
+ const MCP_VERSION = "1.41.3";
40
40
  const EXPORT_TOOL_DESCRIPTION = `Export Figma variables to design token files in your codebase. Bidirectional with figma_import_tokens — together they replace Style Dictionary and Tokens Studio's export pipeline for the popular styling methods.
41
41
 
42
42
  FULLY-IMPLEMENTED OUTPUT FORMATS:
@@ -9,7 +9,7 @@
9
9
  // detect stale cached plugins. Bumped by scripts/release.sh ONLY when plugin files
10
10
  // change (see issue #62); server-only releases leave it alone, so it may lag
11
11
  // package.json — that's intentional, not drift.
12
- var PLUGIN_VERSION = '1.41.1'; // Last release in which plugin files changed.
12
+ var PLUGIN_VERSION = '1.41.3'; // Last release in which plugin files changed.
13
13
 
14
14
  console.log('🌉 [Desktop Bridge] Plugin loaded (v' + PLUGIN_VERSION + ')');
15
15
 
@@ -1165,7 +1165,7 @@ figma.ui.onmessage = async (msg) => {
1165
1165
  }
1166
1166
 
1167
1167
  // Extract visual signature from a variant for diffing
1168
- function extractSignature(variant) {
1168
+ async function extractSignature(variant) {
1169
1169
  var sig = {};
1170
1170
 
1171
1171
  // Find the main interactive element — prioritize by: has strokes (input fields),
@@ -1199,6 +1199,9 @@ figma.ui.onmessage = async (msg) => {
1199
1199
  // No stroked/frame child: the variant itself carries the visuals
1200
1200
  // (e.g. a button whose fill sits on the component).
1201
1201
  if (!mainChild) mainChild = variant;
1202
+ // Layer paths whose values the top-level fields already report.
1203
+ sig._mainPath = mainChild === variant ? null : mainChild.name;
1204
+ sig._textPath = null;
1202
1205
 
1203
1206
  // Geometry and structure, so variants that differ in size or content
1204
1207
  // (2 icons vs 6 icons) don't diff as identical (#121).
@@ -1225,7 +1228,7 @@ figma.ui.onmessage = async (msg) => {
1225
1228
  sig.strokeHex = '#' + Math.round(sc.r*255).toString(16).padStart(2,'0') + Math.round(sc.g*255).toString(16).padStart(2,'0') + Math.round(sc.b*255).toString(16).padStart(2,'0');
1226
1229
  }
1227
1230
  sig.effects = child.effects && child.effects.length > 0 ? child.effects : null;
1228
- sig.opacity = child.opacity < 1 ? child.opacity : null;
1231
+ sig.opacity = child.opacity < 1 ? Math.round(child.opacity * 100) / 100 : null;
1229
1232
  } catch(e) {}
1230
1233
 
1231
1234
  // Check text children for color changes
@@ -1233,6 +1236,7 @@ figma.ui.onmessage = async (msg) => {
1233
1236
  for (var t = 0; t < child.children.length; t++) {
1234
1237
  var textChild = child.children[t];
1235
1238
  if (textChild.type === 'TEXT') {
1239
+ sig._textPath = sig._mainPath ? sig._mainPath + ' › ' + textChild.name : textChild.name;
1236
1240
  try {
1237
1241
  var tbv = textChild.boundVariables || {};
1238
1242
  sig.textToken = resolveBoundColor(tbv.fills);
@@ -1247,20 +1251,79 @@ figma.ui.onmessage = async (msg) => {
1247
1251
  }
1248
1252
  }
1249
1253
 
1250
- // Check element visibility changes
1254
+ // Top-level layers that are hidden. _visible keeps every child's
1255
+ // visibility so the diff can compare both directions.
1251
1256
  sig.visibilityChanges = {};
1257
+ sig._visible = {};
1252
1258
  if (variant.children) {
1253
1259
  for (var j = 0; j < variant.children.length; j++) {
1254
1260
  var ch = variant.children[j];
1255
1261
  try {
1262
+ sig._visible[ch.name] = ch.visible !== false;
1256
1263
  if (!ch.visible) sig.visibilityChanges[ch.name] = false;
1257
1264
  } catch(e) {}
1258
1265
  }
1259
1266
  }
1260
1267
 
1268
+ // Opacity on the variant itself (a disabled state often lives here,
1269
+ // not on any child).
1270
+ sig.variantOpacity = variant.opacity < 1 ? Math.round(variant.opacity * 100) / 100 : null;
1271
+
1272
+ // Nested layers, keyed by path. State changes often sit below the
1273
+ // first child (a checked radio swaps the icon instance; its vector's
1274
+ // fill token changes), which the fields above never see. Only used
1275
+ // for diffing — stripped from the response.
1276
+ sig._layers = {};
1277
+ var layerCount = 0;
1278
+ async function walkLayers(parent, prefix, depth) {
1279
+ if (!parent.children || depth > 4) return;
1280
+ var seen = {};
1281
+ for (var li = 0; li < parent.children.length && layerCount < 300; li++) {
1282
+ var ln = parent.children[li];
1283
+ var nm = ln.name;
1284
+ seen[nm] = (seen[nm] || 0) + 1;
1285
+ if (seen[nm] > 1) nm = nm + '#' + seen[nm];
1286
+ var path = prefix ? prefix + ' › ' + nm : nm;
1287
+ var entry = {};
1288
+ layerCount++;
1289
+ try {
1290
+ var lbv = ln.boundVariables || {};
1291
+ var ft = resolveBoundColor(lbv.fills);
1292
+ var st = resolveBoundColor(lbv.strokes);
1293
+ entry.fill = ft || (ln.fills && ln.fills.length > 0 && ln.fills[0].color ? colorHex(ln.fills[0].color) : null);
1294
+ entry.stroke = st || (ln.strokes && ln.strokes.length > 0 && ln.strokes[0].color ? colorHex(ln.strokes[0].color) : null);
1295
+ entry.strokeWeight = entry.stroke ? (typeof ln.strokeWeight === 'number' ? ln.strokeWeight : null) : null;
1296
+ entry.opacity = ln.opacity < 1 ? Math.round(ln.opacity * 100) / 100 : null;
1297
+ entry.visible = ln.visible !== false;
1298
+ } catch(e) {}
1299
+ if (ln.type === 'INSTANCE') {
1300
+ try {
1301
+ var mc = await ln.getMainComponentAsync();
1302
+ entry.component = mc ? mc.name : null;
1303
+ } catch(e) {}
1304
+ }
1305
+ sig._layers[path] = entry;
1306
+ await walkLayers(ln, path, depth + 1);
1307
+ }
1308
+ }
1309
+ await walkLayers(variant, '', 0);
1310
+
1261
1311
  return sig;
1262
1312
  }
1263
1313
 
1314
+ function colorHex(c) {
1315
+ return '#' + Math.round(c.r*255).toString(16).padStart(2,'0') + Math.round(c.g*255).toString(16).padStart(2,'0') + Math.round(c.b*255).toString(16).padStart(2,'0');
1316
+ }
1317
+
1318
+ // Signature as returned to the caller, without the diff-only fields.
1319
+ function publicSignature(sig) {
1320
+ var out = {};
1321
+ for (var k in sig) {
1322
+ if (k.charAt(0) !== '_') out[k] = sig[k];
1323
+ }
1324
+ return out;
1325
+ }
1326
+
1264
1327
  // Parse variant property definitions
1265
1328
  var propDefs = node.componentPropertyDefinitions || {};
1266
1329
  var variantAxes = {};
@@ -1359,14 +1422,14 @@ figma.ui.onmessage = async (msg) => {
1359
1422
  }
1360
1423
  }
1361
1424
  if (defaultVariant) {
1362
- defaultSig = extractSignature(defaultVariant);
1425
+ defaultSig = await extractSignature(defaultVariant);
1363
1426
  }
1364
1427
 
1365
1428
  // Process each variant and compute diff from default
1366
1429
  var variantDiffs = [];
1367
1430
  for (var vdi = 0; vdi < variants.length; vdi++) {
1368
1431
  var variant = variants[vdi];
1369
- var sig = extractSignature(variant);
1432
+ var sig = await extractSignature(variant);
1370
1433
 
1371
1434
  // Parse variant name to extract axis values
1372
1435
  var axisParts = variant.name.split(', ');
@@ -1400,15 +1463,51 @@ figma.ui.onmessage = async (msg) => {
1400
1463
  removed: defaultSig.children.filter(function(n) { return sig.children.indexOf(n) === -1; })
1401
1464
  };
1402
1465
  }
1403
- // Visibility changes not in default
1404
- var dvKeys = Object.keys(defaultSig.visibilityChanges);
1405
- var svKeys = Object.keys(sig.visibilityChanges);
1406
- for (var sk = 0; sk < svKeys.length; sk++) {
1407
- if (!defaultSig.visibilityChanges[svKeys[sk]]) {
1466
+ // Top-level layers present in both whose visibility differs
1467
+ // (false = hidden in this variant, true = shown here but hidden in
1468
+ // the default).
1469
+ for (var vk in sig._visible) {
1470
+ if (Object.prototype.hasOwnProperty.call(defaultSig._visible, vk) && sig._visible[vk] !== defaultSig._visible[vk]) {
1408
1471
  if (!diff.visibilityChanges) diff.visibilityChanges = {};
1409
- diff.visibilityChanges[svKeys[sk]] = sig.visibilityChanges[svKeys[sk]];
1472
+ diff.visibilityChanges[vk] = sig._visible[vk];
1473
+ }
1474
+ }
1475
+ if (sig._mainPath && sig.variantOpacity !== defaultSig.variantOpacity) diff.variantOpacity = sig.variantOpacity === null ? 1 : sig.variantOpacity;
1476
+
1477
+ // Nested layer changes, skipping values the fields above already
1478
+ // report so one change isn't listed twice.
1479
+ var layerProps = ['fill', 'stroke', 'strokeWeight', 'opacity', 'visible', 'component'];
1480
+ for (var lp in sig._layers) {
1481
+ var dl = defaultSig._layers[lp];
1482
+ if (!dl) continue;
1483
+ var sl = sig._layers[lp];
1484
+ var isTop = lp.indexOf(' › ') === -1;
1485
+ var ld = null;
1486
+ for (var pi = 0; pi < layerProps.length; pi++) {
1487
+ var prop = layerProps[pi];
1488
+ if (prop === 'visible' && isTop) continue;
1489
+ if (lp === sig._mainPath && prop !== 'visible' && prop !== 'component') continue;
1490
+ if (lp === sig._textPath && prop === 'fill') continue;
1491
+ if (sl[prop] !== dl[prop]) {
1492
+ if (!ld) ld = {};
1493
+ ld[prop] = sl[prop] === undefined ? null : sl[prop];
1494
+ }
1495
+ }
1496
+ if (ld) {
1497
+ if (!diff.layers) diff.layers = {};
1498
+ diff.layers[lp] = ld;
1410
1499
  }
1411
1500
  }
1501
+ var nestedAdded = [];
1502
+ var nestedRemoved = [];
1503
+ for (var ap2 in sig._layers) {
1504
+ if (ap2.indexOf(' › ') !== -1 && !defaultSig._layers[ap2] && nestedAdded.length < 20) nestedAdded.push(ap2);
1505
+ }
1506
+ for (var rp2 in defaultSig._layers) {
1507
+ if (rp2.indexOf(' › ') !== -1 && !sig._layers[rp2] && nestedRemoved.length < 20) nestedRemoved.push(rp2);
1508
+ }
1509
+ if (nestedAdded.length) diff.layersAdded = nestedAdded;
1510
+ if (nestedRemoved.length) diff.layersRemoved = nestedRemoved;
1412
1511
  }
1413
1512
 
1414
1513
  variantDiffs.push({
@@ -1418,7 +1517,7 @@ figma.ui.onmessage = async (msg) => {
1418
1517
  state: stateValue,
1419
1518
  cssSelector: cssSelector,
1420
1519
  diffFromDefault: Object.keys(diff).length > 0 ? diff : null,
1421
- signature: sig
1520
+ signature: publicSignature(sig)
1422
1521
  });
1423
1522
 
1424
1523
  // Build CSS mapping
@@ -1435,7 +1534,7 @@ figma.ui.onmessage = async (msg) => {
1435
1534
  var defaultAxes = parseAxes(defaultVariant.name);
1436
1535
  stateMachine.defaultState = stateAxis ? (defaultAxes[stateAxis] || 'default') : 'default';
1437
1536
  stateMachine.defaultVariant = { id: defaultVariant.id, name: defaultVariant.name };
1438
- stateMachine.defaultSignature = defaultSig;
1537
+ stateMachine.defaultSignature = publicSignature(defaultSig);
1439
1538
  }
1440
1539
 
1441
1540
  var result = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "figma-console-mcp",
3
- "version": "1.41.2",
3
+ "version": "1.41.3",
4
4
  "description": "The most comprehensive MCP server for Figma — design tokens, variables, components, write tools, version history diff, accessibility audits, FigJam, Slides, and more. Local (WebSocket Desktop Bridge plugin) and Cloudflare Workers (paired + remote) modes.",
5
5
  "type": "module",
6
6
  "main": "dist/local.js",