@muloka/figma-console-mcp 0.6.5 → 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 +12 -5
- 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/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-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.map +1 -1
- package/dist/core/figma-api.js +2 -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 +39 -38
- 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-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 +6 -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 +76 -147
- 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
package/dist/core/figma-tools.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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";
|
|
@@ -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
|
],
|
|
@@ -1846,7 +1847,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1846
1847
|
],
|
|
1847
1848
|
};
|
|
1848
1849
|
}
|
|
1849
|
-
desktopBridgeFailure = "
|
|
1850
|
+
desktopBridgeFailure = "The " + PLUGIN_NAME + " plugin returned no variables data";
|
|
1850
1851
|
}
|
|
1851
1852
|
catch (desktopError) {
|
|
1852
1853
|
const errorMessage = desktopError instanceof Error ? desktopError.message : String(desktopError);
|
|
@@ -1960,7 +1961,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1960
1961
|
throw identifiedError("parseFromConsole is no longer supported.\n\n" +
|
|
1961
1962
|
"The console-snippet workflow it relied on required a Puppeteer browser " +
|
|
1962
1963
|
"connection to Figma Desktop, which was removed in Phase 3 of the cleanup. " +
|
|
1963
|
-
"To extract variables, open the
|
|
1964
|
+
"To extract variables, open the " + PLUGIN_NAME_WITH_OLD + " plugin in " +
|
|
1964
1965
|
"Figma Desktop and call figma_get_variables() without parseFromConsole — " +
|
|
1965
1966
|
"the plugin returns full variable data through the WebSocket bridge.");
|
|
1966
1967
|
}
|
|
@@ -1972,10 +1973,10 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1972
1973
|
throw new VariablesReadFailedError(`Cannot retrieve variables. All methods failed.\n\n` +
|
|
1973
1974
|
`Tried methods:\n` +
|
|
1974
1975
|
`${restFailure ? `✗ REST API: ${restFailure}\n` : ''}` +
|
|
1975
|
-
`✗
|
|
1976
|
+
`✗ ${PLUGIN_NAME} plugin: ${causes.desktopBridge}\n` +
|
|
1976
1977
|
`\nTo fix:\n` +
|
|
1977
1978
|
`1. If you have FIGMA_ACCESS_TOKEN: Check your token permissions\n` +
|
|
1978
|
-
`2. Install and run the
|
|
1979
|
+
`2. Install and run the ${PLUGIN_NAME_WITH_OLD} plugin and re-run this tool`, causes);
|
|
1979
1980
|
}
|
|
1980
1981
|
catch (error) {
|
|
1981
1982
|
logger.error({ error }, "Failed to get variables");
|
|
@@ -1993,8 +1994,8 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1993
1994
|
message: "Failed to retrieve Figma variables",
|
|
1994
1995
|
causes: error.causes,
|
|
1995
1996
|
hint: error.causes.restApi
|
|
1996
|
-
? "Both reads failed; see causes for each. Open the
|
|
1997
|
-
: "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.",
|
|
1998
1999
|
}),
|
|
1999
2000
|
},
|
|
2000
2001
|
],
|
|
@@ -2015,7 +2016,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2015
2016
|
text: JSON.stringify({
|
|
2016
2017
|
error: errorMessage,
|
|
2017
2018
|
message: "Failed to retrieve Figma variables — REST token is expired or invalid",
|
|
2018
|
-
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.",
|
|
2019
2020
|
}),
|
|
2020
2021
|
},
|
|
2021
2022
|
],
|
|
@@ -2076,7 +2077,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2076
2077
|
"The file structure may not contain extractable styles",
|
|
2077
2078
|
"There may be a network or authentication issue"
|
|
2078
2079
|
],
|
|
2079
|
-
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.",
|
|
2080
2081
|
technical: styleError instanceof Error ? styleError.message : String(styleError)
|
|
2081
2082
|
}),
|
|
2082
2083
|
},
|
|
@@ -2094,8 +2095,8 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2094
2095
|
error: errorMessage,
|
|
2095
2096
|
message: "Failed to retrieve Figma variables",
|
|
2096
2097
|
hint: errorMessage.includes("403")
|
|
2097
|
-
? "The Variables REST API requires an Enterprise plan. Open the
|
|
2098
|
-
: "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",
|
|
2099
2100
|
}),
|
|
2100
2101
|
},
|
|
2101
2102
|
],
|
|
@@ -2106,7 +2107,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2106
2107
|
// Tool 10: Get Component Data
|
|
2107
2108
|
const componentDescription = isRemoteMode
|
|
2108
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."
|
|
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. 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.";
|
|
2110
2111
|
server.registerTool("figma_get_component", {
|
|
2111
2112
|
description: componentDescription,
|
|
2112
2113
|
inputSchema: z.object({
|
|
@@ -2114,7 +2115,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2114
2115
|
.string()
|
|
2115
2116
|
.url()
|
|
2116
2117
|
.optional()
|
|
2117
|
-
.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."),
|
|
2118
2119
|
nodeId: z
|
|
2119
2120
|
.string()
|
|
2120
2121
|
.describe("Component node ID (e.g., '123:456')"),
|
|
@@ -2132,7 +2133,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2132
2133
|
try {
|
|
2133
2134
|
const url = fileUrl || getCurrentUrl();
|
|
2134
2135
|
if (!url) {
|
|
2135
|
-
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.");
|
|
2136
2137
|
}
|
|
2137
2138
|
const fileKey = extractFileKey(url);
|
|
2138
2139
|
if (!fileKey) {
|
|
@@ -2230,7 +2231,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2230
2231
|
annotations: annotationSummary,
|
|
2231
2232
|
source: "desktop_bridge_plugin",
|
|
2232
2233
|
enriched: enrich || false,
|
|
2233
|
-
note: "Retrieved via
|
|
2234
|
+
note: "Retrieved via the " + PLUGIN_NAME + " plugin - description fields and annotations are reliable and current"
|
|
2234
2235
|
}),
|
|
2235
2236
|
},
|
|
2236
2237
|
],
|
|
@@ -2253,7 +2254,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2253
2254
|
const dbStatus = getDesktopConnector
|
|
2254
2255
|
? "Failed (see logs above)"
|
|
2255
2256
|
: "Not available";
|
|
2256
|
-
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.");
|
|
2257
2258
|
}
|
|
2258
2259
|
const componentData = await api.getComponentData(fileKey, nodeId);
|
|
2259
2260
|
if (!componentData) {
|
|
@@ -2322,7 +2323,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2322
2323
|
source: "rest_api",
|
|
2323
2324
|
enriched: enrich || false,
|
|
2324
2325
|
warning: "Retrieved via REST API - description field may be missing due to known Figma API bug",
|
|
2325
|
-
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."
|
|
2326
2327
|
}),
|
|
2327
2328
|
},
|
|
2328
2329
|
],
|
|
@@ -2354,7 +2355,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2354
2355
|
.string()
|
|
2355
2356
|
.url()
|
|
2356
2357
|
.optional()
|
|
2357
|
-
.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."),
|
|
2358
2359
|
verbosity: z
|
|
2359
2360
|
.enum(["summary", "standard", "full"])
|
|
2360
2361
|
.optional()
|
|
@@ -2389,7 +2390,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2389
2390
|
}
|
|
2390
2391
|
const url = fileUrl || getCurrentUrl();
|
|
2391
2392
|
if (!url) {
|
|
2392
|
-
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.");
|
|
2393
2394
|
}
|
|
2394
2395
|
const fileKey = extractFileKey(url);
|
|
2395
2396
|
if (!fileKey) {
|
|
@@ -2499,7 +2500,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2499
2500
|
.string()
|
|
2500
2501
|
.url()
|
|
2501
2502
|
.optional()
|
|
2502
|
-
.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."),
|
|
2503
2504
|
nodeId: z
|
|
2504
2505
|
.string()
|
|
2505
2506
|
.describe("Component node ID to render as image (e.g., '695:313')"),
|
|
@@ -2527,11 +2528,11 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2527
2528
|
}
|
|
2528
2529
|
catch (apiError) {
|
|
2529
2530
|
const errorMessage = apiError instanceof Error ? apiError.message : String(apiError);
|
|
2530
|
-
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.");
|
|
2531
2532
|
}
|
|
2532
2533
|
const url = fileUrl || getCurrentUrl();
|
|
2533
2534
|
if (!url) {
|
|
2534
|
-
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.");
|
|
2535
2536
|
}
|
|
2536
2537
|
const fileKey = extractFileKey(url);
|
|
2537
2538
|
if (!fileKey) {
|
|
@@ -2643,11 +2644,11 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
2643
2644
|
}
|
|
2644
2645
|
catch (apiError) {
|
|
2645
2646
|
const errorMessage = apiError instanceof Error ? apiError.message : String(apiError);
|
|
2646
|
-
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).");
|
|
2647
2648
|
}
|
|
2648
2649
|
const url = fileUrl || getCurrentUrl();
|
|
2649
2650
|
if (!url) {
|
|
2650
|
-
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.");
|
|
2651
2652
|
}
|
|
2652
2653
|
const fileKey = extractFileKey(url);
|
|
2653
2654
|
if (!fileKey) {
|
|
@@ -3090,7 +3091,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3090
3091
|
}
|
|
3091
3092
|
const url = fileUrl || getCurrentUrl();
|
|
3092
3093
|
if (!url) {
|
|
3093
|
-
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.");
|
|
3094
3095
|
}
|
|
3095
3096
|
const fileKey = extractFileKey(url);
|
|
3096
3097
|
if (!fileKey) {
|
|
@@ -3247,7 +3248,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3247
3248
|
// This uses exportAsync() which reads the current plugin runtime state, not the cloud state
|
|
3248
3249
|
// Solves race condition where REST API screenshots show stale data after changes
|
|
3249
3250
|
server.registerTool("figma_capture_screenshot", {
|
|
3250
|
-
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).",
|
|
3251
3252
|
inputSchema: z.object({
|
|
3252
3253
|
nodeId: z
|
|
3253
3254
|
.string()
|
|
@@ -3281,7 +3282,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3281
3282
|
}
|
|
3282
3283
|
}
|
|
3283
3284
|
if (!result) {
|
|
3284
|
-
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.");
|
|
3285
3286
|
}
|
|
3286
3287
|
if (!result.success) {
|
|
3287
3288
|
throw new Error(result.error || "Screenshot capture failed");
|
|
@@ -3327,7 +3328,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3327
3328
|
type: "text",
|
|
3328
3329
|
text: JSON.stringify({
|
|
3329
3330
|
error: errorMessage,
|
|
3330
|
-
message: "Failed to capture screenshot via
|
|
3331
|
+
message: "Failed to capture screenshot via the " + PLUGIN_NAME + " plugin",
|
|
3331
3332
|
suggestion: "Ensure Figma Desktop is open with the plugin running",
|
|
3332
3333
|
}),
|
|
3333
3334
|
},
|
|
@@ -3340,7 +3341,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3340
3341
|
// Updates component properties on an instance using setProperties()
|
|
3341
3342
|
// This is the correct way to update TEXT/BOOLEAN/VARIANT properties on component instances
|
|
3342
3343
|
server.registerTool("figma_set_instance_properties", {
|
|
3343
|
-
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.",
|
|
3344
3345
|
inputSchema: z.object({
|
|
3345
3346
|
nodeId: z
|
|
3346
3347
|
.string()
|
|
@@ -3362,7 +3363,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3362
3363
|
result = await connector.setInstanceProperties(nodeId, properties);
|
|
3363
3364
|
}
|
|
3364
3365
|
if (!result) {
|
|
3365
|
-
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.");
|
|
3366
3367
|
}
|
|
3367
3368
|
if (!result.success) {
|
|
3368
3369
|
throw new Error(result.error || "Failed to set instance properties");
|
|
@@ -3397,7 +3398,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
3397
3398
|
type: "text",
|
|
3398
3399
|
text: JSON.stringify({
|
|
3399
3400
|
error: errorMessage,
|
|
3400
|
-
message: "Failed to set instance properties via
|
|
3401
|
+
message: "Failed to set instance properties via the " + PLUGIN_NAME + " plugin",
|
|
3401
3402
|
suggestions: [
|
|
3402
3403
|
"Verify the node is a component INSTANCE (not a regular frame)",
|
|
3403
3404
|
"Check available properties with figma_get_component first",
|