@muloka/figma-console-mcp 0.5.7 → 0.6.1
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 +120 -848
- package/dist/apps/design-system-dashboard/mcp-app.html +107 -94
- package/dist/apps/design-system-dashboard/server.d.ts +1 -1
- package/dist/apps/design-system-dashboard/server.d.ts.map +1 -1
- package/dist/apps/token-browser/mcp-app.html +95 -82
- package/dist/apps/token-browser/server.d.ts +1 -1
- package/dist/apps/token-browser/server.d.ts.map +1 -1
- package/dist/core/accessibility-tools.d.ts +1 -1
- package/dist/core/accessibility-tools.d.ts.map +1 -1
- package/dist/core/accessibility-tools.js +18 -15
- package/dist/core/accessibility-tools.js.map +1 -1
- package/dist/core/annotation-tools.d.ts +1 -1
- package/dist/core/annotation-tools.d.ts.map +1 -1
- package/dist/core/annotation-tools.js +35 -26
- package/dist/core/annotation-tools.js.map +1 -1
- package/dist/core/comment-tools.d.ts +2 -2
- package/dist/core/comment-tools.d.ts.map +1 -1
- package/dist/core/comment-tools.js +60 -51
- package/dist/core/comment-tools.js.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +2 -17
- package/dist/core/config.js.map +1 -1
- package/dist/core/console-monitor.d.ts +1 -1
- package/dist/core/console-monitor.d.ts.map +1 -1
- package/dist/core/console-monitor.js +2 -2
- package/dist/core/console-monitor.js.map +1 -1
- package/dist/core/deep-component-tools.d.ts +1 -1
- package/dist/core/deep-component-tools.d.ts.map +1 -1
- package/dist/core/deep-component-tools.js +15 -9
- package/dist/core/deep-component-tools.js.map +1 -1
- package/dist/core/design-code-tools.d.ts +1 -1
- package/dist/core/design-code-tools.d.ts.map +1 -1
- package/dist/core/design-code-tools.js +53 -47
- package/dist/core/design-code-tools.js.map +1 -1
- package/dist/core/design-system-manifest.d.ts +37 -2
- package/dist/core/design-system-manifest.d.ts.map +1 -1
- package/dist/core/design-system-manifest.js +85 -0
- package/dist/core/design-system-manifest.js.map +1 -1
- package/dist/core/design-system-tools.d.ts +1 -1
- package/dist/core/design-system-tools.d.ts.map +1 -1
- package/dist/core/design-system-tools.js +39 -36
- package/dist/core/design-system-tools.js.map +1 -1
- package/dist/core/diagnose-tool.d.ts +8 -4
- package/dist/core/diagnose-tool.d.ts.map +1 -1
- package/dist/core/diagnose-tool.js +18 -15
- package/dist/core/diagnose-tool.js.map +1 -1
- package/dist/core/figjam-tools.d.ts +2 -2
- package/dist/core/figjam-tools.d.ts.map +1 -1
- package/dist/core/figjam-tools.js +159 -129
- package/dist/core/figjam-tools.js.map +1 -1
- package/dist/core/figma-connector.d.ts +14 -3
- package/dist/core/figma-connector.d.ts.map +1 -1
- package/dist/core/figma-tools.d.ts +1 -1
- package/dist/core/figma-tools.d.ts.map +1 -1
- package/dist/core/figma-tools.js +284 -267
- package/dist/core/figma-tools.js.map +1 -1
- package/dist/core/identity.d.ts +49 -9
- package/dist/core/identity.d.ts.map +1 -1
- package/dist/core/identity.js +137 -28
- package/dist/core/identity.js.map +1 -1
- package/dist/core/library-tools.d.ts +1 -1
- package/dist/core/library-tools.d.ts.map +1 -1
- package/dist/core/library-tools.js +45 -36
- package/dist/core/library-tools.js.map +1 -1
- package/dist/core/logger.d.ts +0 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +1 -13
- package/dist/core/logger.js.map +1 -1
- package/dist/core/slides-tools.d.ts +2 -2
- package/dist/core/slides-tools.d.ts.map +1 -1
- package/dist/core/slides-tools.js +223 -172
- package/dist/core/slides-tools.js.map +1 -1
- package/dist/core/slot-tools.d.ts +1 -1
- package/dist/core/slot-tools.d.ts.map +1 -1
- package/dist/core/slot-tools.js +101 -86
- package/dist/core/slot-tools.js.map +1 -1
- package/dist/core/tokens/config.d.ts +88 -266
- package/dist/core/tokens/config.d.ts.map +1 -1
- package/dist/core/tokens/config.js +2 -3
- package/dist/core/tokens/config.js.map +1 -1
- package/dist/core/tokens/schemas.d.ts +104 -113
- package/dist/core/tokens/schemas.d.ts.map +1 -1
- package/dist/core/tokens/schemas.js +2 -2
- package/dist/core/tokens/schemas.js.map +1 -1
- package/dist/core/tokens-tools.d.ts +5 -3
- package/dist/core/tokens-tools.d.ts.map +1 -1
- package/dist/core/tokens-tools.js +13 -10
- package/dist/core/tokens-tools.js.map +1 -1
- package/dist/core/types/index.d.ts +1 -1
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/core/variable-resolver.d.ts +3 -3
- package/dist/core/variable-resolver.d.ts.map +1 -1
- package/dist/core/variable-resolver.js +6 -9
- package/dist/core/variable-resolver.js.map +1 -1
- package/dist/core/version-tools.d.ts +4 -4
- package/dist/core/version-tools.d.ts.map +1 -1
- package/dist/core/version-tools.js +162 -144
- package/dist/core/version-tools.js.map +1 -1
- package/dist/core/websocket-connector.d.ts +4 -7
- package/dist/core/websocket-connector.d.ts.map +1 -1
- package/dist/core/websocket-connector.js +28 -39
- package/dist/core/websocket-connector.js.map +1 -1
- package/dist/core/websocket-server.d.ts +36 -2
- package/dist/core/websocket-server.d.ts.map +1 -1
- package/dist/core/websocket-server.js +69 -8
- package/dist/core/websocket-server.js.map +1 -1
- package/dist/core/write-tools.d.ts +2 -2
- package/dist/core/write-tools.d.ts.map +1 -1
- package/dist/core/write-tools.js +564 -471
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts +8 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +390 -302
- package/dist/local.js.map +1 -1
- package/figma-desktop-bridge/code.js +23 -2
- package/package.json +11 -19
package/dist/core/figma-tools.js
CHANGED
|
@@ -679,32 +679,35 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
679
679
|
// NOTE: For specific use cases, consider using specialized tools:
|
|
680
680
|
// - figma_get_component_for_development: For UI component implementation
|
|
681
681
|
// - figma_get_file_for_plugin: For plugin development
|
|
682
|
-
server.
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
682
|
+
server.registerTool("figma_get_file_data", {
|
|
683
|
+
description: "Get full file structure and document tree. WARNING: Can consume large amounts of tokens. NOT recommended for component descriptions (use figma_get_component instead). Best for understanding file structure or finding component nodeIds. Start with verbosity='summary' and depth=1 for initial exploration.",
|
|
684
|
+
inputSchema: z.object({
|
|
685
|
+
fileUrl: z
|
|
686
|
+
.string()
|
|
687
|
+
.url()
|
|
688
|
+
.optional()
|
|
689
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket Desktop Bridge connection. Only required if not connected."),
|
|
690
|
+
depth: z
|
|
691
|
+
.number()
|
|
692
|
+
.min(0)
|
|
693
|
+
.max(3)
|
|
694
|
+
.optional()
|
|
695
|
+
.default(1)
|
|
696
|
+
.describe("How many levels of children to include (default: 1, max: 3). Start with 1 to prevent context exhaustion. Use 0 for full tree only when absolutely necessary."),
|
|
697
|
+
verbosity: z
|
|
698
|
+
.enum(["summary", "standard", "full"])
|
|
699
|
+
.optional()
|
|
700
|
+
.default("summary")
|
|
701
|
+
.describe("Controls payload size: 'summary' (IDs/names/types only, ~90% smaller - RECOMMENDED), 'standard' (essential properties, ~50% smaller), 'full' (everything). Default: summary for token efficiency."),
|
|
702
|
+
nodeIds: z
|
|
703
|
+
.array(z.string())
|
|
704
|
+
.optional()
|
|
705
|
+
.describe("Specific node IDs to retrieve (optional)"),
|
|
706
|
+
enrich: z
|
|
707
|
+
.boolean()
|
|
708
|
+
.optional()
|
|
709
|
+
.describe("Set to true when user asks for: file statistics, health metrics, design system audit, or quality analysis. Adds statistics, health scores, and audit summaries. Default: false"),
|
|
710
|
+
}),
|
|
708
711
|
}, async ({ fileUrl, depth, nodeIds, enrich, verbosity }) => {
|
|
709
712
|
try {
|
|
710
713
|
// Initialize API client (required for file data - no Desktop Bridge alternative)
|
|
@@ -877,106 +880,109 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
877
880
|
* removed in the Phase 3 cleanup. Setting parseFromConsole=true now
|
|
878
881
|
* throws an identified error pointing the caller at the bridge.
|
|
879
882
|
*/
|
|
880
|
-
server.
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
.
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
883
|
+
server.registerTool("figma_get_variables", {
|
|
884
|
+
description: "Extract design tokens and variables from a Figma file with code export support (CSS, Tailwind, TypeScript, Sass). Use when user asks for: design system tokens, variables, color/spacing values, theme data, or code exports. Handles multi-mode variables (Light/Dark themes). NOT for component metadata (use figma_get_component). Returns a compact summary by default — pass format='full' for the complete dataset or format='filtered' with collection/namePattern/mode filters for specific variables. Supports verbosity control to prevent token exhaustion. Resolution order: Desktop Bridge plugin (works on any plan) → Variables REST API (Enterprise only) → Styles API as a partial fallback. TIP: For full design system extraction (tokens + components + styles combined), prefer figma_get_design_system_kit instead — it returns everything in one optimized call.",
|
|
885
|
+
inputSchema: z.object({
|
|
886
|
+
fileUrl: z
|
|
887
|
+
.string()
|
|
888
|
+
.url()
|
|
889
|
+
.optional()
|
|
890
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket Desktop Bridge connection. Only required if not connected."),
|
|
891
|
+
includePublished: z
|
|
892
|
+
.boolean()
|
|
893
|
+
.optional()
|
|
894
|
+
.default(true)
|
|
895
|
+
.describe("Include published variables from libraries"),
|
|
896
|
+
verbosity: z
|
|
897
|
+
.enum(["inventory", "summary", "standard", "full"])
|
|
898
|
+
.optional()
|
|
899
|
+
.default("standard")
|
|
900
|
+
.describe("Controls payload size: 'inventory' (names/IDs only, ~95% smaller, use with filtered), 'summary' (names/values only, ~80% smaller), 'standard' (essential properties, ~45% smaller), 'full' (everything). Default: standard"),
|
|
901
|
+
enrich: z
|
|
902
|
+
.boolean()
|
|
903
|
+
.optional()
|
|
904
|
+
.describe("Set to true when user asks for: CSS/Sass/Tailwind exports, code examples, design tokens, usage information, dependencies, or any export format. Adds resolved values, dependency graphs, and usage analysis. Default: false"),
|
|
905
|
+
include_usage: z
|
|
906
|
+
.boolean()
|
|
907
|
+
.optional()
|
|
908
|
+
.describe("Include usage in styles and components (requires enrich=true)"),
|
|
909
|
+
include_dependencies: z
|
|
910
|
+
.boolean()
|
|
911
|
+
.optional()
|
|
912
|
+
.describe("Include variable dependency graph (requires enrich=true)"),
|
|
913
|
+
include_exports: z
|
|
914
|
+
.boolean()
|
|
915
|
+
.optional()
|
|
916
|
+
.describe("Include export format examples (requires enrich=true)"),
|
|
917
|
+
export_formats: z
|
|
918
|
+
.array(z.enum(["css", "sass", "tailwind", "typescript", "json"]))
|
|
919
|
+
.optional()
|
|
920
|
+
.describe("Which code formats to generate examples for. Use when user mentions specific formats like 'CSS', 'Tailwind', 'SCSS', 'TypeScript', etc. Automatically enables enrichment."),
|
|
921
|
+
format: z
|
|
922
|
+
.enum(["summary", "filtered", "full"])
|
|
923
|
+
.optional()
|
|
924
|
+
.describe("Response format: 'summary' (~2K tokens with overview and names only), 'filtered' (apply collection/name/mode filters), 'full' (complete dataset from cache or fetch). " +
|
|
925
|
+
"Default: summary (token-efficient). When format is omitted, filter params (collection/namePattern/mode) auto-select 'filtered', and enrichment/export/resolveAliases/returnAsLinks params auto-select 'full'. " +
|
|
926
|
+
"Full format returns all data but may be auto-summarized if >25K tokens."),
|
|
927
|
+
collection: z
|
|
928
|
+
.string()
|
|
929
|
+
.optional()
|
|
930
|
+
.describe("Filter variables by collection name or ID. Case-insensitive substring match. Only applies when format='filtered'. Example: 'Primitives' or 'VariableCollectionId:123'"),
|
|
931
|
+
namePattern: z
|
|
932
|
+
.string()
|
|
933
|
+
.optional()
|
|
934
|
+
.describe("Filter variables by name using regex pattern or substring. Case-insensitive. Only applies when format='filtered'. Example: 'color/brand' or '^typography'"),
|
|
935
|
+
mode: z
|
|
936
|
+
.string()
|
|
937
|
+
.optional()
|
|
938
|
+
.describe("Filter variables by mode name or ID. Only returns variables that have values for this mode. Only applies when format='filtered'. Example: 'Light' or 'Dark'"),
|
|
939
|
+
returnAsLinks: z
|
|
940
|
+
.boolean()
|
|
941
|
+
.optional()
|
|
942
|
+
.default(false)
|
|
943
|
+
.describe("Return variables as resource_link references instead of full data. Drastically reduces payload size (100+ variables = ~20KB vs >1MB). Recommended for large variable sets — combine with format='filtered' + namePattern/collection/mode to fetch only the variables you need. Default: false"),
|
|
944
|
+
refreshCache: z
|
|
945
|
+
.boolean()
|
|
946
|
+
.optional()
|
|
947
|
+
.default(false)
|
|
948
|
+
.describe("Force refresh cache by fetching fresh data from Figma. Use when data may have changed since last fetch. Default: false (use cached data if available and fresh)"),
|
|
949
|
+
useConsoleFallback: z
|
|
950
|
+
.boolean()
|
|
951
|
+
.optional()
|
|
952
|
+
.default(true)
|
|
953
|
+
.describe("DEPRECATED — has no effect. The console-snippet workflow was removed in the Phase 3 CDP cleanup; the Desktop Bridge plugin now handles all non-REST variable extraction automatically. Kept for parameter compatibility only — safe to ignore."),
|
|
954
|
+
parseFromConsole: z
|
|
955
|
+
.boolean()
|
|
956
|
+
.optional()
|
|
957
|
+
.default(false)
|
|
958
|
+
.describe("DEPRECATED — setting this to true now raises an explicit error. The Puppeteer-based console parser no longer exists. Open the Figma Console MCP Desktop Bridge plugin in Figma Desktop and call figma_get_variables() without parseFromConsole; the plugin returns full variable data through the WebSocket bridge."),
|
|
959
|
+
// NOTE: deliberately no .default() on either param. Every consumer below
|
|
960
|
+
// applies its own fallback (?? 1 / ?? 50), and leaving these undefined is
|
|
961
|
+
// what lets format='full' tell "caller asked for page 2" apart from
|
|
962
|
+
// "caller passed nothing" — without that distinction, honoring them would
|
|
963
|
+
// silently truncate every full response to 50 variables.
|
|
964
|
+
page: z
|
|
965
|
+
.number()
|
|
966
|
+
.int()
|
|
967
|
+
.min(1)
|
|
968
|
+
.optional()
|
|
969
|
+
.describe("Page number for paginated results (1-based). Use when the response is too large to handle in one call. Applies to format='filtered' and format='full'. Default: 1. IMPORTANT: a page number beyond the last page is CLAMPED to the last page, not rejected — it returns that page's data again with currentPage set to the real last page. Drive iteration off pagination.hasNextPage; a loop that just increments page will repeat the final page forever."),
|
|
970
|
+
pageSize: z
|
|
971
|
+
.number()
|
|
972
|
+
.int()
|
|
973
|
+
.min(1)
|
|
974
|
+
.max(100)
|
|
975
|
+
.optional()
|
|
976
|
+
.describe("Number of variables per page. Hard limit 100 — higher values are rejected with a validation error, not clamped. Default: 50. Applies to format='filtered' and format='full'. For format='full', pagination is applied only when page or pageSize is explicitly passed; otherwise the complete dataset is returned. SOFT LIMIT: a page that exceeds ~25K estimated tokens is auto-summarized, so the page is discarded rather than returned — measured on a 689-variable file, pageSize=100 reached ~16K tokens at standard verbosity and ~20K with verbosity='full' plus resolveAliases. 100 is safe at roughly 200 tokens/variable; prefer 50 when resolving aliases on a mode-heavy file."),
|
|
977
|
+
resolveAliases: z
|
|
978
|
+
.boolean()
|
|
979
|
+
.optional()
|
|
980
|
+
.default(false)
|
|
981
|
+
.describe("Automatically resolve variable aliases to their final values (hex colors, numbers, etc.). " +
|
|
982
|
+
"When true, each variable will include a 'resolvedValuesByMode' field with the actual values " +
|
|
983
|
+
"instead of just alias references. Useful for getting color hex values without manual resolution. " +
|
|
984
|
+
"Default: false."),
|
|
985
|
+
}),
|
|
980
986
|
}, async ({ fileUrl, includePublished, verbosity, enrich, include_usage, include_dependencies, include_exports, export_formats, format, collection, namePattern, mode, returnAsLinks, refreshCache, useConsoleFallback, parseFromConsole, page, pageSize, resolveAliases }) => {
|
|
981
987
|
// Smart format default (token efficiency): when the caller doesn't pick a
|
|
982
988
|
// format, use the cheapest one their other parameters allow. Explicit
|
|
@@ -1619,20 +1625,10 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1619
1625
|
logger.info({ fileKey }, "Attempting to get variables via Desktop connection");
|
|
1620
1626
|
const connector = await getDesktopConnector();
|
|
1621
1627
|
logger.info({ transport: connector.getTransportType?.() || 'websocket' }, "Desktop connector ready");
|
|
1622
|
-
//
|
|
1623
|
-
//
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
: await connector.getVariablesFromPluginUI(fileKey);
|
|
1627
|
-
// EXECUTE_CODE responses come back wrapped one level deeper:
|
|
1628
|
-
// `{ success: true, result: { success: true, variables, ... } }`
|
|
1629
|
-
// because handleResult in ui.html nests the script return value
|
|
1630
|
-
// under `result`. The plugin-UI cache path (GET_VARIABLES_DATA) does
|
|
1631
|
-
// not nest. Unwrap when we detect the EXECUTE_CODE shape so both
|
|
1632
|
-
// paths produce a uniform { success, variables, ... } below. See #68.
|
|
1633
|
-
const variableData = desktopResult?.result?.variables
|
|
1634
|
-
? desktopResult.result
|
|
1635
|
-
: desktopResult;
|
|
1628
|
+
// Reached only on a server-cache miss or refreshCache: read the
|
|
1629
|
+
// Plugin API live. The plugin UI's own copy dates from when it
|
|
1630
|
+
// connected, so it is stale after any write or edit (#14).
|
|
1631
|
+
const variableData = await connector.readVariables(fileKey);
|
|
1636
1632
|
if (variableData?.success && variableData?.variables) {
|
|
1637
1633
|
logger.info({
|
|
1638
1634
|
variableCount: variableData.variables.length,
|
|
@@ -2066,24 +2062,27 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2066
2062
|
const componentDescription = isRemoteMode
|
|
2067
2063
|
? "Get a SINGLE component's metadata or reconstruction specification. Two export formats: (1) 'metadata' (default) - comprehensive documentation with properties, variants, and design tokens for style guides and references, (2) 'reconstruction' - node tree specification compatible with Figma Component Reconstructor plugin for programmatic component creation. TIP: To get ALL components with visual specs in one call, prefer figma_get_design_system_kit instead."
|
|
2068
2064
|
: "Get a SINGLE component's metadata or reconstruction specification. Two export formats: (1) 'metadata' (default) - comprehensive documentation with properties, variants, and design tokens for style guides and references, (2) 'reconstruction' - node tree specification compatible with Figma Component Reconstructor plugin for programmatic component creation. IMPORTANT: For local/unpublished components with metadata format, ensure the Figma Desktop Bridge plugin is running (Right-click in Figma → Plugins → Development → Figma Desktop Bridge) to get complete description data. TIP: To get ALL components with visual specs in one call, prefer figma_get_design_system_kit instead.";
|
|
2069
|
-
server.
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2065
|
+
server.registerTool("figma_get_component", {
|
|
2066
|
+
description: componentDescription,
|
|
2067
|
+
inputSchema: z.object({
|
|
2068
|
+
fileUrl: z
|
|
2069
|
+
.string()
|
|
2070
|
+
.url()
|
|
2071
|
+
.optional()
|
|
2072
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket Desktop Bridge connection. Only required if not connected."),
|
|
2073
|
+
nodeId: z
|
|
2074
|
+
.string()
|
|
2075
|
+
.describe("Component node ID (e.g., '123:456')"),
|
|
2076
|
+
format: z
|
|
2077
|
+
.enum(["metadata", "reconstruction"])
|
|
2078
|
+
.optional()
|
|
2079
|
+
.default("metadata")
|
|
2080
|
+
.describe("Export format: 'metadata' (default) for comprehensive documentation, 'reconstruction' for node tree specification compatible with Figma Component Reconstructor plugin"),
|
|
2081
|
+
enrich: z
|
|
2082
|
+
.boolean()
|
|
2083
|
+
.optional()
|
|
2084
|
+
.describe("Set to true when user asks for: design token coverage, hardcoded value analysis, or component quality metrics. Adds token coverage analysis and hardcoded value detection. Default: false. Only applicable for metadata format."),
|
|
2085
|
+
}),
|
|
2087
2086
|
}, async ({ fileUrl, nodeId, format = "metadata", enrich }) => {
|
|
2088
2087
|
try {
|
|
2089
2088
|
const url = fileUrl || getCurrentUrl();
|
|
@@ -2303,33 +2302,36 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2303
2302
|
}
|
|
2304
2303
|
});
|
|
2305
2304
|
// Tool 11: Get Styles
|
|
2306
|
-
server.
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2305
|
+
server.registerTool("figma_get_styles", {
|
|
2306
|
+
description: "Get all styles (color, text, effects, grids) from a Figma file with optional code exports. Use when user asks for: text styles, color palette, design system styles, typography, or style documentation. Returns organized style definitions with resolved values. NOT for design tokens/variables (use figma_get_variables). Set enrich=true for CSS/Tailwind/Sass code examples. Supports verbosity control to manage payload size. TIP: For full design system extraction (tokens + components + styles combined), prefer figma_get_design_system_kit instead — it returns everything in one optimized call.",
|
|
2307
|
+
inputSchema: z.object({
|
|
2308
|
+
fileUrl: z
|
|
2309
|
+
.string()
|
|
2310
|
+
.url()
|
|
2311
|
+
.optional()
|
|
2312
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket Desktop Bridge connection. Only required if not connected."),
|
|
2313
|
+
verbosity: z
|
|
2314
|
+
.enum(["summary", "standard", "full"])
|
|
2315
|
+
.optional()
|
|
2316
|
+
.default("standard")
|
|
2317
|
+
.describe("Controls payload size: 'summary' (names/types only, ~85% smaller), 'standard' (essential properties, ~40% smaller), 'full' (everything). Default: standard"),
|
|
2318
|
+
enrich: z
|
|
2319
|
+
.boolean()
|
|
2320
|
+
.optional()
|
|
2321
|
+
.describe("Set to true when user asks for: CSS/Sass/Tailwind code, export formats, usage information, code examples, or design system exports. Adds resolved values, usage analysis, and export format examples. Default: false for backward compatibility"),
|
|
2322
|
+
include_usage: z
|
|
2323
|
+
.boolean()
|
|
2324
|
+
.optional()
|
|
2325
|
+
.describe("Include component usage information (requires enrich=true)"),
|
|
2326
|
+
include_exports: z
|
|
2327
|
+
.boolean()
|
|
2328
|
+
.optional()
|
|
2329
|
+
.describe("Include export format examples (requires enrich=true)"),
|
|
2330
|
+
export_formats: z
|
|
2331
|
+
.array(z.enum(["css", "sass", "tailwind", "typescript", "json"]))
|
|
2332
|
+
.optional()
|
|
2333
|
+
.describe("Which code formats to generate examples for. Use when user mentions specific formats like 'CSS', 'Tailwind', 'SCSS', 'TypeScript', etc. Automatically enables enrichment. Default: all formats"),
|
|
2334
|
+
}),
|
|
2333
2335
|
}, async ({ fileUrl, verbosity, enrich, include_usage, include_exports, export_formats }) => {
|
|
2334
2336
|
try {
|
|
2335
2337
|
let api;
|
|
@@ -2445,27 +2447,30 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2445
2447
|
}
|
|
2446
2448
|
});
|
|
2447
2449
|
// Tool 12: Get Component Image (Visual Reference)
|
|
2448
|
-
server.
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2450
|
+
server.registerTool("figma_get_component_image", {
|
|
2451
|
+
description: "Render a specific component or node as an image (PNG, JPG, SVG, PDF). Returns image URL valid for 30 days. Use when user asks for: component screenshot, visual preview, rendered output, or 'show me'. NOT for component metadata/properties (use figma_get_component). NOT for getting code/layout data (use figma_get_component_for_development). Best for: visual references, design review, documentation.",
|
|
2452
|
+
inputSchema: z.object({
|
|
2453
|
+
fileUrl: z
|
|
2454
|
+
.string()
|
|
2455
|
+
.url()
|
|
2456
|
+
.optional()
|
|
2457
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket Desktop Bridge connection. Only required if not connected."),
|
|
2458
|
+
nodeId: z
|
|
2459
|
+
.string()
|
|
2460
|
+
.describe("Component node ID to render as image (e.g., '695:313')"),
|
|
2461
|
+
scale: z
|
|
2462
|
+
.number()
|
|
2463
|
+
.min(0.01)
|
|
2464
|
+
.max(4)
|
|
2465
|
+
.optional()
|
|
2466
|
+
.default(2)
|
|
2467
|
+
.describe("Image scale factor (0.01-4, default: 2 for high quality)"),
|
|
2468
|
+
format: z
|
|
2469
|
+
.enum(["png", "jpg", "svg", "pdf"])
|
|
2470
|
+
.optional()
|
|
2471
|
+
.default("png")
|
|
2472
|
+
.describe("Image format (default: png)"),
|
|
2473
|
+
}),
|
|
2469
2474
|
}, async ({ fileUrl, nodeId, scale, format }) => {
|
|
2470
2475
|
try {
|
|
2471
2476
|
// Accept URL-format ids (123-456); the REST response maps key by
|
|
@@ -2564,24 +2569,27 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2564
2569
|
}
|
|
2565
2570
|
});
|
|
2566
2571
|
// Tool 13: Get Component for Development (UI Implementation)
|
|
2567
|
-
server.
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2572
|
+
server.registerTool("figma_get_component_for_development", {
|
|
2573
|
+
description: "Get component data optimized for high-fidelity UI implementation. Returns a deep component tree (depth 4) with design tokens (boundVariables), interaction states (reactions), sizing constraints (min/max/layoutSizing), text behavior (autoResize, truncation), Figma slots (named freeform-content regions on a component, with the components each accepts and any min/max limit violations), and design annotations. Automatically includes 2x rendered image. Use when user asks to: 'build this component', 'implement this in React/Vue', 'generate code for', or needs both visual reference and technical specs for production-quality, accessible, token-aware code. For just metadata/descriptions, use figma_get_component. For just image, use figma_get_component_image. For full annotation details, use figma_get_annotations. To resolve variable IDs to names/values, use figma_get_variables.",
|
|
2574
|
+
inputSchema: z.object({
|
|
2575
|
+
fileUrl: z
|
|
2576
|
+
.string()
|
|
2577
|
+
.url()
|
|
2578
|
+
.optional()
|
|
2579
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). REQUIRED unless figma_navigate was already called."),
|
|
2580
|
+
nodeId: z
|
|
2581
|
+
.string()
|
|
2582
|
+
.describe("Component node ID to get data for (e.g., '695:313')"),
|
|
2583
|
+
includeImage: z
|
|
2584
|
+
.boolean()
|
|
2585
|
+
.optional()
|
|
2586
|
+
.default(true)
|
|
2587
|
+
.describe("Include rendered image for visual reference (default: true)"),
|
|
2588
|
+
codebasePath: z
|
|
2589
|
+
.string()
|
|
2590
|
+
.optional()
|
|
2591
|
+
.describe("Path to target codebase components directory (e.g., '/Users/me/project/src/components'). When provided, scans for existing components and includes a registry in the response to prevent recreating components that already exist. Strongly recommended for design-to-code workflows."),
|
|
2592
|
+
}),
|
|
2585
2593
|
}, async ({ fileUrl, nodeId, includeImage, codebasePath }) => {
|
|
2586
2594
|
try {
|
|
2587
2595
|
let api;
|
|
@@ -3005,23 +3013,26 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3005
3013
|
}
|
|
3006
3014
|
});
|
|
3007
3015
|
// Tool 14: Get File for Plugin Development
|
|
3008
|
-
server.
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3016
|
+
server.registerTool("figma_get_file_for_plugin", {
|
|
3017
|
+
description: "Get file data optimized for plugin development with filtered properties (IDs, structure, plugin data, component relationships). Excludes visual properties (fills, strokes, effects) to reduce payload. Use when user asks for: plugin development, file structure for manipulation, node IDs for plugin API. NOT for component descriptions (use figma_get_component). NOT for visual/styling data (use figma_get_component_for_development). Supports deeper tree traversal (max depth=5) than figma_get_file_data.",
|
|
3018
|
+
inputSchema: z.object({
|
|
3019
|
+
fileUrl: z
|
|
3020
|
+
.string()
|
|
3021
|
+
.url()
|
|
3022
|
+
.optional()
|
|
3023
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). REQUIRED unless figma_navigate was already called."),
|
|
3024
|
+
depth: z
|
|
3025
|
+
.number()
|
|
3026
|
+
.min(0)
|
|
3027
|
+
.max(5)
|
|
3028
|
+
.optional()
|
|
3029
|
+
.default(2)
|
|
3030
|
+
.describe("How many levels of children to include (default: 2, max: 5). Higher depths are safe here due to filtering."),
|
|
3031
|
+
nodeIds: z
|
|
3032
|
+
.array(z.string())
|
|
3033
|
+
.optional()
|
|
3034
|
+
.describe("Specific node IDs to retrieve (optional)"),
|
|
3035
|
+
}),
|
|
3025
3036
|
}, async ({ fileUrl, depth, nodeIds }) => {
|
|
3026
3037
|
try {
|
|
3027
3038
|
let api;
|
|
@@ -3190,23 +3201,26 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3190
3201
|
// Tool 15: Capture Screenshot via Plugin (Desktop Bridge)
|
|
3191
3202
|
// This uses exportAsync() which reads the current plugin runtime state, not the cloud state
|
|
3192
3203
|
// Solves race condition where REST API screenshots show stale data after changes
|
|
3193
|
-
server.
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3204
|
+
server.registerTool("figma_capture_screenshot", {
|
|
3205
|
+
description: "Capture a screenshot of a node using the plugin's exportAsync API. IMPORTANT: This tool captures the CURRENT state from the plugin runtime (not cloud state like REST API), making it reliable for validating changes immediately after making them. Use this instead of figma_get_component_image when you need to verify that changes were applied correctly. Defaults are AI-optimized: PNG at 1x with automatic downscaling so the longest side stays within the 1568px AI vision processing ceiling. PNG is the default because design tool content (flat colors, text, UI components) compresses significantly better as PNG. Use JPG for photographic or gradient-heavy content. Requires Desktop Bridge connection (Figma Desktop with plugin running).",
|
|
3206
|
+
inputSchema: z.object({
|
|
3207
|
+
nodeId: z
|
|
3208
|
+
.string()
|
|
3209
|
+
.optional()
|
|
3210
|
+
.describe("ID of the node to capture (e.g., '1:234'). If not provided, captures the current page."),
|
|
3211
|
+
format: z
|
|
3212
|
+
.enum(["PNG", "JPG", "SVG"])
|
|
3213
|
+
.optional()
|
|
3214
|
+
.default("PNG")
|
|
3215
|
+
.describe("Image format (default: PNG). Use JPG for photographic or gradient-heavy content."),
|
|
3216
|
+
scale: z
|
|
3217
|
+
.number()
|
|
3218
|
+
.min(0.5)
|
|
3219
|
+
.max(4)
|
|
3220
|
+
.optional()
|
|
3221
|
+
.default(1)
|
|
3222
|
+
.describe("Scale factor (default: 1). The plugin automatically caps the effective scale so the exported image does not exceed 1568px on its longest side (the AI vision processing ceiling)."),
|
|
3223
|
+
}),
|
|
3210
3224
|
}, async ({ nodeId, format, scale }) => {
|
|
3211
3225
|
try {
|
|
3212
3226
|
logger.info({ nodeId, format, scale }, "Capturing screenshot via Desktop Bridge");
|
|
@@ -3280,15 +3294,18 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3280
3294
|
// Tool 16: Set Instance Properties (Desktop Bridge)
|
|
3281
3295
|
// Updates component properties on an instance using setProperties()
|
|
3282
3296
|
// This is the correct way to update TEXT/BOOLEAN/VARIANT properties on component instances
|
|
3283
|
-
server.
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3297
|
+
server.registerTool("figma_set_instance_properties", {
|
|
3298
|
+
description: "Update component properties on a component instance. IMPORTANT: Use this tool instead of trying to edit text nodes directly when working with component instances. Components often expose TEXT, BOOLEAN, INSTANCE_SWAP, and VARIANT properties that control their content. SLOT properties CANNOT be set here — use figma_append_to_slot to populate slot content. Direct text node editing may fail silently if the component uses properties. This tool handles the #nodeId suffix pattern automatically. Requires Desktop Bridge connection.",
|
|
3299
|
+
inputSchema: z.object({
|
|
3300
|
+
nodeId: z
|
|
3301
|
+
.string()
|
|
3302
|
+
.describe("ID of the INSTANCE node to update (e.g., '1:234'). Must be a component instance, not a regular frame."),
|
|
3303
|
+
properties: z
|
|
3304
|
+
.record(z.string(), z.union([z.string(), z.boolean()]))
|
|
3305
|
+
.describe("Properties to set. Keys are property names (e.g., 'Label', 'Show Icon', 'Size'). " +
|
|
3306
|
+
"Values are strings for TEXT/VARIANT properties, booleans for BOOLEAN properties. " +
|
|
3307
|
+
"The tool automatically handles the #nodeId suffix for TEXT/BOOLEAN/INSTANCE_SWAP properties."),
|
|
3308
|
+
}),
|
|
3292
3309
|
}, async ({ nodeId, properties }) => {
|
|
3293
3310
|
try {
|
|
3294
3311
|
logger.info({ nodeId, properties: Object.keys(properties) }, "Setting instance properties via Desktop Bridge");
|