@muloka/figma-console-mcp 0.6.4 → 0.6.6
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 +18 -6
- package/dist/apps/design-system-dashboard/mcp-app.html +20 -20
- package/dist/apps/design-system-dashboard/scoring/accessibility.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/accessibility.js +2 -1
- package/dist/apps/design-system-dashboard/scoring/accessibility.js.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/coverage.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/coverage.js +2 -1
- package/dist/apps/design-system-dashboard/scoring/coverage.js.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/token-architecture.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js +2 -1
- package/dist/apps/design-system-dashboard/scoring/token-architecture.js.map +1 -1
- package/dist/apps/design-system-dashboard/server.d.ts.map +1 -1
- package/dist/apps/design-system-dashboard/server.js +2 -1
- package/dist/apps/design-system-dashboard/server.js.map +1 -1
- package/dist/core/annotation-tools.d.ts.map +1 -1
- package/dist/core/annotation-tools.js +7 -6
- package/dist/core/annotation-tools.js.map +1 -1
- package/dist/core/cache-invalidation.d.ts +18 -2
- package/dist/core/cache-invalidation.d.ts.map +1 -1
- package/dist/core/cache-invalidation.js +51 -0
- package/dist/core/cache-invalidation.js.map +1 -1
- package/dist/core/call-context.d.ts +13 -0
- package/dist/core/call-context.d.ts.map +1 -0
- package/dist/core/call-context.js +20 -0
- package/dist/core/call-context.js.map +1 -0
- package/dist/core/comment-tools.d.ts.map +1 -1
- package/dist/core/comment-tools.js +4 -3
- package/dist/core/comment-tools.js.map +1 -1
- package/dist/core/deep-component-tools.d.ts.map +1 -1
- package/dist/core/deep-component-tools.js +5 -4
- package/dist/core/deep-component-tools.js.map +1 -1
- package/dist/core/design-code-tools.d.ts.map +1 -1
- package/dist/core/design-code-tools.js +4 -3
- package/dist/core/design-code-tools.js.map +1 -1
- package/dist/core/design-system-manifest.d.ts +7 -3
- package/dist/core/design-system-manifest.d.ts.map +1 -1
- package/dist/core/design-system-manifest.js +14 -5
- package/dist/core/design-system-manifest.js.map +1 -1
- package/dist/core/design-system-tools.d.ts.map +1 -1
- package/dist/core/design-system-tools.js +2 -1
- package/dist/core/design-system-tools.js.map +1 -1
- package/dist/core/diagnose-tool.d.ts +2 -0
- package/dist/core/diagnose-tool.d.ts.map +1 -1
- package/dist/core/diagnose-tool.js +6 -5
- package/dist/core/diagnose-tool.js.map +1 -1
- package/dist/core/figjam-tools.d.ts.map +1 -1
- package/dist/core/figjam-tools.js +5 -4
- package/dist/core/figjam-tools.js.map +1 -1
- package/dist/core/figma-api.d.ts +12 -0
- package/dist/core/figma-api.d.ts.map +1 -1
- package/dist/core/figma-api.js +17 -1
- package/dist/core/figma-api.js.map +1 -1
- package/dist/core/figma-tools.d.ts.map +1 -1
- package/dist/core/figma-tools.js +42 -53
- package/dist/core/figma-tools.js.map +1 -1
- package/dist/core/library-tools.d.ts.map +1 -1
- package/dist/core/library-tools.js +7 -6
- package/dist/core/library-tools.js.map +1 -1
- package/dist/core/logger.d.ts +11 -0
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +13 -1
- package/dist/core/logger.js.map +1 -1
- package/dist/core/plugin-import-dir.d.ts +9 -0
- package/dist/core/plugin-import-dir.d.ts.map +1 -0
- package/dist/core/plugin-import-dir.js +47 -0
- package/dist/core/plugin-import-dir.js.map +1 -0
- package/dist/core/plugin-name.d.ts +26 -0
- package/dist/core/plugin-name.d.ts.map +1 -0
- package/dist/core/plugin-name.js +35 -0
- package/dist/core/plugin-name.js.map +1 -0
- package/dist/core/port-discovery.d.ts +2 -2
- package/dist/core/port-discovery.d.ts.map +1 -1
- package/dist/core/port-discovery.js +8 -6
- package/dist/core/port-discovery.js.map +1 -1
- package/dist/core/slides-tools.d.ts.map +1 -1
- package/dist/core/slides-tools.js +2 -1
- package/dist/core/slides-tools.js.map +1 -1
- package/dist/core/slot-tools.d.ts.map +1 -1
- package/dist/core/slot-tools.js +3 -2
- package/dist/core/slot-tools.js.map +1 -1
- package/dist/core/tokens/schemas.d.ts +1 -1
- package/dist/core/tokens-tools.d.ts.map +1 -1
- package/dist/core/tokens-tools.js +2 -1
- package/dist/core/tokens-tools.js.map +1 -1
- package/dist/core/variable-resolver.d.ts.map +1 -1
- package/dist/core/variable-resolver.js +3 -2
- package/dist/core/variable-resolver.js.map +1 -1
- package/dist/core/version-tools.d.ts.map +1 -1
- package/dist/core/version-tools.js +9 -8
- package/dist/core/version-tools.js.map +1 -1
- package/dist/core/websocket-connector.d.ts.map +1 -1
- package/dist/core/websocket-connector.js +3 -2
- package/dist/core/websocket-connector.js.map +1 -1
- package/dist/core/websocket-server.d.ts.map +1 -1
- package/dist/core/websocket-server.js +8 -5
- package/dist/core/websocket-server.js.map +1 -1
- package/dist/core/write-tools.d.ts.map +1 -1
- package/dist/core/write-tools.js +283 -232
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +114 -190
- package/dist/local.js.map +1 -1
- package/figma-desktop-bridge/README.md +15 -63
- package/figma-desktop-bridge/code.js +31 -29
- package/figma-desktop-bridge/manifest.json +5 -9
- package/figma-desktop-bridge/ui.html +768 -924
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figma-tools.d.ts","sourceRoot":"","sources":["../../src/core/figma-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"figma-tools.d.ts","sourceRoot":"","sources":["../../src/core/figma-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AA6xB7D;;GAEG;AACH,UAAU,oBAAoB;IAC7B,iGAAiG;IACjG,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,EACpC,aAAa,EAAE,MAAM,MAAM,GAAG,IAAI,EAClC,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,EAC9D,OAAO,CAAC,EAAE,oBAAoB,EAC9B,mBAAmB,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAoqGxC"}
|
package/dist/core/figma-tools.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* Figma API MCP Tools
|
|
3
3
|
* MCP tool definitions for Figma REST API data extraction
|
|
4
4
|
*/
|
|
5
|
+
import { PLUGIN_NAME, PLUGIN_NAME_WITH_OLD, PLUGIN_MENU_PATH } from "./plugin-name.js";
|
|
5
6
|
import { z } from "zod";
|
|
6
7
|
import * as fs from "fs";
|
|
7
8
|
import * as path from "path";
|
|
8
|
-
import { extractFileKey, extractFigmaUrlInfo, formatVariables, formatComponentData, withTimeout } from "./figma-api.js";
|
|
9
|
+
import { extractFileKey, extractFigmaUrlInfo, formatVariables, restVariablesCacheData, formatComponentData, withTimeout } from "./figma-api.js";
|
|
9
10
|
import { createChildLogger } from "./logger.js";
|
|
10
11
|
import { cacheGeneration, evictCacheEntry, setCacheIfCurrent } from "./variables-cache.js";
|
|
11
12
|
import { identifiedError, withIdentity } from "./identity.js";
|
|
@@ -704,7 +705,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
704
705
|
.string()
|
|
705
706
|
.url()
|
|
706
707
|
.optional()
|
|
707
|
-
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket
|
|
708
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from the WebSocket connection to the " + PLUGIN_NAME + " plugin. Only required if not connected."),
|
|
708
709
|
depth: z
|
|
709
710
|
.number()
|
|
710
711
|
.min(0)
|
|
@@ -735,12 +736,12 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
735
736
|
}
|
|
736
737
|
catch (apiError) {
|
|
737
738
|
const errorMessage = apiError instanceof Error ? apiError.message : String(apiError);
|
|
738
|
-
throw restAuthError("Cannot retrieve file data. REST API authentication required.", errorMessage, "Note: figma_get_file_data requires REST API access. For component-specific data, use figma_get_component which has
|
|
739
|
+
throw restAuthError("Cannot retrieve file data. REST API authentication required.", errorMessage, "Note: figma_get_file_data requires REST API access. For component-specific data, use figma_get_component which has a fallback through the " + PLUGIN_NAME + " plugin.");
|
|
739
740
|
}
|
|
740
741
|
// Use provided URL or current URL from browser
|
|
741
742
|
const url = fileUrl || getCurrentUrl();
|
|
742
743
|
if (!url) {
|
|
743
|
-
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the
|
|
744
|
+
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is open in Figma.");
|
|
744
745
|
}
|
|
745
746
|
const fileKey = extractFileKey(url);
|
|
746
747
|
if (!fileKey) {
|
|
@@ -899,13 +900,13 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
899
900
|
* throws an identified error pointing the caller at the bridge.
|
|
900
901
|
*/
|
|
901
902
|
server.registerTool("figma_get_variables", {
|
|
902
|
-
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:
|
|
903
|
+
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: the " + PLUGIN_NAME + " 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.",
|
|
903
904
|
inputSchema: z.object({
|
|
904
905
|
fileUrl: z
|
|
905
906
|
.string()
|
|
906
907
|
.url()
|
|
907
908
|
.optional()
|
|
908
|
-
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket
|
|
909
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from the WebSocket connection to the " + PLUGIN_NAME + " plugin. Only required if not connected."),
|
|
909
910
|
includePublished: z
|
|
910
911
|
.boolean()
|
|
911
912
|
.optional()
|
|
@@ -968,12 +969,12 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
968
969
|
.boolean()
|
|
969
970
|
.optional()
|
|
970
971
|
.default(true)
|
|
971
|
-
.describe("DEPRECATED — has no effect. The console-snippet workflow was removed in the Phase 3 CDP cleanup; the
|
|
972
|
+
.describe("DEPRECATED — has no effect. The console-snippet workflow was removed in the Phase 3 CDP cleanup; the " + PLUGIN_NAME + " plugin now handles all non-REST variable extraction automatically. Kept for parameter compatibility only — safe to ignore."),
|
|
972
973
|
parseFromConsole: z
|
|
973
974
|
.boolean()
|
|
974
975
|
.optional()
|
|
975
976
|
.default(false)
|
|
976
|
-
.describe("DEPRECATED — setting this to true now raises an explicit error. The Puppeteer-based console parser no longer exists. Open the
|
|
977
|
+
.describe("DEPRECATED — setting this to true now raises an explicit error. The Puppeteer-based console parser no longer exists. Open the " + PLUGIN_NAME + " plugin in Figma Desktop and call figma_get_variables() without parseFromConsole; the plugin returns full variable data through the WebSocket bridge."),
|
|
977
978
|
// NOTE: deliberately no .default() on either param. Every consumer below
|
|
978
979
|
// applies its own fallback (?? 1 / ?? 50), and leaving these undefined is
|
|
979
980
|
// what lets format='full' tell "caller asked for page 2" apart from
|
|
@@ -1033,7 +1034,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1033
1034
|
type: "text",
|
|
1034
1035
|
text: JSON.stringify({
|
|
1035
1036
|
error: "No Figma file URL available",
|
|
1036
|
-
message: "Pass the fileUrl parameter or ensure the
|
|
1037
|
+
message: "Pass the fileUrl parameter or ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is open in Figma."
|
|
1037
1038
|
}),
|
|
1038
1039
|
},
|
|
1039
1040
|
],
|
|
@@ -1386,13 +1387,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1386
1387
|
// write or edit invalidated the cache while this read ran.
|
|
1387
1388
|
if (variablesCache) {
|
|
1388
1389
|
const stored = setCacheIfCurrent(variablesCache, fileKey, {
|
|
1389
|
-
data:
|
|
1390
|
-
fileKey,
|
|
1391
|
-
source: "rest_api",
|
|
1392
|
-
timestamp: Date.now(),
|
|
1393
|
-
variables: (localFormatted.variables || []).map((v) => ({ ...v })),
|
|
1394
|
-
variableCollections: (localFormatted.collections || []).map((c) => ({ ...c })),
|
|
1395
|
-
},
|
|
1390
|
+
data: restVariablesCacheData(fileKey, local),
|
|
1396
1391
|
timestamp: Date.now(),
|
|
1397
1392
|
}, startedAt, () => evictOldestCacheEntry(variablesCache));
|
|
1398
1393
|
logger.info({ fileKey, variableCount: localFormatted.variables?.length }, stored
|
|
@@ -1852,7 +1847,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1852
1847
|
],
|
|
1853
1848
|
};
|
|
1854
1849
|
}
|
|
1855
|
-
desktopBridgeFailure = "
|
|
1850
|
+
desktopBridgeFailure = "The " + PLUGIN_NAME + " plugin returned no variables data";
|
|
1856
1851
|
}
|
|
1857
1852
|
catch (desktopError) {
|
|
1858
1853
|
const errorMessage = desktopError instanceof Error ? desktopError.message : String(desktopError);
|
|
@@ -1881,13 +1876,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1881
1876
|
// the cache was invalidated while this read ran.
|
|
1882
1877
|
if (variablesCache) {
|
|
1883
1878
|
setCacheIfCurrent(variablesCache, fileKey, {
|
|
1884
|
-
data:
|
|
1885
|
-
fileKey,
|
|
1886
|
-
source: "rest_api",
|
|
1887
|
-
timestamp: Date.now(),
|
|
1888
|
-
variables: (localFormatted.variables || []).map((v) => ({ ...v })),
|
|
1889
|
-
variableCollections: (localFormatted.collections || []).map((c) => ({ ...c })),
|
|
1890
|
-
},
|
|
1879
|
+
data: restVariablesCacheData(fileKey, local),
|
|
1891
1880
|
timestamp: Date.now(),
|
|
1892
1881
|
}, startedAt, () => evictOldestCacheEntry(variablesCache));
|
|
1893
1882
|
}
|
|
@@ -1972,7 +1961,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1972
1961
|
throw identifiedError("parseFromConsole is no longer supported.\n\n" +
|
|
1973
1962
|
"The console-snippet workflow it relied on required a Puppeteer browser " +
|
|
1974
1963
|
"connection to Figma Desktop, which was removed in Phase 3 of the cleanup. " +
|
|
1975
|
-
"To extract variables, open the
|
|
1964
|
+
"To extract variables, open the " + PLUGIN_NAME_WITH_OLD + " plugin in " +
|
|
1976
1965
|
"Figma Desktop and call figma_get_variables() without parseFromConsole — " +
|
|
1977
1966
|
"the plugin returns full variable data through the WebSocket bridge.");
|
|
1978
1967
|
}
|
|
@@ -1984,10 +1973,10 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1984
1973
|
throw new VariablesReadFailedError(`Cannot retrieve variables. All methods failed.\n\n` +
|
|
1985
1974
|
`Tried methods:\n` +
|
|
1986
1975
|
`${restFailure ? `✗ REST API: ${restFailure}\n` : ''}` +
|
|
1987
|
-
`✗
|
|
1976
|
+
`✗ ${PLUGIN_NAME} plugin: ${causes.desktopBridge}\n` +
|
|
1988
1977
|
`\nTo fix:\n` +
|
|
1989
1978
|
`1. If you have FIGMA_ACCESS_TOKEN: Check your token permissions\n` +
|
|
1990
|
-
`2. Install and run the
|
|
1979
|
+
`2. Install and run the ${PLUGIN_NAME_WITH_OLD} plugin and re-run this tool`, causes);
|
|
1991
1980
|
}
|
|
1992
1981
|
catch (error) {
|
|
1993
1982
|
logger.error({ error }, "Failed to get variables");
|
|
@@ -2005,8 +1994,8 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2005
1994
|
message: "Failed to retrieve Figma variables",
|
|
2006
1995
|
causes: error.causes,
|
|
2007
1996
|
hint: error.causes.restApi
|
|
2008
|
-
? "Both reads failed; see causes for each. Open the
|
|
2009
|
-
: "Open the
|
|
1997
|
+
? "Both reads failed; see causes for each. Open the " + PLUGIN_NAME_WITH_OLD + " plugin in the file (variables work on any plan without a REST token). The REST API read needs a FIGMA_ACCESS_TOKEN on an Enterprise plan; causes.restApi says why it failed."
|
|
1998
|
+
: "Open the " + PLUGIN_NAME_WITH_OLD + " plugin in the file (variables work on any plan without a REST token). On an Enterprise plan, setting FIGMA_ACCESS_TOKEN also enables the REST API fallback.",
|
|
2010
1999
|
}),
|
|
2011
2000
|
},
|
|
2012
2001
|
],
|
|
@@ -2027,7 +2016,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2027
2016
|
text: JSON.stringify({
|
|
2028
2017
|
error: errorMessage,
|
|
2029
2018
|
message: "Failed to retrieve Figma variables — REST token is expired or invalid",
|
|
2030
|
-
hint: "Generate a new personal access token at figma.com → Settings → Security → Personal access tokens and update FIGMA_ACCESS_TOKEN. Or open the
|
|
2019
|
+
hint: "Generate a new personal access token at figma.com → Settings → Security → Personal access tokens and update FIGMA_ACCESS_TOKEN. Or open the " + PLUGIN_NAME_WITH_OLD + " plugin in Figma Desktop — variables work on any plan without a REST token.",
|
|
2031
2020
|
}),
|
|
2032
2021
|
},
|
|
2033
2022
|
],
|
|
@@ -2088,7 +2077,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2088
2077
|
"The file structure may not contain extractable styles",
|
|
2089
2078
|
"There may be a network or authentication issue"
|
|
2090
2079
|
],
|
|
2091
|
-
suggestion: "Please ensure the file is accessible and try again, or check if your token has the necessary permissions. With the
|
|
2080
|
+
suggestion: "Please ensure the file is accessible and try again, or check if your token has the necessary permissions. With the " + PLUGIN_NAME_WITH_OLD + " plugin open in Figma Desktop, variables work on any plan without a REST token.",
|
|
2092
2081
|
technical: styleError instanceof Error ? styleError.message : String(styleError)
|
|
2093
2082
|
}),
|
|
2094
2083
|
},
|
|
@@ -2106,8 +2095,8 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2106
2095
|
error: errorMessage,
|
|
2107
2096
|
message: "Failed to retrieve Figma variables",
|
|
2108
2097
|
hint: errorMessage.includes("403")
|
|
2109
|
-
? "The Variables REST API requires an Enterprise plan. Open the
|
|
2110
|
-
: "Make sure FIGMA_ACCESS_TOKEN is configured and has appropriate permissions, or open the
|
|
2098
|
+
? "The Variables REST API requires an Enterprise plan. Open the " + PLUGIN_NAME_WITH_OLD + " plugin in Figma Desktop instead — variables work on any plan through the bridge."
|
|
2099
|
+
: "Make sure FIGMA_ACCESS_TOKEN is configured and has appropriate permissions, or open the " + PLUGIN_NAME_WITH_OLD + " plugin in Figma Desktop",
|
|
2111
2100
|
}),
|
|
2112
2101
|
},
|
|
2113
2102
|
],
|
|
@@ -2118,7 +2107,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2118
2107
|
// Tool 10: Get Component Data
|
|
2119
2108
|
const componentDescription = isRemoteMode
|
|
2120
2109
|
? "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."
|
|
2121
|
-
: "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
|
|
2110
|
+
: "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 " + PLUGIN_NAME + " plugin is running (Right-click in Figma → " + PLUGIN_MENU_PATH + ") to get complete description data. TIP: To get ALL components with visual specs in one call, prefer figma_get_design_system_kit instead.";
|
|
2122
2111
|
server.registerTool("figma_get_component", {
|
|
2123
2112
|
description: componentDescription,
|
|
2124
2113
|
inputSchema: z.object({
|
|
@@ -2126,7 +2115,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2126
2115
|
.string()
|
|
2127
2116
|
.url()
|
|
2128
2117
|
.optional()
|
|
2129
|
-
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket
|
|
2118
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from the WebSocket connection to the " + PLUGIN_NAME + " plugin. Only required if not connected."),
|
|
2130
2119
|
nodeId: z
|
|
2131
2120
|
.string()
|
|
2132
2121
|
.describe("Component node ID (e.g., '123:456')"),
|
|
@@ -2144,7 +2133,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2144
2133
|
try {
|
|
2145
2134
|
const url = fileUrl || getCurrentUrl();
|
|
2146
2135
|
if (!url) {
|
|
2147
|
-
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the
|
|
2136
|
+
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is open in Figma.");
|
|
2148
2137
|
}
|
|
2149
2138
|
const fileKey = extractFileKey(url);
|
|
2150
2139
|
if (!fileKey) {
|
|
@@ -2242,7 +2231,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2242
2231
|
annotations: annotationSummary,
|
|
2243
2232
|
source: "desktop_bridge_plugin",
|
|
2244
2233
|
enriched: enrich || false,
|
|
2245
|
-
note: "Retrieved via
|
|
2234
|
+
note: "Retrieved via the " + PLUGIN_NAME + " plugin - description fields and annotations are reliable and current"
|
|
2246
2235
|
}),
|
|
2247
2236
|
},
|
|
2248
2237
|
],
|
|
@@ -2265,7 +2254,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2265
2254
|
const dbStatus = getDesktopConnector
|
|
2266
2255
|
? "Failed (see logs above)"
|
|
2267
2256
|
: "Not available";
|
|
2268
|
-
throw restAuthError("Cannot retrieve component data. Both
|
|
2257
|
+
throw restAuthError("Cannot retrieve component data. Both the " + PLUGIN_NAME + " plugin and REST API are unavailable.", `${PLUGIN_NAME} plugin: ${dbStatus}; REST API: ${errorMessage}`, "Alternatively: open the " + PLUGIN_NAME_WITH_OLD + " plugin in Figma Desktop to enable the plugin-based fallback.");
|
|
2269
2258
|
}
|
|
2270
2259
|
const componentData = await api.getComponentData(fileKey, nodeId);
|
|
2271
2260
|
if (!componentData) {
|
|
@@ -2334,7 +2323,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2334
2323
|
source: "rest_api",
|
|
2335
2324
|
enriched: enrich || false,
|
|
2336
2325
|
warning: "Retrieved via REST API - description field may be missing due to known Figma API bug",
|
|
2337
|
-
action_required: formatted.description || formatted.descriptionMarkdown ? null : "To get reliable component descriptions, run the
|
|
2326
|
+
action_required: formatted.description || formatted.descriptionMarkdown ? null : "To get reliable component descriptions, run the " + PLUGIN_NAME + " plugin in Figma Desktop: Right-click → " + PLUGIN_MENU_PATH + ", then try again."
|
|
2338
2327
|
}),
|
|
2339
2328
|
},
|
|
2340
2329
|
],
|
|
@@ -2366,7 +2355,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2366
2355
|
.string()
|
|
2367
2356
|
.url()
|
|
2368
2357
|
.optional()
|
|
2369
|
-
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket
|
|
2358
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from the WebSocket connection to the " + PLUGIN_NAME + " plugin. Only required if not connected."),
|
|
2370
2359
|
verbosity: z
|
|
2371
2360
|
.enum(["summary", "standard", "full"])
|
|
2372
2361
|
.optional()
|
|
@@ -2401,7 +2390,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2401
2390
|
}
|
|
2402
2391
|
const url = fileUrl || getCurrentUrl();
|
|
2403
2392
|
if (!url) {
|
|
2404
|
-
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the
|
|
2393
|
+
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is open in Figma.");
|
|
2405
2394
|
}
|
|
2406
2395
|
const fileKey = extractFileKey(url);
|
|
2407
2396
|
if (!fileKey) {
|
|
@@ -2511,7 +2500,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2511
2500
|
.string()
|
|
2512
2501
|
.url()
|
|
2513
2502
|
.optional()
|
|
2514
|
-
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from WebSocket
|
|
2503
|
+
.describe("Figma file URL (e.g., https://figma.com/design/abc123). Auto-detected from the WebSocket connection to the " + PLUGIN_NAME + " plugin. Only required if not connected."),
|
|
2515
2504
|
nodeId: z
|
|
2516
2505
|
.string()
|
|
2517
2506
|
.describe("Component node ID to render as image (e.g., '695:313')"),
|
|
@@ -2539,11 +2528,11 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2539
2528
|
}
|
|
2540
2529
|
catch (apiError) {
|
|
2541
2530
|
const errorMessage = apiError instanceof Error ? apiError.message : String(apiError);
|
|
2542
|
-
throw restAuthError("Cannot render component image. REST API authentication required.", errorMessage, "Note: For component screenshots, figma_capture_screenshot may work as an alternative if the
|
|
2531
|
+
throw restAuthError("Cannot render component image. REST API authentication required.", errorMessage, "Note: For component screenshots, figma_capture_screenshot may work as an alternative if the " + PLUGIN_NAME_WITH_OLD + " plugin is connected.");
|
|
2543
2532
|
}
|
|
2544
2533
|
const url = fileUrl || getCurrentUrl();
|
|
2545
2534
|
if (!url) {
|
|
2546
|
-
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the
|
|
2535
|
+
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is open in Figma.");
|
|
2547
2536
|
}
|
|
2548
2537
|
const fileKey = extractFileKey(url);
|
|
2549
2538
|
if (!fileKey) {
|
|
@@ -2655,11 +2644,11 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2655
2644
|
}
|
|
2656
2645
|
catch (apiError) {
|
|
2657
2646
|
const errorMessage = apiError instanceof Error ? apiError.message : String(apiError);
|
|
2658
|
-
throw restAuthError("Cannot retrieve component for development. REST API authentication required.", errorMessage, "Note: For component metadata, figma_get_component has a
|
|
2647
|
+
throw restAuthError("Cannot retrieve component for development. REST API authentication required.", errorMessage, "Note: For component metadata, figma_get_component has a fallback through the " + PLUGIN_NAME + " plugin that works without a token (requires the " + PLUGIN_NAME + " plugin to be connected).");
|
|
2659
2648
|
}
|
|
2660
2649
|
const url = fileUrl || getCurrentUrl();
|
|
2661
2650
|
if (!url) {
|
|
2662
|
-
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the
|
|
2651
|
+
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is open in Figma.");
|
|
2663
2652
|
}
|
|
2664
2653
|
const fileKey = extractFileKey(url);
|
|
2665
2654
|
if (!fileKey) {
|
|
@@ -3102,7 +3091,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3102
3091
|
}
|
|
3103
3092
|
const url = fileUrl || getCurrentUrl();
|
|
3104
3093
|
if (!url) {
|
|
3105
|
-
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the
|
|
3094
|
+
throw new Error("No Figma file URL available. Pass the fileUrl parameter or ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is open in Figma.");
|
|
3106
3095
|
}
|
|
3107
3096
|
const fileKey = extractFileKey(url);
|
|
3108
3097
|
if (!fileKey) {
|
|
@@ -3259,7 +3248,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3259
3248
|
// This uses exportAsync() which reads the current plugin runtime state, not the cloud state
|
|
3260
3249
|
// Solves race condition where REST API screenshots show stale data after changes
|
|
3261
3250
|
server.registerTool("figma_capture_screenshot", {
|
|
3262
|
-
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
|
|
3251
|
+
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 a connection to the " + PLUGIN_NAME + " plugin (Figma Desktop with the plugin running).",
|
|
3263
3252
|
inputSchema: z.object({
|
|
3264
3253
|
nodeId: z
|
|
3265
3254
|
.string()
|
|
@@ -3293,7 +3282,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3293
3282
|
}
|
|
3294
3283
|
}
|
|
3295
3284
|
if (!result) {
|
|
3296
|
-
throw new Error("
|
|
3285
|
+
throw new Error("The " + PLUGIN_NAME + " plugin was not found. Ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is running in Figma Desktop.");
|
|
3297
3286
|
}
|
|
3298
3287
|
if (!result.success) {
|
|
3299
3288
|
throw new Error(result.error || "Screenshot capture failed");
|
|
@@ -3339,7 +3328,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3339
3328
|
type: "text",
|
|
3340
3329
|
text: JSON.stringify({
|
|
3341
3330
|
error: errorMessage,
|
|
3342
|
-
message: "Failed to capture screenshot via
|
|
3331
|
+
message: "Failed to capture screenshot via the " + PLUGIN_NAME + " plugin",
|
|
3343
3332
|
suggestion: "Ensure Figma Desktop is open with the plugin running",
|
|
3344
3333
|
}),
|
|
3345
3334
|
},
|
|
@@ -3352,7 +3341,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3352
3341
|
// Updates component properties on an instance using setProperties()
|
|
3353
3342
|
// This is the correct way to update TEXT/BOOLEAN/VARIANT properties on component instances
|
|
3354
3343
|
server.registerTool("figma_set_instance_properties", {
|
|
3355
|
-
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
|
|
3344
|
+
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 a connection to the " + PLUGIN_NAME + " plugin.",
|
|
3356
3345
|
inputSchema: z.object({
|
|
3357
3346
|
nodeId: z
|
|
3358
3347
|
.string()
|
|
@@ -3374,7 +3363,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3374
3363
|
result = await connector.setInstanceProperties(nodeId, properties);
|
|
3375
3364
|
}
|
|
3376
3365
|
if (!result) {
|
|
3377
|
-
throw new Error("
|
|
3366
|
+
throw new Error("The " + PLUGIN_NAME + " plugin was not found. Ensure the " + PLUGIN_NAME_WITH_OLD + " plugin is running in Figma Desktop.");
|
|
3378
3367
|
}
|
|
3379
3368
|
if (!result.success) {
|
|
3380
3369
|
throw new Error(result.error || "Failed to set instance properties");
|
|
@@ -3409,7 +3398,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3409
3398
|
type: "text",
|
|
3410
3399
|
text: JSON.stringify({
|
|
3411
3400
|
error: errorMessage,
|
|
3412
|
-
message: "Failed to set instance properties via
|
|
3401
|
+
message: "Failed to set instance properties via the " + PLUGIN_NAME + " plugin",
|
|
3413
3402
|
suggestions: [
|
|
3414
3403
|
"Verify the node is a component INSTANCE (not a regular frame)",
|
|
3415
3404
|
"Check available properties with figma_get_component first",
|