@muloka/figma-console-mcp 0.6.1 → 0.6.2
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 +3 -0
- package/dist/core/figma-tools.d.ts.map +1 -1
- package/dist/core/figma-tools.js +49 -4
- package/dist/core/figma-tools.js.map +1 -1
- package/dist/core/identity.d.ts +30 -6
- package/dist/core/identity.d.ts.map +1 -1
- package/dist/core/identity.js +60 -10
- package/dist/core/identity.js.map +1 -1
- package/dist/core/tool-annotations.d.ts +53 -0
- package/dist/core/tool-annotations.d.ts.map +1 -0
- package/dist/core/tool-annotations.js +214 -0
- package/dist/core/tool-annotations.js.map +1 -0
- package/dist/local.d.ts +1 -0
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +18 -8
- package/dist/local.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,6 +156,9 @@ With `ENABLE_MCP_APPS=true`, hosts that support [MCP Apps](https://github.com/mo
|
|
|
156
156
|
- Aliased tokens in the design-system summary and `figma_get_token_values` report their resolved value and `aliasOf`. An alias to a library variable reports `value: null`.
|
|
157
157
|
- **Create-variable rollback (0.6.1)** — when `figma_create_variable` fails after creating the variable (a bad mode id, value or scope), the plugin removes it again, and the error says so.
|
|
158
158
|
- **Stale-plugin detection (0.6.1)** — the plugin reports a fork revision alongside its upstream `PLUGIN_VERSION`, so the server flags a plugin that predates this fork's latest plugin changes (see [When to re-import the plugin](#when-to-re-import-the-plugin)).
|
|
159
|
+
- **Tool annotations (0.6.2)** — every tool declares MCP `readOnlyHint`, `destructiveHint`, `idempotentHint` and `openWorldHint`, so a client can tell a read like `figma_get_status` from a write or a delete. Deletes, arbitrary code (`figma_execute`) and tools that write local files are destructive; updates, renames and sets are not. The classification is upstream's, trimmed to this fork's tools.
|
|
160
|
+
- **Stdio result cap (0.6.2)** — on stdio, a tool result above 8 MB comes back as an error saying it was withheld, that any changes made in Figma still happened, and how to ask for less. Without it, a client such as Claude Code drops the whole stdio connection on an oversized message. Results over `MCP_HTTP_PORT` are not capped.
|
|
161
|
+
- **Real errors from `figma_get_variables` (0.6.2)** — when every read method fails, the error names each method with its own message, for example the plugin's "File … is not connected to the Desktop Bridge … Connected files: …", and lists them in a `causes` object. It used to say only "All methods failed". The failure is always returned as an error, whatever text the causes contain.
|
|
159
162
|
- **Honest error reporting** — the eight single-op variable/collection/mode write tools check the bridge's result envelope, so a plugin-side failure surfaces its real error text instead of a false success or a masking TypeError; batch-create failure rows identify variables that were created before the throw (`created`/`id`/`valueSet: false`).
|
|
160
163
|
- **Mode-limit safety** — `figma_setup_design_tokens` and `figma_create_variable_collection` roll the collection back on a mode-limit failure instead of orphaning it, and the setup tool returns your file's real ceiling as `planModeLimit`; the schema's stale 4-mode cap is now a 40 sanity bound (current Figma plans allow 10/20/unlimited — the runtime limit governs).
|
|
161
164
|
- **No orphaned nodes on failure** — `figma_create_connector` validates endpoints before creating, and create-child / add-text-to-slide / create-table remove their partially-created node on error; batch stickies report the id of any sticky a failed row left behind. `figma_create_child` also gains the POLYGON/STAR/VECTOR types the plugin always supported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figma-tools.d.ts","sourceRoot":"","sources":["../../src/core/figma-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"figma-tools.d.ts","sourceRoot":"","sources":["../../src/core/figma-tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,KAAK,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAwxB7D;;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,QA6qGxC"}
|
package/dist/core/figma-tools.js
CHANGED
|
@@ -541,6 +541,19 @@ function evictOldestCacheEntry(cache) {
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* Thrown when every variables read method failed. Carries each method's own
|
|
546
|
+
* failure text so the handler's catch can answer it before the text-based
|
|
547
|
+
* routing (a "403" inside a file name or REST error must not trigger the
|
|
548
|
+
* Styles fallback).
|
|
549
|
+
*/
|
|
550
|
+
class VariablesReadFailedError extends Error {
|
|
551
|
+
constructor(message, causes) {
|
|
552
|
+
super(message);
|
|
553
|
+
this.causes = causes;
|
|
554
|
+
this.name = "VariablesReadFailedError";
|
|
555
|
+
}
|
|
556
|
+
}
|
|
544
557
|
/**
|
|
545
558
|
* Resolve variable aliases to their final values for all modes
|
|
546
559
|
* @param variables Array of variables to resolve
|
|
@@ -1333,6 +1346,8 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1333
1346
|
// Check if REST API token is available
|
|
1334
1347
|
const hasToken = !!process.env.FIGMA_ACCESS_TOKEN;
|
|
1335
1348
|
let restApiSucceeded = false;
|
|
1349
|
+
let desktopBridgeFailure;
|
|
1350
|
+
let restFailure;
|
|
1336
1351
|
const hasDesktopConnection = !!getDesktopConnector;
|
|
1337
1352
|
// PRIORITY LOGIC:
|
|
1338
1353
|
// 1. If Desktop Bridge connected → Try Desktop Bridge FIRST (instant, all plans, full Plugin API data)
|
|
@@ -1599,6 +1614,7 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1599
1614
|
}
|
|
1600
1615
|
catch (restError) {
|
|
1601
1616
|
const errorMessage = restError instanceof Error ? restError.message : String(restError);
|
|
1617
|
+
restFailure = errorMessage;
|
|
1602
1618
|
// Detect specific error types for better logging and handling
|
|
1603
1619
|
const isTimeout = errorMessage.includes('timed out');
|
|
1604
1620
|
const isRateLimit = errorMessage.includes('429') || errorMessage.toLowerCase().includes('rate limit');
|
|
@@ -1825,9 +1841,11 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1825
1841
|
],
|
|
1826
1842
|
};
|
|
1827
1843
|
}
|
|
1844
|
+
desktopBridgeFailure = "Desktop Bridge returned no variables data";
|
|
1828
1845
|
}
|
|
1829
1846
|
catch (desktopError) {
|
|
1830
1847
|
const errorMessage = desktopError instanceof Error ? desktopError.message : String(desktopError);
|
|
1848
|
+
desktopBridgeFailure = errorMessage;
|
|
1831
1849
|
const errorStack = desktopError instanceof Error ? desktopError.stack : undefined;
|
|
1832
1850
|
logger.error({
|
|
1833
1851
|
error: desktopError,
|
|
@@ -1923,11 +1941,13 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1923
1941
|
});
|
|
1924
1942
|
}
|
|
1925
1943
|
else {
|
|
1944
|
+
restFailure = localError || "REST API returned no variables data";
|
|
1926
1945
|
logger.warn({ error: localError, fileKey }, "REST API fallback also failed (likely non-Enterprise plan)");
|
|
1927
1946
|
}
|
|
1928
1947
|
}
|
|
1929
1948
|
catch (restFallbackError) {
|
|
1930
1949
|
const msg = restFallbackError instanceof Error ? restFallbackError.message : String(restFallbackError);
|
|
1950
|
+
restFailure = msg;
|
|
1931
1951
|
logger.warn({ error: msg, fileKey }, "REST API fallback failed");
|
|
1932
1952
|
}
|
|
1933
1953
|
}
|
|
@@ -1945,17 +1965,42 @@ export function registerFigmaAPITools(server, getFigmaAPI, getCurrentUrl, variab
|
|
|
1945
1965
|
"the plugin returns full variable data through the WebSocket bridge.");
|
|
1946
1966
|
}
|
|
1947
1967
|
// No more fallback options available
|
|
1948
|
-
|
|
1968
|
+
const causes = {
|
|
1969
|
+
desktopBridge: desktopBridgeFailure ?? "not available",
|
|
1970
|
+
...(restFailure && { restApi: restFailure }),
|
|
1971
|
+
};
|
|
1972
|
+
throw new VariablesReadFailedError(`Cannot retrieve variables. All methods failed.\n\n` +
|
|
1949
1973
|
`Tried methods:\n` +
|
|
1950
|
-
`${
|
|
1951
|
-
`✗ Desktop Bridge
|
|
1974
|
+
`${restFailure ? `✗ REST API: ${restFailure}\n` : ''}` +
|
|
1975
|
+
`✗ Desktop Bridge: ${causes.desktopBridge}\n` +
|
|
1952
1976
|
`\nTo fix:\n` +
|
|
1953
1977
|
`1. If you have FIGMA_ACCESS_TOKEN: Check your token permissions\n` +
|
|
1954
|
-
`2. Install and run the Figma Desktop Bridge plugin and re-run this tool
|
|
1978
|
+
`2. Install and run the Figma Desktop Bridge plugin and re-run this tool`, causes);
|
|
1955
1979
|
}
|
|
1956
1980
|
catch (error) {
|
|
1957
1981
|
logger.error({ error }, "Failed to get variables");
|
|
1958
1982
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1983
|
+
// All read methods failed: answer with each method's own error before
|
|
1984
|
+
// the text-based routing below, which would read a "403" quoted inside
|
|
1985
|
+
// that text as a plan gate and return styles that look like success.
|
|
1986
|
+
if (error instanceof VariablesReadFailedError) {
|
|
1987
|
+
return {
|
|
1988
|
+
content: [
|
|
1989
|
+
{
|
|
1990
|
+
type: "text",
|
|
1991
|
+
text: JSON.stringify({
|
|
1992
|
+
error: error.message,
|
|
1993
|
+
message: "Failed to retrieve Figma variables",
|
|
1994
|
+
causes: error.causes,
|
|
1995
|
+
hint: error.causes.restApi
|
|
1996
|
+
? "Both reads failed; see causes for each. Open the Desktop Bridge 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."
|
|
1997
|
+
: "Open the Desktop Bridge 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
|
+
},
|
|
2000
|
+
],
|
|
2001
|
+
isError: true,
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
1959
2004
|
// A 403 here has two very different causes: an expired/invalid token
|
|
1960
2005
|
// (isAuthError, set centrally by FigmaAPI.request) or the Variables
|
|
1961
2006
|
// API's Enterprise plan gate. Only the latter should be diagnosed as
|