figma-mcp-server 0.0.0-alpha.1 → 0.1.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/Dockerfile +9 -0
- package/LICENSE +19 -0
- package/README.md +41 -92
- package/commands/tools.js +65 -0
- package/lib/tools.js +16 -0
- package/mcpServer.js +145 -0
- package/package.json +9 -4
- package/tools/figma/figma-api/add-webhook.js +57 -0
- package/tools/figma/figma-api/create-variable-collection.js +84 -0
- package/tools/figma/figma-api/delete-webhook.js +64 -0
- package/tools/figma/figma-api/get-actions-analytics.js +67 -0
- package/tools/figma/figma-api/get-all-webhooks-for-team.js +56 -0
- package/tools/figma/figma-api/get-design-node.js +72 -0
- package/tools/figma/figma-api/get-design.js +66 -0
- package/tools/figma/figma-api/get-dev-resources.js +67 -0
- package/tools/figma/figma-api/get-file-comments.js +67 -0
- package/tools/figma/figma-api/get-image-node.js +74 -0
- package/tools/figma/figma-api/get-images.js +66 -0
- package/tools/figma/figma-api/get-library-analytics.js +66 -0
- package/tools/figma/figma-api/get-project-files.js +66 -0
- package/tools/figma/figma-api/get-team-projects.js +66 -0
- package/tools/figma/figma-api/post-a-new-comment.js +89 -0
- package/tools/figma/figma-api/post-dev-resource.js +93 -0
- package/tools/figma/figma-api/reply-to-comment.js +84 -0
- package/tools/paths.js +19 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to get projects associated with a specific team in Figma.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} args - Arguments for the request.
|
|
5
|
+
* @param {string} args.team_id - The ID of the team whose projects are to be retrieved.
|
|
6
|
+
* @returns {Promise<Object>} - The list of projects associated with the team.
|
|
7
|
+
*/
|
|
8
|
+
const executeFunction = async ({ team_id }) => {
|
|
9
|
+
const baseUrl = 'https://api.figma.com/v1';
|
|
10
|
+
const token = process.env.FIGMA_API_KEY;
|
|
11
|
+
try {
|
|
12
|
+
// Construct the URL for the request
|
|
13
|
+
const url = `${baseUrl}/teams/${team_id}/projects`;
|
|
14
|
+
|
|
15
|
+
// Set up headers for the request
|
|
16
|
+
const headers = {
|
|
17
|
+
'X-Figma-Token': token
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Perform the fetch request
|
|
21
|
+
const response = await fetch(url, {
|
|
22
|
+
method: 'GET',
|
|
23
|
+
headers
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Check if the response was successful
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
const errorData = await response.json();
|
|
29
|
+
throw new Error(errorData);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Parse and return the response data
|
|
33
|
+
const data = await response.json();
|
|
34
|
+
return data;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Error retrieving team projects:', error);
|
|
37
|
+
return { error: 'An error occurred while retrieving team projects.' };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Tool configuration for getting team projects in Figma.
|
|
43
|
+
* @type {Object}
|
|
44
|
+
*/
|
|
45
|
+
const apiTool = {
|
|
46
|
+
function: executeFunction,
|
|
47
|
+
definition: {
|
|
48
|
+
type: 'function',
|
|
49
|
+
function: {
|
|
50
|
+
name: 'get_team_projects',
|
|
51
|
+
description: 'Retrieve projects associated with a specific team in Figma.',
|
|
52
|
+
parameters: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
team_id: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'The ID of the team whose projects are to be retrieved.'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
required: ['team_id']
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { apiTool };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to post a new comment on a Figma file.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} args - Arguments for the comment.
|
|
5
|
+
* @param {string} args.file_key - The unique identifier of the file to which the comment should be added.
|
|
6
|
+
* @param {string} args.node_id - The node ID where the comment is to be placed.
|
|
7
|
+
* @param {string} args.message - The message content of the comment.
|
|
8
|
+
* @returns {Promise<Object>} - The response from the Figma API after posting the comment.
|
|
9
|
+
*/
|
|
10
|
+
const executeFunction = async ({ file_key, node_id, message }) => {
|
|
11
|
+
const baseUrl = 'https://api.figma.com/v1';
|
|
12
|
+
const token = process.env.FIGMA_API_KEY;
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
// Construct the URL for the API request
|
|
16
|
+
const url = `${baseUrl}/files/${file_key}/comments`;
|
|
17
|
+
|
|
18
|
+
// Prepare the request body
|
|
19
|
+
const body = JSON.stringify({
|
|
20
|
+
message: message,
|
|
21
|
+
client_meta: {
|
|
22
|
+
x: 0,
|
|
23
|
+
y: 0,
|
|
24
|
+
node_id: node_id
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Set up headers for the request
|
|
29
|
+
const headers = {
|
|
30
|
+
'X-Figma-Token': token,
|
|
31
|
+
'Content-Type': 'application/json'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Perform the fetch request
|
|
35
|
+
const response = await fetch(url, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: headers,
|
|
38
|
+
body: body
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Check if the response was successful
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const errorData = await response.json();
|
|
44
|
+
throw new Error(errorData);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Parse and return the response data
|
|
48
|
+
const data = await response.json();
|
|
49
|
+
return data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Error posting comment:', error);
|
|
52
|
+
return { error: 'An error occurred while posting the comment.' };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Tool configuration for posting a new comment on a Figma file.
|
|
58
|
+
* @type {Object}
|
|
59
|
+
*/
|
|
60
|
+
const apiTool = {
|
|
61
|
+
function: executeFunction,
|
|
62
|
+
definition: {
|
|
63
|
+
type: 'function',
|
|
64
|
+
function: {
|
|
65
|
+
name: 'post_new_comment',
|
|
66
|
+
description: 'Post a new comment on a Figma file.',
|
|
67
|
+
parameters: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
properties: {
|
|
70
|
+
file_key: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
description: 'The unique identifier of the file to which the comment should be added.'
|
|
73
|
+
},
|
|
74
|
+
node_id: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
description: 'The node ID where the comment is to be placed.'
|
|
77
|
+
},
|
|
78
|
+
message: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'The message content of the comment.'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
required: ['file_key', 'node_id', 'message']
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { apiTool };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to post a new development resource to Figma.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} args - Arguments for the new development resource.
|
|
5
|
+
* @param {string} args.name - The name of the resource.
|
|
6
|
+
* @param {string} args.url - The URL of the resource.
|
|
7
|
+
* @param {string} args.file_key - The file key of the resource.
|
|
8
|
+
* @param {string} args.node_id - The node ID of the resource.
|
|
9
|
+
* @returns {Promise<Object>} - The result of the resource creation.
|
|
10
|
+
*/
|
|
11
|
+
const executeFunction = async ({ name, url, file_key, node_id }) => {
|
|
12
|
+
const baseUrl = 'https://api.figma.com/v1';
|
|
13
|
+
const token = process.env.FIGMA_API_KEY;
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
// Construct the request body
|
|
17
|
+
const body = JSON.stringify({
|
|
18
|
+
dev_resources: [
|
|
19
|
+
{
|
|
20
|
+
name,
|
|
21
|
+
url,
|
|
22
|
+
file_key,
|
|
23
|
+
node_id
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Set up headers for the request
|
|
29
|
+
const headers = {
|
|
30
|
+
'X-Figma-Token': token,
|
|
31
|
+
'Content-Type': 'application/json'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Perform the fetch request
|
|
35
|
+
const response = await fetch(`${baseUrl}/dev_resources`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers,
|
|
38
|
+
body
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Check if the response was successful
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const errorData = await response.json();
|
|
44
|
+
throw new Error(errorData);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Parse and return the response data
|
|
48
|
+
const data = await response.json();
|
|
49
|
+
return data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Error posting development resource:', error);
|
|
52
|
+
return { error: 'An error occurred while posting the development resource.' };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Tool configuration for posting a new development resource to Figma.
|
|
58
|
+
* @type {Object}
|
|
59
|
+
*/
|
|
60
|
+
const apiTool = {
|
|
61
|
+
function: executeFunction,
|
|
62
|
+
definition: {
|
|
63
|
+
type: 'function',
|
|
64
|
+
function: {
|
|
65
|
+
name: 'post_dev_resource',
|
|
66
|
+
description: 'Post a new development resource to Figma.',
|
|
67
|
+
parameters: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
properties: {
|
|
70
|
+
name: {
|
|
71
|
+
type: 'string',
|
|
72
|
+
description: 'The name of the resource.'
|
|
73
|
+
},
|
|
74
|
+
url: {
|
|
75
|
+
type: 'string',
|
|
76
|
+
description: 'The URL of the resource.'
|
|
77
|
+
},
|
|
78
|
+
file_key: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'The file key of the resource.'
|
|
81
|
+
},
|
|
82
|
+
node_id: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'The node ID of the resource.'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
required: ['name', 'url', 'file_key', 'node_id']
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { apiTool };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to reply to a comment on a Figma file.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} args - Arguments for the reply.
|
|
5
|
+
* @param {string} args.message - The message for the new comment.
|
|
6
|
+
* @param {string} args.comment_id - The identifier of the comment to which the reply is being made.
|
|
7
|
+
* @param {string} args.file_key - The key of the Figma file.
|
|
8
|
+
* @returns {Promise<Object>} - The result of the reply operation.
|
|
9
|
+
*/
|
|
10
|
+
const executeFunction = async ({ message, comment_id, file_key }) => {
|
|
11
|
+
const baseUrl = 'https://api.figma.com/v1';
|
|
12
|
+
const token = process.env.FIGMA_API_KEY;
|
|
13
|
+
try {
|
|
14
|
+
// Construct the URL for the API request
|
|
15
|
+
const url = `${baseUrl}/files/${file_key}/comments`;
|
|
16
|
+
|
|
17
|
+
// Set up headers for the request
|
|
18
|
+
const headers = {
|
|
19
|
+
'X-Figma-Token': token,
|
|
20
|
+
'Content-Type': 'application/json'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Prepare the body of the request
|
|
24
|
+
const body = JSON.stringify({
|
|
25
|
+
message,
|
|
26
|
+
comment_id
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Perform the fetch request
|
|
30
|
+
const response = await fetch(url, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers,
|
|
33
|
+
body
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Check if the response was successful
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
const errorData = await response.json();
|
|
39
|
+
throw new Error(errorData);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Parse and return the response data
|
|
43
|
+
const data = await response.json();
|
|
44
|
+
return data;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('Error replying to comment:', error);
|
|
47
|
+
return { error: 'An error occurred while replying to the comment.' };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Tool configuration for replying to comments on Figma.
|
|
53
|
+
* @type {Object}
|
|
54
|
+
*/
|
|
55
|
+
const apiTool = {
|
|
56
|
+
function: executeFunction,
|
|
57
|
+
definition: {
|
|
58
|
+
type: 'function',
|
|
59
|
+
function: {
|
|
60
|
+
name: 'reply_to_comment',
|
|
61
|
+
description: 'Reply to a comment on a Figma file.',
|
|
62
|
+
parameters: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
message: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'The message for the new comment.'
|
|
68
|
+
},
|
|
69
|
+
comment_id: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'The identifier of the comment to which the reply is being made.'
|
|
72
|
+
},
|
|
73
|
+
file_key: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'The key of the Figma file.'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
required: ['message', 'comment_id', 'file_key']
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export { apiTool };
|
package/tools/paths.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const toolPaths = [
|
|
2
|
+
'figma/figma-api/get-all-webhooks-for-team.js',
|
|
3
|
+
'figma/figma-api/add-webhook.js',
|
|
4
|
+
'figma/figma-api/delete-webhook.js',
|
|
5
|
+
'figma/figma-api/get-library-analytics.js',
|
|
6
|
+
'figma/figma-api/get-dev-resources.js',
|
|
7
|
+
'figma/figma-api/get-design.js',
|
|
8
|
+
'figma/figma-api/get-actions-analytics.js',
|
|
9
|
+
'figma/figma-api/get-image-node.js',
|
|
10
|
+
'figma/figma-api/get-team-projects.js',
|
|
11
|
+
'figma/figma-api/get-project-files.js',
|
|
12
|
+
'figma/figma-api/get-file-comments.js',
|
|
13
|
+
'figma/figma-api/post-dev-resource.js',
|
|
14
|
+
'figma/figma-api/get-images.js',
|
|
15
|
+
'figma/figma-api/create-variable-collection.js',
|
|
16
|
+
'figma/figma-api/get-design-node.js',
|
|
17
|
+
'figma/figma-api/post-a-new-comment.js',
|
|
18
|
+
'figma/figma-api/reply-to-comment.js'
|
|
19
|
+
];
|