@liner-fe/figma-mcp 1.0.3 → 1.0.5
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/dist/server/server.cjs +87 -58
- package/package.json +2 -3
package/dist/server/server.cjs
CHANGED
|
@@ -24,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
// src/server.ts
|
|
25
25
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
26
26
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
27
|
+
var import_zod = require("zod");
|
|
27
28
|
|
|
28
29
|
// src/figmaClient.ts
|
|
29
30
|
var import_crypto = require("crypto");
|
|
@@ -157,20 +158,47 @@ var { connectToFigma, sendCommandToFigma } = createFigmaClient({
|
|
|
157
158
|
serverUrl,
|
|
158
159
|
wsUrlBase: WS_URL
|
|
159
160
|
});
|
|
160
|
-
server.
|
|
161
|
-
"
|
|
161
|
+
server.tool(
|
|
162
|
+
"get_document_info",
|
|
163
|
+
"Get detailed information about the current Figma document",
|
|
164
|
+
{},
|
|
165
|
+
async () => {
|
|
166
|
+
try {
|
|
167
|
+
const result = await sendCommandToFigma("get_document_info");
|
|
168
|
+
return {
|
|
169
|
+
content: [
|
|
170
|
+
{
|
|
171
|
+
type: "text",
|
|
172
|
+
text: JSON.stringify(result)
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return {
|
|
178
|
+
content: [
|
|
179
|
+
{
|
|
180
|
+
type: "text",
|
|
181
|
+
text: `Error getting document info: ${error instanceof Error ? error.message : String(error)}`
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
server.tool(
|
|
189
|
+
"get_node_info",
|
|
190
|
+
"Get detailed information about a specific node in Figma",
|
|
162
191
|
{
|
|
163
|
-
|
|
164
|
-
inputSchema: {}
|
|
192
|
+
nodeId: import_zod.z.string().describe("The ID of the node to get information about")
|
|
165
193
|
},
|
|
166
|
-
async () => {
|
|
194
|
+
async ({ nodeId }) => {
|
|
167
195
|
try {
|
|
168
|
-
const result = await sendCommandToFigma("
|
|
196
|
+
const result = await sendCommandToFigma("get_node_info", { nodeId });
|
|
169
197
|
return {
|
|
170
198
|
content: [
|
|
171
199
|
{
|
|
172
200
|
type: "text",
|
|
173
|
-
text: JSON.stringify(result
|
|
201
|
+
text: JSON.stringify(result)
|
|
174
202
|
}
|
|
175
203
|
]
|
|
176
204
|
};
|
|
@@ -179,73 +207,74 @@ server.registerTool(
|
|
|
179
207
|
content: [
|
|
180
208
|
{
|
|
181
209
|
type: "text",
|
|
182
|
-
text: `Error getting
|
|
210
|
+
text: `Error getting node info: ${error instanceof Error ? error.message : String(error)}`
|
|
183
211
|
}
|
|
184
212
|
]
|
|
185
213
|
};
|
|
186
214
|
}
|
|
187
215
|
}
|
|
188
216
|
);
|
|
189
|
-
server.
|
|
190
|
-
"
|
|
217
|
+
server.tool(
|
|
218
|
+
"get_nodes_info",
|
|
219
|
+
"Get detailed information about multiple nodes in Figma",
|
|
191
220
|
{
|
|
192
|
-
|
|
221
|
+
nodeIds: import_zod.z.array(import_zod.z.string()).describe("Array of node IDs to get information about")
|
|
193
222
|
},
|
|
194
|
-
() => {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
{
|
|
198
|
-
|
|
199
|
-
|
|
223
|
+
async ({ nodeIds }) => {
|
|
224
|
+
try {
|
|
225
|
+
const results = await Promise.all(
|
|
226
|
+
nodeIds.map(async (nodeId) => {
|
|
227
|
+
const result = await sendCommandToFigma("get_node_info", { nodeId });
|
|
228
|
+
return { nodeId, info: result };
|
|
229
|
+
})
|
|
230
|
+
);
|
|
231
|
+
return {
|
|
232
|
+
content: [
|
|
233
|
+
{
|
|
200
234
|
type: "text",
|
|
201
|
-
text:
|
|
202
|
-
\uD2B9\uD788 Figma \uC778\uD130\uD398\uC774\uC2A4\uC640 \uCF54\uB4DC \uAC04\uC758 \uAD6C\uD604 \uCC28\uC774\uB97C \uC815\uD655\uD558\uAC8C \uD30C\uC545\uD558\uACE0 \uCF54\uB4DC\uC5D0 \uB9DE\uAC8C \uD65C\uC6A9\uD574\uC57C \uD569\uB2C8\uB2E4.`
|
|
235
|
+
text: JSON.stringify(results)
|
|
203
236
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
237
|
+
]
|
|
238
|
+
};
|
|
239
|
+
} catch (error) {
|
|
240
|
+
return {
|
|
241
|
+
content: [
|
|
242
|
+
{
|
|
243
|
+
type: "text",
|
|
244
|
+
text: `Error getting nodes info: ${error instanceof Error ? error.message : String(error)}`
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
};
|
|
248
|
+
}
|
|
208
249
|
}
|
|
209
250
|
);
|
|
210
|
-
server.
|
|
211
|
-
"
|
|
251
|
+
server.registerTool(
|
|
252
|
+
"get_selection",
|
|
212
253
|
{
|
|
213
|
-
description: "
|
|
254
|
+
description: "Get information about the current selection in Figma",
|
|
255
|
+
inputSchema: {}
|
|
214
256
|
},
|
|
215
|
-
() => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
257
|
+
async () => {
|
|
258
|
+
try {
|
|
259
|
+
const result = await sendCommandToFigma("get_selection");
|
|
260
|
+
return {
|
|
261
|
+
content: [
|
|
262
|
+
{
|
|
221
263
|
type: "text",
|
|
222
|
-
text:
|
|
223
|
-
|
|
224
|
-
1. Data Extraction Workflow:
|
|
225
|
-
- Use get_selection() to focus on specific areas of interest
|
|
226
|
-
- Use get_document_info() when connection is enabled
|
|
227
|
-
|
|
228
|
-
2. Component Analysis:
|
|
229
|
-
- Identify reusable components vs one-off elements
|
|
230
|
-
- Look for design system patterns (colors, typography, spacing)
|
|
231
|
-
- Note component variants and their properties
|
|
232
|
-
- Extract design tokens (colors, fonts, spacing values)
|
|
233
|
-
|
|
234
|
-
3. Layout Analysis:
|
|
235
|
-
- Analyze auto-layout settings and constraints
|
|
236
|
-
- Document spacing patterns and grid systems
|
|
237
|
-
- Identify responsive design patterns
|
|
238
|
-
- Note alignment and positioning strategies
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
`
|
|
264
|
+
text: JSON.stringify(result, null, 2)
|
|
244
265
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
266
|
+
]
|
|
267
|
+
};
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return {
|
|
270
|
+
content: [
|
|
271
|
+
{
|
|
272
|
+
type: "text",
|
|
273
|
+
text: `Error getting selection: ${error instanceof Error ? error.message : String(error)}`
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
};
|
|
277
|
+
}
|
|
249
278
|
}
|
|
250
279
|
);
|
|
251
280
|
async function main() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liner-fe/figma-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": "dist/server/server.cjs",
|
|
6
6
|
"files": [
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"start": "concurrently \"pnpm run socket\" \"pnpm run dev\" --names \"SOCKET,MCP\" --prefix-colors \"blue,green\"",
|
|
66
66
|
"build:server": "pnpm tsup",
|
|
67
67
|
"build": "pnpm build:server",
|
|
68
|
-
"build:package": "pnpm build"
|
|
69
|
-
"generate-from-link": "tsx src/generate-from-link.ts"
|
|
68
|
+
"build:package": "pnpm build"
|
|
70
69
|
}
|
|
71
70
|
}
|