figma-code-agent-mcp 1.0.0
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/assetServer.d.ts +34 -0
- package/dist/assetServer.js +168 -0
- package/dist/codeGenerator/componentDetector.d.ts +57 -0
- package/dist/codeGenerator/componentDetector.js +171 -0
- package/dist/codeGenerator/index.d.ts +77 -0
- package/dist/codeGenerator/index.js +184 -0
- package/dist/codeGenerator/jsxGenerator.d.ts +46 -0
- package/dist/codeGenerator/jsxGenerator.js +182 -0
- package/dist/codeGenerator/styleConverter.d.ts +95 -0
- package/dist/codeGenerator/styleConverter.js +306 -0
- package/dist/hints.d.ts +14 -0
- package/dist/hints.js +105 -0
- package/dist/hub.d.ts +9 -0
- package/dist/hub.js +252 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +146 -0
- package/dist/sandbox.d.ts +18 -0
- package/dist/sandbox.js +154 -0
- package/dist/toolRegistry.d.ts +19 -0
- package/dist/toolRegistry.js +729 -0
- package/dist/tools/captureScreenshot.d.ts +28 -0
- package/dist/tools/captureScreenshot.js +31 -0
- package/dist/tools/cloneNode.d.ts +43 -0
- package/dist/tools/cloneNode.js +46 -0
- package/dist/tools/createFrame.d.ts +157 -0
- package/dist/tools/createFrame.js +114 -0
- package/dist/tools/createInstance.d.ts +38 -0
- package/dist/tools/createInstance.js +41 -0
- package/dist/tools/createRectangle.d.ts +108 -0
- package/dist/tools/createRectangle.js +77 -0
- package/dist/tools/createText.d.ts +81 -0
- package/dist/tools/createText.js +67 -0
- package/dist/tools/deleteNode.d.ts +15 -0
- package/dist/tools/deleteNode.js +18 -0
- package/dist/tools/execute.d.ts +17 -0
- package/dist/tools/execute.js +68 -0
- package/dist/tools/getCurrentPage.d.ts +16 -0
- package/dist/tools/getCurrentPage.js +19 -0
- package/dist/tools/getDesignContext.d.ts +42 -0
- package/dist/tools/getDesignContext.js +55 -0
- package/dist/tools/getLocalComponents.d.ts +20 -0
- package/dist/tools/getLocalComponents.js +23 -0
- package/dist/tools/getNode.d.ts +30 -0
- package/dist/tools/getNode.js +33 -0
- package/dist/tools/getSelection.d.ts +10 -0
- package/dist/tools/getSelection.js +13 -0
- package/dist/tools/getStyles.d.ts +17 -0
- package/dist/tools/getStyles.js +20 -0
- package/dist/tools/getVariables.d.ts +26 -0
- package/dist/tools/getVariables.js +29 -0
- package/dist/tools/moveNode.d.ts +28 -0
- package/dist/tools/moveNode.js +31 -0
- package/dist/tools/openInEditor.d.ts +21 -0
- package/dist/tools/openInEditor.js +98 -0
- package/dist/tools/searchNodes.d.ts +30 -0
- package/dist/tools/searchNodes.js +46 -0
- package/dist/tools/searchTools.d.ts +28 -0
- package/dist/tools/searchTools.js +28 -0
- package/dist/tools/swapComponent.d.ts +23 -0
- package/dist/tools/swapComponent.js +26 -0
- package/dist/tools/updateNode.d.ts +194 -0
- package/dist/tools/updateNode.js +163 -0
- package/dist/types.d.ts +101 -0
- package/dist/types.js +1 -0
- package/dist/websocket.d.ts +30 -0
- package/dist/websocket.js +282 -0
- package/package.json +29 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export declare const createTextSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
text: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
name: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
x: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
default: number;
|
|
19
|
+
};
|
|
20
|
+
y: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
default: number;
|
|
24
|
+
};
|
|
25
|
+
fontSize: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
default: number;
|
|
29
|
+
};
|
|
30
|
+
fontFamily: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
fontWeight: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
default: string;
|
|
39
|
+
};
|
|
40
|
+
fillColor: {
|
|
41
|
+
type: string;
|
|
42
|
+
description: string;
|
|
43
|
+
properties: {
|
|
44
|
+
r: {
|
|
45
|
+
type: string;
|
|
46
|
+
minimum: number;
|
|
47
|
+
maximum: number;
|
|
48
|
+
};
|
|
49
|
+
g: {
|
|
50
|
+
type: string;
|
|
51
|
+
minimum: number;
|
|
52
|
+
maximum: number;
|
|
53
|
+
};
|
|
54
|
+
b: {
|
|
55
|
+
type: string;
|
|
56
|
+
minimum: number;
|
|
57
|
+
maximum: number;
|
|
58
|
+
};
|
|
59
|
+
a: {
|
|
60
|
+
type: string;
|
|
61
|
+
minimum: number;
|
|
62
|
+
maximum: number;
|
|
63
|
+
default: number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
required: string[];
|
|
67
|
+
};
|
|
68
|
+
parentId: {
|
|
69
|
+
type: string;
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
returnScreenshot: {
|
|
73
|
+
type: string;
|
|
74
|
+
description: string;
|
|
75
|
+
default: boolean;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
required: string[];
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export declare function createText(params: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const createTextSchema = {
|
|
3
|
+
name: 'create_text',
|
|
4
|
+
description: 'Create a new text node in Figma.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
text: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'The text content to display',
|
|
11
|
+
},
|
|
12
|
+
name: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Name of the text node',
|
|
15
|
+
},
|
|
16
|
+
x: {
|
|
17
|
+
type: 'number',
|
|
18
|
+
description: 'X position of the text',
|
|
19
|
+
default: 0,
|
|
20
|
+
},
|
|
21
|
+
y: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
description: 'Y position of the text',
|
|
24
|
+
default: 0,
|
|
25
|
+
},
|
|
26
|
+
fontSize: {
|
|
27
|
+
type: 'number',
|
|
28
|
+
description: 'Font size in pixels',
|
|
29
|
+
default: 16,
|
|
30
|
+
},
|
|
31
|
+
fontFamily: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Font family name (must be available in Figma)',
|
|
34
|
+
default: 'Inter',
|
|
35
|
+
},
|
|
36
|
+
fontWeight: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'Font weight/style (e.g., "Regular", "Bold", "Medium", "Semi Bold")',
|
|
39
|
+
default: 'Regular',
|
|
40
|
+
},
|
|
41
|
+
fillColor: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
description: 'Text color (RGB values from 0-1)',
|
|
44
|
+
properties: {
|
|
45
|
+
r: { type: 'number', minimum: 0, maximum: 1 },
|
|
46
|
+
g: { type: 'number', minimum: 0, maximum: 1 },
|
|
47
|
+
b: { type: 'number', minimum: 0, maximum: 1 },
|
|
48
|
+
a: { type: 'number', minimum: 0, maximum: 1, default: 1 },
|
|
49
|
+
},
|
|
50
|
+
required: ['r', 'g', 'b'],
|
|
51
|
+
},
|
|
52
|
+
parentId: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'ID of the parent node to create the text in.',
|
|
55
|
+
},
|
|
56
|
+
returnScreenshot: {
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
description: 'If true, returns a screenshot of the created element for visual verification',
|
|
59
|
+
default: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ['text'],
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export async function createText(params) {
|
|
66
|
+
return figmaWebSocket.sendCommand('createText', params);
|
|
67
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const deleteNodeSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
nodeId: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
required: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function deleteNode(params: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const deleteNodeSchema = {
|
|
3
|
+
name: 'delete_node',
|
|
4
|
+
description: 'Delete a node from Figma.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
nodeId: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'ID of the node to delete',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
required: ['nodeId'],
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export async function deleteNode(params) {
|
|
17
|
+
return figmaWebSocket.sendCommand('deleteNode', params);
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema for the execute tool — runs JavaScript in a sandbox with figma.* API.
|
|
3
|
+
*/
|
|
4
|
+
export declare const executeSchema: {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: "object";
|
|
9
|
+
properties: {
|
|
10
|
+
code: {
|
|
11
|
+
type: string;
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
required: string[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema for the execute tool — runs JavaScript in a sandbox with figma.* API.
|
|
3
|
+
*/
|
|
4
|
+
export const executeSchema = {
|
|
5
|
+
name: 'execute',
|
|
6
|
+
description: `Execute JavaScript code in a sandbox with access to the figma.* API.
|
|
7
|
+
Use this to batch multiple operations in a single call (create UIs, modify nodes, read data).
|
|
8
|
+
Works in both Figma Design and FigJam files — use \`figma.getEditorType()\` to detect which.
|
|
9
|
+
|
|
10
|
+
## Quick API Reference
|
|
11
|
+
|
|
12
|
+
**Create (Figma Design):** figma.create(opts) [unified with presets], figma.createFrame, figma.createRectangle, figma.createEllipse, figma.createLine, figma.createText, figma.createInstance, figma.cloneNode
|
|
13
|
+
**Create (FigJam):** figma.createSection, figma.createSticky, figma.createShape, figma.createConnector — also available via figma.create({ type: "section" | "sticky" | "shape" | "connector" })
|
|
14
|
+
**Read:** figma.getNode, figma.getSelection(), figma.getCurrentPage, figma.getStyles, figma.getLocalComponents, figma.getVariables, figma.searchNodes, figma.captureScreenshot, figma.getEditorType()
|
|
15
|
+
**Update:** figma.updateNode, figma.moveNode, figma.swapComponent
|
|
16
|
+
**Delete:** figma.deleteNode
|
|
17
|
+
**Tokens:** figma.createToken(opts), figma.bindToken(opts)
|
|
18
|
+
**Components:** figma.toComponent(opts), figma.createVariants(opts), figma.addComponentProperty(opts), figma.setInstanceOverride(opts)
|
|
19
|
+
**Accessibility:** figma.checkAccessibility(opts)
|
|
20
|
+
|
|
21
|
+
All methods are async — use \`await\`. Use \`return\` to send results back.
|
|
22
|
+
Use \`console.log()\` for debug output (captured in response).
|
|
23
|
+
Use \`search_tools\` to discover full parameter details for any method (try category "figjam").
|
|
24
|
+
|
|
25
|
+
**Colors** accept hex strings ("#FF0000"), rgb("rgb(255,0,0)"), or {r,g,b} objects. Use \`fill\`/\`stroke\` as aliases for fillColor/strokeColor.
|
|
26
|
+
**Target specifiers:** use "selection", "name:NodeName", or "page" instead of node IDs.
|
|
27
|
+
**Layout (Figma Design):** use CSS-like \`layout: { direction: "row", gap: 12, padding: 16 }\` instead of raw Figma props.
|
|
28
|
+
**Presets:** \`figma.create({ type: "card" })\` applies sensible defaults. Types: card, button, nav, input, form.
|
|
29
|
+
|
|
30
|
+
## FigJam
|
|
31
|
+
|
|
32
|
+
In FigJam, use sections (containers), stickies (notes), shapes (diagrams), connectors (lines between nodes), and text. Frames/rectangles are auto-remapped to sections/shapes as a fallback, but prefer explicit FigJam methods.
|
|
33
|
+
|
|
34
|
+
## Example (Figma Design)
|
|
35
|
+
|
|
36
|
+
\`\`\`js
|
|
37
|
+
const card = await figma.create({
|
|
38
|
+
type: "card",
|
|
39
|
+
name: "Profile",
|
|
40
|
+
children: [
|
|
41
|
+
{ type: "text", content: "Hello World", fontSize: 24, fontWeight: "Bold" },
|
|
42
|
+
{ type: "button", children: [{ type: "text", content: "Click me", fill: "#FFF" }] }
|
|
43
|
+
]
|
|
44
|
+
});
|
|
45
|
+
return card;
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
## Example (FigJam)
|
|
49
|
+
|
|
50
|
+
\`\`\`js
|
|
51
|
+
const section = await figma.createSection({ name: "Sprint Planning", width: 800, height: 600 });
|
|
52
|
+
const shapeA = await figma.createShape({ text: "Frontend", fillColor: "#E8F0FE", parentId: section.id });
|
|
53
|
+
const shapeB = await figma.createShape({ text: "API", x: 400, fillColor: "#FCE8E6", parentId: section.id });
|
|
54
|
+
await figma.createConnector({ startNodeId: shapeA.id, endNodeId: shapeB.id, endStrokeCap: "ARROW_EQUILATERAL", text: "REST calls" });
|
|
55
|
+
await figma.createSticky({ text: "User story #1", fillColor: "#FFF9B1", parentId: section.id });
|
|
56
|
+
return section;
|
|
57
|
+
\`\`\``,
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
properties: {
|
|
61
|
+
code: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'JavaScript code to execute. All figma.* methods are async. Use return to send back results.',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
required: ['code'],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const getCurrentPageSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
depth: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
default: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
required: never[];
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function getCurrentPage(params: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const getCurrentPageSchema = {
|
|
3
|
+
name: 'get_current_page',
|
|
4
|
+
description: 'Get a lightweight tree structure of the current Figma page. Returns hierarchy with id, name, type, and text content (for text nodes). Use this to understand page structure before making changes. Use get_node for detailed properties of specific nodes.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
depth: {
|
|
9
|
+
type: 'number',
|
|
10
|
+
description: 'Maximum depth to traverse (default: 10). Use lower values for complex pages.',
|
|
11
|
+
default: 10,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
required: [],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export async function getCurrentPage(params) {
|
|
18
|
+
return figmaWebSocket.sendCommand('getCurrentPage', params);
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare const getDesignContextSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
nodeId: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
depth: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
default: number;
|
|
15
|
+
};
|
|
16
|
+
exportImages: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
default: boolean;
|
|
20
|
+
};
|
|
21
|
+
includeTokens: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
generateNestedComponents: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
default: boolean;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
required: string[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export interface GetDesignContextParams {
|
|
36
|
+
nodeId: string;
|
|
37
|
+
depth?: number;
|
|
38
|
+
exportImages?: boolean;
|
|
39
|
+
includeTokens?: boolean;
|
|
40
|
+
generateNestedComponents?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare function getDesignContext(params: Record<string, unknown>): Promise<string>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
import { generateDesignContext, formatDesignContextResponse, } from '../codeGenerator/index.js';
|
|
3
|
+
export const getDesignContextSchema = {
|
|
4
|
+
name: 'get_design_context',
|
|
5
|
+
description: `Generate React + Tailwind CSS code from a Figma design. This tool:
|
|
6
|
+
- Extracts the full node tree with styling details
|
|
7
|
+
- Converts Figma auto-layout to Flexbox
|
|
8
|
+
- Maps Figma styles to Tailwind utility classes
|
|
9
|
+
- Exports images to a local asset server
|
|
10
|
+
- Detects component instances and generates their implementations
|
|
11
|
+
- Extracts design tokens (colors, typography)
|
|
12
|
+
- Includes component documentation links from Figma
|
|
13
|
+
|
|
14
|
+
The generated code includes data-node-id attributes for traceability back to Figma.`,
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
nodeId: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'ID of the Figma node to convert, or a Figma URL containing the node-id parameter',
|
|
21
|
+
},
|
|
22
|
+
depth: {
|
|
23
|
+
type: 'number',
|
|
24
|
+
description: 'How deep to traverse children. Default is 10.',
|
|
25
|
+
default: 10,
|
|
26
|
+
},
|
|
27
|
+
exportImages: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
description: 'Whether to export images (nodes with image fills, vectors, icons). Default is true.',
|
|
30
|
+
default: true,
|
|
31
|
+
},
|
|
32
|
+
includeTokens: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
description: 'Whether to include design tokens (colors, typography). Default is true.',
|
|
35
|
+
default: true,
|
|
36
|
+
},
|
|
37
|
+
generateNestedComponents: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
description: 'Whether to generate stub implementations for nested component instances. Default is true.',
|
|
40
|
+
default: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
required: ['nodeId'],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
export async function getDesignContext(params) {
|
|
47
|
+
const nodeId = params.nodeId;
|
|
48
|
+
const generateNestedComponents = params.generateNestedComponents !== false;
|
|
49
|
+
// Get design context from Figma plugin
|
|
50
|
+
const result = (await figmaWebSocket.sendCommand('getDesignContext', params));
|
|
51
|
+
// Generate React + Tailwind code
|
|
52
|
+
const output = generateDesignContext(result, { generateNestedComponents });
|
|
53
|
+
// Format the response
|
|
54
|
+
return formatDesignContextResponse(output, nodeId);
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const getLocalComponentsSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
nameFilter: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
limit: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
default: number;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: never[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function getLocalComponents(params: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const getLocalComponentsSchema = {
|
|
3
|
+
name: 'get_local_components',
|
|
4
|
+
description: 'Get all local components and component sets in the current file. Returns componentId for use with create_instance.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
nameFilter: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Filter components by name (case-insensitive contains match)',
|
|
11
|
+
},
|
|
12
|
+
limit: {
|
|
13
|
+
type: 'number',
|
|
14
|
+
description: 'Maximum number of components to return. Default is 50.',
|
|
15
|
+
default: 50,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: [],
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export async function getLocalComponents(params) {
|
|
22
|
+
return figmaWebSocket.sendCommand('getLocalComponents', params);
|
|
23
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const getNodeSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
nodeId: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
depth: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
default: number;
|
|
15
|
+
};
|
|
16
|
+
childLimit: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
default: number;
|
|
20
|
+
};
|
|
21
|
+
detailed: {
|
|
22
|
+
type: string;
|
|
23
|
+
description: string;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
required: string[];
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare function getNode(params: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const getNodeSchema = {
|
|
3
|
+
name: 'get_node',
|
|
4
|
+
description: 'Get information about a specific node in Figma. By default returns lightweight data (id, name, type, dimensions, text). Use detailed=true for full styling info (fills, strokes, layout, etc). WARNING: Using depth > 1 with detailed=true can return very large responses that fill up context quickly. Start with depth=0 or depth=1 and detailed=false, only increase if needed.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
nodeId: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'ID of the node, or a Figma URL containing the node-id parameter',
|
|
11
|
+
},
|
|
12
|
+
depth: {
|
|
13
|
+
type: 'number',
|
|
14
|
+
description: 'How deep to traverse children (0 = no children, 1 = direct children only). Default is 0.',
|
|
15
|
+
default: 0,
|
|
16
|
+
},
|
|
17
|
+
childLimit: {
|
|
18
|
+
type: 'number',
|
|
19
|
+
description: 'Maximum number of children to return per node. Default is 20.',
|
|
20
|
+
default: 20,
|
|
21
|
+
},
|
|
22
|
+
detailed: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
description: 'If true, include full styling details (fills, strokes, effects, layout properties). Default is false (lightweight response).',
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ['nodeId'],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export async function getNode(params) {
|
|
32
|
+
return figmaWebSocket.sendCommand('getNode', params);
|
|
33
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const getSelectionSchema = {
|
|
3
|
+
name: 'get_selection',
|
|
4
|
+
description: 'Get the currently selected nodes in Figma.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {},
|
|
8
|
+
required: [],
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
export async function getSelection() {
|
|
12
|
+
return figmaWebSocket.sendCommand('getSelection', {});
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const getStylesSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
type: {
|
|
8
|
+
type: string;
|
|
9
|
+
enum: string[];
|
|
10
|
+
description: string;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
required: never[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function getStyles(params: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const getStylesSchema = {
|
|
3
|
+
name: 'get_styles',
|
|
4
|
+
description: 'Get all local styles (colors, text, effects, grids) from the current file.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
type: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
enum: ['PAINT', 'TEXT', 'EFFECT', 'GRID', 'ALL'],
|
|
11
|
+
description: 'Type of styles to get. PAINT=colors, TEXT=typography, ALL=everything. Default is ALL.',
|
|
12
|
+
default: 'ALL',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
required: [],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export async function getStyles(params) {
|
|
19
|
+
return figmaWebSocket.sendCommand('getStyles', params);
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const getVariablesSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
collectionName: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
type: {
|
|
12
|
+
type: string;
|
|
13
|
+
enum: string[];
|
|
14
|
+
description: string;
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
limit: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
default: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
required: never[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare function getVariables(params: Record<string, unknown>): Promise<unknown>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { figmaWebSocket } from '../websocket.js';
|
|
2
|
+
export const getVariablesSchema = {
|
|
3
|
+
name: 'get_variables',
|
|
4
|
+
description: 'Get variables and variable collections from the current file. Variables can be colors, numbers, strings, or booleans.',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
collectionName: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Filter by collection name (case-insensitive contains match)',
|
|
11
|
+
},
|
|
12
|
+
type: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
enum: ['COLOR', 'FLOAT', 'STRING', 'BOOLEAN', 'ALL'],
|
|
15
|
+
description: 'Filter by variable type. Default is ALL.',
|
|
16
|
+
default: 'ALL',
|
|
17
|
+
},
|
|
18
|
+
limit: {
|
|
19
|
+
type: 'number',
|
|
20
|
+
description: 'Maximum number of variables to return. Default is 100.',
|
|
21
|
+
default: 100,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
required: [],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export async function getVariables(params) {
|
|
28
|
+
return figmaWebSocket.sendCommand('getVariables', params);
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const moveNodeSchema: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
nodeId: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
parentId: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
index: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
returnScreenshot: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
default: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function moveNode(params: Record<string, unknown>): Promise<unknown>;
|