@seed-design/mcp 0.0.22 → 0.0.24

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/bin/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
4
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
5
  import { v4 } from 'uuid';
6
6
  import WebSocket$1 from 'ws';
7
- import { figma, react, createRestNormalizer, getFigmaColorVariableNames } from '@seed-design/figma';
7
+ import { createRestNormalizer, figma, react, getFigmaColorVariableNames } from '@seed-design/figma';
8
8
  import { z } from 'zod';
9
9
  import fs from 'node:fs';
10
10
  import path from 'node:path';
@@ -58,7 +58,7 @@ function createFigmaWebSocketClient(serverUrl) {
58
58
  ws.on("open", ()=>{
59
59
  logger.info("Connected to Figma socket server");
60
60
  // Reset channel on new connection
61
- currentChannel = null;
61
+ joinChannel("local-default");
62
62
  });
63
63
  ws.on("message", (data)=>{
64
64
  try {
@@ -266,10 +266,6 @@ function createFigmaWebSocketClient(serverUrl) {
266
266
  function registerTools(server, figmaClient, config = {}) {
267
267
  const { joinChannel, sendCommandToFigma } = figmaClient;
268
268
  const { extend } = config ?? {};
269
- const figmaPipeline = figma.createPipeline();
270
- const reactPipeline = react.createPipeline({
271
- extend
272
- });
273
269
  // join_channel tool
274
270
  server.tool("join_channel", "Join a specific channel to communicate with Figma", {
275
271
  channel: z.string().describe("The name of the channel to join").default("")
@@ -373,15 +369,19 @@ function registerTools(server, figmaClient, config = {}) {
373
369
  });
374
370
  const normalizer = createRestNormalizer(result);
375
371
  const node = normalizer(result.document);
376
- const original = figmaPipeline.generateCode(node, {
377
- shouldPrintSource: true,
378
- shouldInferVariableName: false,
379
- shouldInferAutoLayout: false
372
+ const noInferPipeline = figma.createPipeline({
373
+ shouldInferAutoLayout: false,
374
+ shouldInferVariableName: false
375
+ });
376
+ const inferPipeline = figma.createPipeline({
377
+ shouldInferAutoLayout: true,
378
+ shouldInferVariableName: true
379
+ });
380
+ const original = noInferPipeline.generateCode(node, {
381
+ shouldPrintSource: true
380
382
  }) ?? "Failed to generate summarized node info";
381
- const inferred = figmaPipeline.generateCode(node, {
382
- shouldPrintSource: true,
383
- shouldInferVariableName: false,
384
- shouldInferAutoLayout: true
383
+ const inferred = inferPipeline.generateCode(node, {
384
+ shouldPrintSource: true
385
385
  }) ?? "Failed to generate summarized node info";
386
386
  return formatObjectResponse({
387
387
  original: {
@@ -408,15 +408,19 @@ function registerTools(server, figmaClient, config = {}) {
408
408
  });
409
409
  const normalizer = createRestNormalizer(result);
410
410
  const node = normalizer(result.document);
411
- const original = figmaPipeline.generateCode(node, {
412
- shouldInferVariableName: false,
413
- shouldPrintSource: true,
414
- shouldInferAutoLayout: false
411
+ const noInferPipeline = figma.createPipeline({
412
+ shouldInferAutoLayout: false,
413
+ shouldInferVariableName: false
414
+ });
415
+ const inferPipeline = figma.createPipeline({
416
+ shouldInferAutoLayout: true,
417
+ shouldInferVariableName: true
418
+ });
419
+ const original = noInferPipeline.generateCode(node, {
420
+ shouldPrintSource: true
415
421
  }) ?? "Failed to generate summarized node info";
416
- const inferred = figmaPipeline.generateCode(node, {
417
- shouldInferVariableName: true,
418
- shouldPrintSource: true,
419
- shouldInferAutoLayout: false
422
+ const inferred = inferPipeline.generateCode(node, {
423
+ shouldPrintSource: true
420
424
  }) ?? "Failed to generate summarized node info";
421
425
  return {
422
426
  nodeId,
@@ -443,10 +447,13 @@ function registerTools(server, figmaClient, config = {}) {
443
447
  nodeId
444
448
  });
445
449
  const normalizer = createRestNormalizer(result);
446
- const code = reactPipeline.generateCode(normalizer(result.document), {
450
+ const pipeline = react.createPipeline({
451
+ shouldInferAutoLayout: true,
447
452
  shouldInferVariableName: true,
448
- shouldPrintSource: false,
449
- shouldInferAutoLayout: true
453
+ extend
454
+ });
455
+ const code = pipeline.generateCode(normalizer(result.document), {
456
+ shouldPrintSource: false
450
457
  }) ?? "Failed to generate code";
451
458
  return formatTextResponse(code);
452
459
  } catch (error) {
@@ -668,7 +675,7 @@ function registerPrompts(server) {
668
675
  });
669
676
  }
670
677
 
671
- var version = "0.0.22";
678
+ var version = "0.0.24";
672
679
 
673
680
  // Config loader
674
681
  async function loadConfig(configPath) {
@@ -858,10 +865,10 @@ async function startMcpServer(serverUrl, experimental, configPath) {
858
865
  if (configData) {
859
866
  logger.info(`Loaded configuration from: ${configPath}`);
860
867
  // Log component transformers if present
861
- if (configData.extend?.componentTransformers) {
862
- const transformerKeys = configData.extend.componentTransformers.map((t)=>t.key);
863
- if (transformerKeys.length > 0) {
864
- logger.info(`Found ${transformerKeys.length} custom component transformers: ${transformerKeys.join(", ")}`);
868
+ if (configData.extend?.componentHandlers) {
869
+ const handlers = configData.extend.componentHandlers;
870
+ if (handlers.length > 0) {
871
+ logger.info(`Found ${handlers.length} custom component handlers`);
865
872
  }
866
873
  }
867
874
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/mcp",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@modelcontextprotocol/sdk": "^1.10.2",
26
- "@seed-design/figma": "0.0.22",
26
+ "@seed-design/figma": "0.0.24",
27
27
  "cac": "^6.7.14",
28
28
  "uuid": "^11.1.0",
29
29
  "ws": "^8.18.1",
package/src/bin/index.ts CHANGED
@@ -198,12 +198,10 @@ async function startMcpServer(serverUrl: string, experimental: boolean, configPa
198
198
  logger.info(`Loaded configuration from: ${configPath}`);
199
199
 
200
200
  // Log component transformers if present
201
- if (configData.extend?.componentTransformers) {
202
- const transformerKeys = configData.extend.componentTransformers.map((t) => t.key);
203
- if (transformerKeys.length > 0) {
204
- logger.info(
205
- `Found ${transformerKeys.length} custom component transformers: ${transformerKeys.join(", ")}`,
206
- );
201
+ if (configData.extend?.componentHandlers) {
202
+ const handlers = configData.extend.componentHandlers;
203
+ if (handlers.length > 0) {
204
+ logger.info(`Found ${handlers.length} custom component handlers`);
207
205
  }
208
206
  }
209
207
  }
package/src/tools.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { GetFileNodesResponse } from "@figma/rest-api-spec";
2
2
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { createRestNormalizer, getFigmaColorVariableNames, react, figma } from "@seed-design/figma";
3
+ import { createRestNormalizer, figma, getFigmaColorVariableNames, react } from "@seed-design/figma";
4
4
  import { z } from "zod";
5
5
  import type { McpConfig } from "./config";
6
6
  import {
@@ -19,11 +19,6 @@ export function registerTools(
19
19
  const { joinChannel, sendCommandToFigma } = figmaClient;
20
20
  const { extend } = config ?? {};
21
21
 
22
- const figmaPipeline = figma.createPipeline();
23
- const reactPipeline = react.createPipeline({
24
- extend,
25
- });
26
-
27
22
  // join_channel tool
28
23
  server.tool(
29
24
  "join_channel",
@@ -177,17 +172,21 @@ export function registerTools(
177
172
  const normalizer = createRestNormalizer(result);
178
173
  const node = normalizer(result.document);
179
174
 
175
+ const noInferPipeline = figma.createPipeline({
176
+ shouldInferAutoLayout: false,
177
+ shouldInferVariableName: false,
178
+ });
179
+ const inferPipeline = figma.createPipeline({
180
+ shouldInferAutoLayout: true,
181
+ shouldInferVariableName: true,
182
+ });
180
183
  const original =
181
- figmaPipeline.generateCode(node, {
184
+ noInferPipeline.generateCode(node, {
182
185
  shouldPrintSource: true,
183
- shouldInferVariableName: false,
184
- shouldInferAutoLayout: false,
185
186
  }) ?? "Failed to generate summarized node info";
186
187
  const inferred =
187
- figmaPipeline.generateCode(node, {
188
+ inferPipeline.generateCode(node, {
188
189
  shouldPrintSource: true,
189
- shouldInferVariableName: false,
190
- shouldInferAutoLayout: true,
191
190
  }) ?? "Failed to generate summarized node info";
192
191
 
193
192
  return formatObjectResponse({
@@ -221,17 +220,21 @@ export function registerTools(
221
220
  const normalizer = createRestNormalizer(result);
222
221
  const node = normalizer(result.document);
223
222
 
223
+ const noInferPipeline = figma.createPipeline({
224
+ shouldInferAutoLayout: false,
225
+ shouldInferVariableName: false,
226
+ });
227
+ const inferPipeline = figma.createPipeline({
228
+ shouldInferAutoLayout: true,
229
+ shouldInferVariableName: true,
230
+ });
224
231
  const original =
225
- figmaPipeline.generateCode(node, {
226
- shouldInferVariableName: false,
232
+ noInferPipeline.generateCode(node, {
227
233
  shouldPrintSource: true,
228
- shouldInferAutoLayout: false,
229
234
  }) ?? "Failed to generate summarized node info";
230
235
  const inferred =
231
- figmaPipeline.generateCode(node, {
232
- shouldInferVariableName: true,
236
+ inferPipeline.generateCode(node, {
233
237
  shouldPrintSource: true,
234
- shouldInferAutoLayout: false,
235
238
  }) ?? "Failed to generate summarized node info";
236
239
 
237
240
  return {
@@ -263,11 +266,14 @@ export function registerTools(
263
266
  const result: any = await sendCommandToFigma("get_node_info", { nodeId });
264
267
  const normalizer = createRestNormalizer(result);
265
268
 
269
+ const pipeline = react.createPipeline({
270
+ shouldInferAutoLayout: true,
271
+ shouldInferVariableName: true,
272
+ extend,
273
+ });
266
274
  const code =
267
- reactPipeline.generateCode(normalizer(result.document), {
268
- shouldInferVariableName: true,
275
+ pipeline.generateCode(normalizer(result.document), {
269
276
  shouldPrintSource: false,
270
- shouldInferAutoLayout: true,
271
277
  }) ?? "Failed to generate code";
272
278
 
273
279
  return formatTextResponse(code);
package/src/websocket.ts CHANGED
@@ -54,7 +54,7 @@ export function createFigmaWebSocketClient(serverUrl: string) {
54
54
  ws.on("open", () => {
55
55
  logger.info("Connected to Figma socket server");
56
56
  // Reset channel on new connection
57
- currentChannel = null;
57
+ joinChannel("local-default");
58
58
  });
59
59
 
60
60
  ws.on("message", (data: any) => {