figma-mcp-server 0.1.0-beta.1 → 0.1.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/README.md +51 -44
- package/mcpServer.js +51 -33
- package/package.json +3 -3
- package/tools/figma/figma-api/create-dev-resources-for-a-file.js +95 -0
- package/tools/figma/figma-api/{create-variable-collection.js → create-variable-collections-for-a-file.js} +12 -13
- package/tools/figma/figma-api/get-a-published-component-by-key.js +66 -0
- package/tools/figma/figma-api/get-a-published-component-set-by-key.js +66 -0
- package/tools/figma/figma-api/get-a-published-library-by-id.js +66 -0
- package/tools/figma/figma-api/get-a-published-style-by-key.js +66 -0
- package/tools/figma/figma-api/{get-all-webhooks-for-team.js → get-current-user.js} +10 -10
- package/tools/figma/figma-api/{get-design-node.js → get-file-nodes.js} +17 -15
- package/tools/figma/figma-api/get-file-version-history.js +66 -0
- package/tools/figma/figma-api/{get-design.js → get-file.js} +8 -8
- package/tools/figma/figma-api/{get-image-node.js → get-image-fills.js} +17 -17
- package/tools/figma/figma-api/{get-library-analytics.js → get-library-action-analytics.js} +12 -12
- package/tools/figma/figma-api/{get-actions-analytics.js → get-library-usage-analytics.js} +12 -13
- package/tools/figma/figma-api/list-comments-on-a-file.js +66 -0
- package/tools/figma/figma-api/{get-dev-resources.js → list-component-sets-in-a-file.js} +11 -11
- package/tools/figma/figma-api/list-components-in-a-file.js +66 -0
- package/tools/figma/figma-api/list-dev-resources-for-a-file.js +66 -0
- package/tools/figma/figma-api/{get-project-files.js → list-files-in-a-project.js} +12 -11
- package/tools/figma/figma-api/{get-team-projects.js → list-projects-in-a-team.js} +11 -11
- package/tools/figma/figma-api/{add-webhook.js → list-published-libraries.js} +11 -12
- package/tools/figma/figma-api/{get-file-comments.js → list-styles-in-a-file.js} +11 -11
- package/tools/figma/figma-api/{get-images.js → list-variables-for-a-file.js} +13 -13
- package/tools/figma/figma-api/post-a-comment-to-a-file.js +102 -0
- package/tools/paths.js +23 -17
- package/tools/figma/figma-api/delete-webhook.js +0 -64
- package/tools/figma/figma-api/post-a-new-comment.js +0 -89
- package/tools/figma/figma-api/post-dev-resource.js +0 -93
- package/tools/figma/figma-api/reply-to-comment.js +0 -84
|
@@ -1,89 +0,0 @@
|
|
|
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 };
|
|
@@ -1,93 +0,0 @@
|
|
|
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 };
|
|
@@ -1,84 +0,0 @@
|
|
|
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 };
|