@muloka/figma-console-mcp 0.5.0 → 0.5.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 -1
- package/dist/core/port-discovery.d.ts +9 -0
- package/dist/core/port-discovery.d.ts.map +1 -1
- package/dist/core/port-discovery.js +40 -14
- package/dist/core/port-discovery.js.map +1 -1
- package/dist/core/websocket-connector.d.ts +2 -1
- package/dist/core/websocket-connector.d.ts.map +1 -1
- package/dist/core/websocket-connector.js +17 -2
- package/dist/core/websocket-connector.js.map +1 -1
- package/dist/core/websocket-server.d.ts +8 -1
- package/dist/core/websocket-server.d.ts.map +1 -1
- package/dist/core/websocket-server.js +18 -2
- package/dist/core/websocket-server.js.map +1 -1
- package/dist/core/write-tools.d.ts +3 -1
- package/dist/core/write-tools.d.ts.map +1 -1
- package/dist/core/write-tools.js +34 -14
- package/dist/core/write-tools.js.map +1 -1
- package/dist/local.d.ts +2 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +10 -14
- package/dist/local.js.map +1 -1
- package/package.json +1 -1
- package/dist/apps/design-system-dashboard/mcp-app.html +0 -521
- package/dist/apps/token-browser/mcp-app.html +0 -410
- package/dist/cloudflare/apps/design-system-dashboard/scoring/accessibility.js +0 -277
- package/dist/cloudflare/apps/design-system-dashboard/scoring/component-metadata.js +0 -357
- package/dist/cloudflare/apps/design-system-dashboard/scoring/consistency.js +0 -341
- package/dist/cloudflare/apps/design-system-dashboard/scoring/coverage.js +0 -230
- package/dist/cloudflare/apps/design-system-dashboard/scoring/engine.js +0 -92
- package/dist/cloudflare/apps/design-system-dashboard/scoring/naming-semantics.js +0 -308
- package/dist/cloudflare/apps/design-system-dashboard/scoring/token-architecture.js +0 -349
- package/dist/cloudflare/apps/design-system-dashboard/scoring/types.js +0 -40
- package/dist/cloudflare/apps/design-system-dashboard/server.js +0 -159
- package/dist/cloudflare/apps/token-browser/server.js +0 -136
- package/dist/cloudflare/browser-manager.js +0 -157
- package/dist/cloudflare/core/accessibility-tools.js +0 -361
- package/dist/cloudflare/core/annotation-tools.js +0 -230
- package/dist/cloudflare/core/cloud-websocket-connector.js +0 -419
- package/dist/cloudflare/core/cloud-websocket-relay.js +0 -198
- package/dist/cloudflare/core/comment-tools.js +0 -292
- package/dist/cloudflare/core/config.js +0 -153
- package/dist/cloudflare/core/console-monitor.js +0 -427
- package/dist/cloudflare/core/deep-component-tools.js +0 -128
- package/dist/cloudflare/core/design-code-tools.js +0 -2793
- package/dist/cloudflare/core/design-system-manifest.js +0 -265
- package/dist/cloudflare/core/design-system-tools.js +0 -882
- package/dist/cloudflare/core/diagnose-tool.js +0 -100
- package/dist/cloudflare/core/diff/changelog-formatter.js +0 -275
- package/dist/cloudflare/core/diff/diff-engine.js +0 -334
- package/dist/cloudflare/core/diff/property-compare.js +0 -36
- package/dist/cloudflare/core/diff/version-cache.js +0 -74
- package/dist/cloudflare/core/enrichment/enrichment-service.js +0 -374
- package/dist/cloudflare/core/enrichment/index.js +0 -7
- package/dist/cloudflare/core/enrichment/relationship-mapper.js +0 -351
- package/dist/cloudflare/core/enrichment/style-resolver.js +0 -346
- package/dist/cloudflare/core/figjam-tools.js +0 -547
- package/dist/cloudflare/core/figma-api.js +0 -509
- package/dist/cloudflare/core/figma-connector.js +0 -7
- package/dist/cloudflare/core/figma-reconstruction-spec.js +0 -402
- package/dist/cloudflare/core/figma-style-extractor.js +0 -311
- package/dist/cloudflare/core/figma-tools.js +0 -3353
- package/dist/cloudflare/core/identity.js +0 -96
- package/dist/cloudflare/core/library-tools.js +0 -580
- package/dist/cloudflare/core/logger.js +0 -53
- package/dist/cloudflare/core/port-discovery.js +0 -935
- package/dist/cloudflare/core/resolve-package-root.js +0 -11
- package/dist/cloudflare/core/slides-tools.js +0 -714
- package/dist/cloudflare/core/slot-tools.js +0 -334
- package/dist/cloudflare/core/snippet-injector.js +0 -96
- package/dist/cloudflare/core/tokens/alias-resolver.js +0 -205
- package/dist/cloudflare/core/tokens/config.js +0 -294
- package/dist/cloudflare/core/tokens/dialect.js +0 -232
- package/dist/cloudflare/core/tokens/figma-converter.js +0 -323
- package/dist/cloudflare/core/tokens/formatters/css-vars.js +0 -338
- package/dist/cloudflare/core/tokens/formatters/dtcg.js +0 -376
- package/dist/cloudflare/core/tokens/formatters/index.js +0 -45
- package/dist/cloudflare/core/tokens/formatters/json.js +0 -205
- package/dist/cloudflare/core/tokens/formatters/less.js +0 -4
- package/dist/cloudflare/core/tokens/formatters/scss.js +0 -258
- package/dist/cloudflare/core/tokens/formatters/stubs.js +0 -13
- package/dist/cloudflare/core/tokens/formatters/style-dictionary-v3.js +0 -213
- package/dist/cloudflare/core/tokens/formatters/tailwind-v3.js +0 -237
- package/dist/cloudflare/core/tokens/formatters/tailwind-v4.js +0 -335
- package/dist/cloudflare/core/tokens/formatters/tokens-studio.js +0 -256
- package/dist/cloudflare/core/tokens/formatters/ts-module.js +0 -198
- package/dist/cloudflare/core/tokens/index.js +0 -16
- package/dist/cloudflare/core/tokens/parsers/css-vars.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/dtcg.js +0 -280
- package/dist/cloudflare/core/tokens/parsers/index.js +0 -138
- package/dist/cloudflare/core/tokens/parsers/json.js +0 -7
- package/dist/cloudflare/core/tokens/parsers/scss.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/stubs.js +0 -20
- package/dist/cloudflare/core/tokens/parsers/style-dictionary-v3.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/tailwind-v3.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/tailwind-v4.js +0 -4
- package/dist/cloudflare/core/tokens/parsers/tokens-studio.js +0 -4
- package/dist/cloudflare/core/tokens/schemas.js +0 -152
- package/dist/cloudflare/core/tokens/transforms/color.js +0 -12
- package/dist/cloudflare/core/tokens/transforms/index.js +0 -29
- package/dist/cloudflare/core/tokens/transforms/size.js +0 -7
- package/dist/cloudflare/core/tokens/types.js +0 -18
- package/dist/cloudflare/core/tokens-tools.js +0 -1788
- package/dist/cloudflare/core/types/design-code.js +0 -4
- package/dist/cloudflare/core/types/enriched.js +0 -5
- package/dist/cloudflare/core/types/index.js +0 -4
- package/dist/cloudflare/core/variable-resolver.js +0 -85
- package/dist/cloudflare/core/version-tools.js +0 -1199
- package/dist/cloudflare/core/websocket-connector.js +0 -436
- package/dist/cloudflare/core/websocket-server.js +0 -1009
- package/dist/cloudflare/core/write-tools.js +0 -2506
- package/dist/cloudflare/index.js +0 -3010
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bridge-first variable resolution.
|
|
3
|
-
*
|
|
4
|
-
* Figma's Variables REST API (`/files/:key/variables/local`) is **Enterprise-only**
|
|
5
|
-
* and returns 403 for the majority of users (Starter/Pro/Org). The Desktop Bridge
|
|
6
|
-
* and cloud relay read variables through the Plugin API
|
|
7
|
-
* (`figma.variables.getLocalVariablesAsync`), which works on **every** Figma plan.
|
|
8
|
-
*
|
|
9
|
-
* Orchestration tools (e.g. `figma_get_design_system_kit`) historically called the
|
|
10
|
-
* REST API directly and dead-ended on a 403 for non-Enterprise users — even when a
|
|
11
|
-
* bridge was connected. This helper mirrors `figma_get_variables`' resolution order
|
|
12
|
-
* so every variable-reading tool behaves consistently:
|
|
13
|
-
*
|
|
14
|
-
* 1. Desktop Bridge / cloud relay (any plan) ← preferred
|
|
15
|
-
* 2. REST Variables API (Enterprise only) ← fallback
|
|
16
|
-
*
|
|
17
|
-
* It returns the same normalized shape as `formatVariables()`.
|
|
18
|
-
*/
|
|
19
|
-
import { formatVariables, withTimeout } from "./figma-api.js";
|
|
20
|
-
import { createChildLogger } from "./logger.js";
|
|
21
|
-
const logger = createChildLogger({ component: "variable-resolver" });
|
|
22
|
-
/**
|
|
23
|
-
* The Desktop Bridge returns variables/collections as **arrays**, while
|
|
24
|
-
* `formatVariables()` expects **objects keyed by id** (the REST shape). Convert so
|
|
25
|
-
* the same formatter handles both transports.
|
|
26
|
-
*/
|
|
27
|
-
function bridgeArraysToFormatInput(data) {
|
|
28
|
-
const variables = {};
|
|
29
|
-
for (const v of data.variables || []) {
|
|
30
|
-
if (v && v.id)
|
|
31
|
-
variables[v.id] = v;
|
|
32
|
-
}
|
|
33
|
-
const variableCollections = {};
|
|
34
|
-
for (const c of data.variableCollections || []) {
|
|
35
|
-
if (c && c.id)
|
|
36
|
-
variableCollections[c.id] = c;
|
|
37
|
-
}
|
|
38
|
-
return { variables, variableCollections };
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Resolve + format local variables, preferring the Desktop Bridge / cloud relay and
|
|
42
|
-
* falling back to the Enterprise-only REST API only when no bridge is connected.
|
|
43
|
-
*
|
|
44
|
-
* @throws a bridge-pointing error when the bridge is unavailable AND the REST API
|
|
45
|
-
* fails (e.g. 403 without Enterprise), so callers/LLMs retry via the bridge
|
|
46
|
-
* instead of treating variables as inaccessible.
|
|
47
|
-
*/
|
|
48
|
-
export async function resolveFormattedVariables(opts) {
|
|
49
|
-
const { getDesktopConnector, getFigmaAPI, fileKey } = opts;
|
|
50
|
-
const timeoutMs = opts.timeoutMs ?? 30000;
|
|
51
|
-
// 1. Desktop Bridge / cloud relay — works on ANY plan. Preferred.
|
|
52
|
-
if (getDesktopConnector) {
|
|
53
|
-
try {
|
|
54
|
-
const connector = await getDesktopConnector();
|
|
55
|
-
const raw = await withTimeout(connector.getVariables(fileKey), timeoutMs, "Desktop Bridge variables");
|
|
56
|
-
// EXECUTE_CODE responses nest the return value under `result`; unwrap so
|
|
57
|
-
// both the live and cached plugin paths produce a uniform shape. See #68.
|
|
58
|
-
const data = raw?.result?.variables ? raw.result : raw;
|
|
59
|
-
if (data?.success && Array.isArray(data.variables)) {
|
|
60
|
-
const formatted = formatVariables(bridgeArraysToFormatInput(data));
|
|
61
|
-
logger.info({ source: "desktop_bridge", variableCount: formatted.variables.length }, "Resolved variables via Desktop Bridge");
|
|
62
|
-
return { ...formatted, source: "desktop_bridge" };
|
|
63
|
-
}
|
|
64
|
-
logger.warn({ fileKey, error: data?.error }, "Desktop Bridge returned no variables; falling back to REST API");
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
logger.warn({ fileKey, error: err instanceof Error ? err.message : String(err) }, "Desktop Bridge variable fetch failed; falling back to REST API");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// 2. REST Variables API — Enterprise only. Last resort.
|
|
71
|
-
const api = await getFigmaAPI();
|
|
72
|
-
try {
|
|
73
|
-
const local = await withTimeout(api.getLocalVariables(fileKey), timeoutMs, "getLocalVariables");
|
|
74
|
-
const formatted = formatVariables(local);
|
|
75
|
-
logger.info({ source: "rest_api", variableCount: formatted.variables.length }, "Resolved variables via REST API");
|
|
76
|
-
return { ...formatted, source: "rest_api" };
|
|
77
|
-
}
|
|
78
|
-
catch (restErr) {
|
|
79
|
-
const msg = restErr instanceof Error ? restErr.message : String(restErr);
|
|
80
|
-
throw new Error(`[figma-console-mcp] Could not read variables. The Figma Variables REST API ` +
|
|
81
|
-
`is unavailable for this file (${msg}) — it requires an Enterprise plan. ` +
|
|
82
|
-
`Connect the Figma Console MCP Desktop Bridge plugin (or pair it via Cloud Mode) ` +
|
|
83
|
-
`to read variables on ANY plan, then retry.`);
|
|
84
|
-
}
|
|
85
|
-
}
|