figma-mcp-server 0.1.2 → 2.0.1
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/LICENSE +1 -0
- package/README.md +57 -43
- package/bun.lock +197 -0
- package/index.js +1 -2
- package/lib/tools.js +1 -5
- package/mcpServer.js +11 -10
- package/package.json +9 -8
- package/tools/figma/figma-api/create-dev-resources-for-a-file.js +0 -20
- package/tools/figma/figma-api/create-variable-collections-for-a-file.js +0 -18
- package/tools/figma/figma-api/get-a-published-component-by-key.js +0 -16
- package/tools/figma/figma-api/get-a-published-component-set-by-key.js +0 -16
- package/tools/figma/figma-api/get-a-published-library-by-id.js +0 -16
- package/tools/figma/figma-api/get-a-published-style-by-key.js +0 -16
- package/tools/figma/figma-api/get-current-user.js +0 -13
- package/tools/figma/figma-api/get-file-nodes.js +0 -17
- package/tools/figma/figma-api/get-file-version-history.js +0 -16
- package/tools/figma/figma-api/get-file.js +0 -16
- package/tools/figma/figma-api/get-image-fills.js +0 -17
- package/tools/figma/figma-api/get-library-action-analytics.js +0 -16
- package/tools/figma/figma-api/get-library-usage-analytics.js +0 -16
- package/tools/figma/figma-api/list-comments-on-a-file.js +0 -16
- package/tools/figma/figma-api/list-component-sets-in-a-file.js +0 -16
- package/tools/figma/figma-api/list-components-in-a-file.js +0 -16
- package/tools/figma/figma-api/list-dev-resources-for-a-file.js +0 -16
- package/tools/figma/figma-api/list-files-in-a-project.js +0 -16
- package/tools/figma/figma-api/list-projects-in-a-team.js +0 -16
- package/tools/figma/figma-api/list-published-libraries.js +0 -13
- package/tools/figma/figma-api/list-styles-in-a-file.js +0 -16
- package/tools/figma/figma-api/list-variables-for-a-file.js +0 -16
- package/tools/figma/figma-api/post-a-comment-to-a-file.js +1 -23
- package/Dockerfile +0 -28
- package/smithery.yaml +0 -39
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to list development resources for a specific Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file to retrieve development resources for.
|
|
6
|
-
* @returns {Promise<Object>} - The result of the development resources request.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ file_key }) => {
|
|
9
2
|
const baseUrl = 'https://api.figma.com';
|
|
10
3
|
const token = process.env.FIGMA_API_KEY;
|
|
11
4
|
try {
|
|
12
|
-
// Construct the URL for the request
|
|
13
5
|
const url = `${baseUrl}/v1/files/${file_key}/dev_resources`;
|
|
14
6
|
|
|
15
|
-
// Set up headers for the request
|
|
16
7
|
const headers = {
|
|
17
8
|
'X-Figma-Token': token
|
|
18
9
|
};
|
|
19
10
|
|
|
20
|
-
// Perform the fetch request
|
|
21
11
|
const response = await fetch(url, {
|
|
22
12
|
method: 'GET',
|
|
23
13
|
headers
|
|
24
14
|
});
|
|
25
15
|
|
|
26
|
-
// Check if the response was successful
|
|
27
16
|
if (!response.ok) {
|
|
28
17
|
const errorData = await response.json();
|
|
29
18
|
throw new Error(errorData);
|
|
30
19
|
}
|
|
31
20
|
|
|
32
|
-
// Parse and return the response data
|
|
33
21
|
const data = await response.json();
|
|
34
22
|
return data;
|
|
35
23
|
} catch (error) {
|
|
@@ -38,10 +26,6 @@ const executeFunction = async ({ file_key }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for listing development resources for a Figma file.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to list files in a specified Figma project.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.project_id - The ID of the project to list files from.
|
|
6
|
-
* @returns {Promise<Object>} - The result of the files listing.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ project_id }) => {
|
|
9
2
|
const baseUrl = 'https://api.figma.com';
|
|
10
3
|
const token = process.env.FIGMA_API_KEY;
|
|
11
4
|
|
|
12
5
|
try {
|
|
13
|
-
// Construct the URL for the request
|
|
14
6
|
const url = `${baseUrl}/v1/projects/${project_id}/files`;
|
|
15
7
|
|
|
16
|
-
// Set up headers for the request
|
|
17
8
|
const headers = {
|
|
18
9
|
'X-Figma-Token': token
|
|
19
10
|
};
|
|
20
11
|
|
|
21
|
-
// Perform the fetch request
|
|
22
12
|
const response = await fetch(url, {
|
|
23
13
|
method: 'GET',
|
|
24
14
|
headers
|
|
25
15
|
});
|
|
26
16
|
|
|
27
|
-
// Check if the response was successful
|
|
28
17
|
if (!response.ok) {
|
|
29
18
|
const errorData = await response.json();
|
|
30
19
|
throw new Error(errorData);
|
|
31
20
|
}
|
|
32
21
|
|
|
33
|
-
// Parse and return the response data
|
|
34
22
|
const data = await response.json();
|
|
35
23
|
return data;
|
|
36
24
|
} catch (error) {
|
|
@@ -39,10 +27,6 @@ const executeFunction = async ({ project_id }) => {
|
|
|
39
27
|
}
|
|
40
28
|
};
|
|
41
29
|
|
|
42
|
-
/**
|
|
43
|
-
* Tool configuration for listing files in a Figma project.
|
|
44
|
-
* @type {Object}
|
|
45
|
-
*/
|
|
46
30
|
const apiTool = {
|
|
47
31
|
function: executeFunction,
|
|
48
32
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to list projects in a specified team on Figma.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.team_id - The ID of the team for which to list projects.
|
|
6
|
-
* @returns {Promise<Object>} - The list of projects within the specified team.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ team_id }) => {
|
|
9
2
|
const baseUrl = 'https://api.figma.com';
|
|
10
3
|
const token = process.env.FIGMA_API_KEY;
|
|
11
4
|
try {
|
|
12
|
-
// Construct the URL for the request
|
|
13
5
|
const url = `${baseUrl}/v1/teams/${team_id}/projects`;
|
|
14
6
|
|
|
15
|
-
// Set up headers for the request
|
|
16
7
|
const headers = {
|
|
17
8
|
'X-Figma-Token': token
|
|
18
9
|
};
|
|
19
10
|
|
|
20
|
-
// Perform the fetch request
|
|
21
11
|
const response = await fetch(url, {
|
|
22
12
|
method: 'GET',
|
|
23
13
|
headers
|
|
24
14
|
});
|
|
25
15
|
|
|
26
|
-
// Check if the response was successful
|
|
27
16
|
if (!response.ok) {
|
|
28
17
|
const errorData = await response.json();
|
|
29
18
|
throw new Error(errorData);
|
|
30
19
|
}
|
|
31
20
|
|
|
32
|
-
// Parse and return the response data
|
|
33
21
|
const data = await response.json();
|
|
34
22
|
return data;
|
|
35
23
|
} catch (error) {
|
|
@@ -38,10 +26,6 @@ const executeFunction = async ({ team_id }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for listing projects in a team on Figma.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to list published libraries in Figma.
|
|
3
|
-
*
|
|
4
|
-
* @returns {Promise<Array>} - A promise that resolves to an array of published libraries.
|
|
5
|
-
*/
|
|
6
1
|
const executeFunction = async () => {
|
|
7
2
|
const baseUrl = 'https://api.figma.com/v1/libraries/published';
|
|
8
3
|
const token = process.env.FIGMA_API_KEY;
|
|
9
4
|
try {
|
|
10
|
-
// Set up headers for the request
|
|
11
5
|
const headers = {
|
|
12
6
|
'X-Figma-Token': token
|
|
13
7
|
};
|
|
14
8
|
|
|
15
|
-
// Perform the fetch request
|
|
16
9
|
const response = await fetch(baseUrl, {
|
|
17
10
|
method: 'GET',
|
|
18
11
|
headers
|
|
19
12
|
});
|
|
20
13
|
|
|
21
|
-
// Check if the response was successful
|
|
22
14
|
if (!response.ok) {
|
|
23
15
|
const errorData = await response.json();
|
|
24
16
|
throw new Error(errorData);
|
|
25
17
|
}
|
|
26
18
|
|
|
27
|
-
// Parse and return the response data
|
|
28
19
|
const data = await response.json();
|
|
29
20
|
return data;
|
|
30
21
|
} catch (error) {
|
|
@@ -33,10 +24,6 @@ const executeFunction = async () => {
|
|
|
33
24
|
}
|
|
34
25
|
};
|
|
35
26
|
|
|
36
|
-
/**
|
|
37
|
-
* Tool configuration for listing published libraries in Figma.
|
|
38
|
-
* @type {Object}
|
|
39
|
-
*/
|
|
40
27
|
const apiTool = {
|
|
41
28
|
function: executeFunction,
|
|
42
29
|
definition: {
|
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to list styles in a specific Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file to retrieve styles from.
|
|
6
|
-
* @returns {Promise<Object>} - The response containing styles from the specified Figma file.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ file_key }) => {
|
|
9
2
|
const baseUrl = 'https://api.figma.com';
|
|
10
3
|
const token = process.env.FIGMA_API_KEY;
|
|
11
4
|
|
|
12
5
|
try {
|
|
13
|
-
// Construct the URL for the request
|
|
14
6
|
const url = `${baseUrl}/v1/files/${file_key}/styles`;
|
|
15
7
|
|
|
16
|
-
// Set up headers for the request
|
|
17
8
|
const headers = {
|
|
18
9
|
'X-Figma-Token': token
|
|
19
10
|
};
|
|
20
11
|
|
|
21
|
-
// Perform the fetch request
|
|
22
12
|
const response = await fetch(url, {
|
|
23
13
|
method: 'GET',
|
|
24
14
|
headers
|
|
25
15
|
});
|
|
26
16
|
|
|
27
|
-
// Check if the response was successful
|
|
28
17
|
if (!response.ok) {
|
|
29
18
|
const errorData = await response.json();
|
|
30
19
|
throw new Error(errorData);
|
|
31
20
|
}
|
|
32
21
|
|
|
33
|
-
// Parse and return the response data
|
|
34
22
|
const data = await response.json();
|
|
35
23
|
return data;
|
|
36
24
|
} catch (error) {
|
|
@@ -39,10 +27,6 @@ const executeFunction = async ({ file_key }) => {
|
|
|
39
27
|
}
|
|
40
28
|
};
|
|
41
29
|
|
|
42
|
-
/**
|
|
43
|
-
* Tool configuration for listing styles in a Figma file.
|
|
44
|
-
* @type {Object}
|
|
45
|
-
*/
|
|
46
30
|
const apiTool = {
|
|
47
31
|
function: executeFunction,
|
|
48
32
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to list variables for a specific Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file for which to list variables.
|
|
6
|
-
* @returns {Promise<Object>} - The response containing the variable collections and variables defined in the specified Figma file.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ file_key }) => {
|
|
9
2
|
const baseUrl = 'https://api.figma.com';
|
|
10
3
|
const token = process.env.FIGMA_API_KEY;
|
|
11
4
|
try {
|
|
12
|
-
// Construct the URL for the request
|
|
13
5
|
const url = `${baseUrl}/v1/files/${file_key}/variables`;
|
|
14
6
|
|
|
15
|
-
// Set up headers for the request
|
|
16
7
|
const headers = {
|
|
17
8
|
'X-Figma-Token': token
|
|
18
9
|
};
|
|
19
10
|
|
|
20
|
-
// Perform the fetch request
|
|
21
11
|
const response = await fetch(url, {
|
|
22
12
|
method: 'GET',
|
|
23
13
|
headers
|
|
24
14
|
});
|
|
25
15
|
|
|
26
|
-
// Check if the response was successful
|
|
27
16
|
if (!response.ok) {
|
|
28
17
|
const errorData = await response.json();
|
|
29
18
|
throw new Error(errorData);
|
|
30
19
|
}
|
|
31
20
|
|
|
32
|
-
// Parse and return the response data
|
|
33
21
|
const data = await response.json();
|
|
34
22
|
return data;
|
|
35
23
|
} catch (error) {
|
|
@@ -38,10 +26,6 @@ const executeFunction = async ({ file_key }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for listing variables for a Figma file.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,49 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to post a comment to a Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the comment.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file to comment on.
|
|
6
|
-
* @param {string} args.message - The message of the comment.
|
|
7
|
-
* @param {Object} [args.client_meta] - Optional metadata for the comment's location.
|
|
8
|
-
* @param {number} [args.client_meta.x] - The x-coordinate for the comment.
|
|
9
|
-
* @param {number} [args.client_meta.y] - The y-coordinate for the comment.
|
|
10
|
-
* @param {string} [args.client_meta.node_id] - The node ID for the comment.
|
|
11
|
-
* @returns {Promise<Object>} - The result of the comment posting.
|
|
12
|
-
*/
|
|
13
1
|
const executeFunction = async ({ file_key, message, client_meta = {} }) => {
|
|
14
2
|
const baseUrl = 'https://api.figma.com';
|
|
15
3
|
const token = process.env.FIGMA_API_KEY;
|
|
16
4
|
|
|
17
5
|
try {
|
|
18
|
-
// Construct the URL for posting a comment
|
|
19
6
|
const url = `${baseUrl}/v1/files/${file_key}/comments`;
|
|
20
7
|
|
|
21
|
-
// Set up headers for the request
|
|
22
8
|
const headers = {
|
|
23
9
|
'X-Figma-Token': token,
|
|
24
10
|
'Content-Type': 'application/json'
|
|
25
11
|
};
|
|
26
12
|
|
|
27
|
-
// Prepare the body of the request
|
|
28
13
|
const body = JSON.stringify({
|
|
29
14
|
message,
|
|
30
15
|
client_meta
|
|
31
16
|
});
|
|
32
17
|
|
|
33
|
-
// Perform the fetch request
|
|
34
18
|
const response = await fetch(url, {
|
|
35
19
|
method: 'POST',
|
|
36
20
|
headers,
|
|
37
21
|
body
|
|
38
22
|
});
|
|
39
23
|
|
|
40
|
-
// Check if the response was successful
|
|
41
24
|
if (!response.ok) {
|
|
42
25
|
const errorData = await response.json();
|
|
43
26
|
throw new Error(errorData);
|
|
44
27
|
}
|
|
45
28
|
|
|
46
|
-
// Parse and return the response data
|
|
47
29
|
const data = await response.json();
|
|
48
30
|
return data;
|
|
49
31
|
} catch (error) {
|
|
@@ -52,10 +34,6 @@ const executeFunction = async ({ file_key, message, client_meta = {} }) => {
|
|
|
52
34
|
}
|
|
53
35
|
};
|
|
54
36
|
|
|
55
|
-
/**
|
|
56
|
-
* Tool configuration for posting comments to a Figma file.
|
|
57
|
-
* @type {Object}
|
|
58
|
-
*/
|
|
59
37
|
const apiTool = {
|
|
60
38
|
function: executeFunction,
|
|
61
39
|
definition: {
|
|
@@ -99,4 +77,4 @@ const apiTool = {
|
|
|
99
77
|
}
|
|
100
78
|
};
|
|
101
79
|
|
|
102
|
-
export { apiTool };
|
|
80
|
+
export { apiTool };
|
package/Dockerfile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
FROM node:22.12-alpine AS builder
|
|
2
|
-
|
|
3
|
-
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
4
|
-
|
|
5
|
-
WORKDIR /app
|
|
6
|
-
COPY package.json pnpm-lock.yaml ./
|
|
7
|
-
RUN pnpm install --frozen-lockfile
|
|
8
|
-
|
|
9
|
-
COPY . .
|
|
10
|
-
|
|
11
|
-
# Production stage
|
|
12
|
-
FROM node:22.12-alpine
|
|
13
|
-
|
|
14
|
-
WORKDIR /app
|
|
15
|
-
|
|
16
|
-
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
17
|
-
|
|
18
|
-
COPY package.json pnpm-lock.yaml ./
|
|
19
|
-
RUN pnpm install --prod --frozen-lockfile
|
|
20
|
-
|
|
21
|
-
COPY --from=builder /app/mcpServer.js ./
|
|
22
|
-
|
|
23
|
-
ENV NODE_ENV=production
|
|
24
|
-
|
|
25
|
-
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
|
|
26
|
-
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
|
|
27
|
-
|
|
28
|
-
ENTRYPOINT ["node", "mcpServer.js"]
|
package/smithery.yaml
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
startCommand:
|
|
2
|
-
type: http
|
|
3
|
-
command: node mcpServer.js --sse
|
|
4
|
-
configSchema:
|
|
5
|
-
type: object
|
|
6
|
-
required: ["port"]
|
|
7
|
-
properties:
|
|
8
|
-
port:
|
|
9
|
-
type: number
|
|
10
|
-
title: "Server Port"
|
|
11
|
-
description: "Port number for the MCP server"
|
|
12
|
-
default: 3001
|
|
13
|
-
mode:
|
|
14
|
-
type: string
|
|
15
|
-
title: "Server Mode"
|
|
16
|
-
description: "Choose between SSE (Server-Sent Events) or stdio mode"
|
|
17
|
-
enum: ["sse", "stdio"]
|
|
18
|
-
default: "sse"
|
|
19
|
-
serverName:
|
|
20
|
-
type: string
|
|
21
|
-
title: "Server Name"
|
|
22
|
-
description: "Name of the MCP server instance"
|
|
23
|
-
default: "generated-mcp-server"
|
|
24
|
-
version:
|
|
25
|
-
type: string
|
|
26
|
-
title: "Server Version"
|
|
27
|
-
description: "Version of the MCP server"
|
|
28
|
-
default: "0.1.2"
|
|
29
|
-
|
|
30
|
-
connection:
|
|
31
|
-
type: sse
|
|
32
|
-
configSchema:
|
|
33
|
-
type: object
|
|
34
|
-
properties:
|
|
35
|
-
baseUrl:
|
|
36
|
-
type: string
|
|
37
|
-
title: "Base URL"
|
|
38
|
-
description: "Base URL for the MCP server"
|
|
39
|
-
default: "http://localhost:3001"
|