figma-mcp-server 0.1.0 → 0.1.2

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.
Files changed (34) hide show
  1. package/.env.example +1 -0
  2. package/Dockerfile +21 -2
  3. package/README.md +40 -40
  4. package/mcpServer.js +59 -35
  5. package/package.json +5 -4
  6. package/smithery.yaml +39 -0
  7. package/tools/figma/figma-api/create-dev-resources-for-a-file.js +95 -0
  8. package/tools/figma/figma-api/{create-variable-collection.js → create-variable-collections-for-a-file.js} +12 -13
  9. package/tools/figma/figma-api/get-a-published-component-by-key.js +66 -0
  10. package/tools/figma/figma-api/get-a-published-component-set-by-key.js +66 -0
  11. package/tools/figma/figma-api/get-a-published-library-by-id.js +66 -0
  12. package/tools/figma/figma-api/get-a-published-style-by-key.js +66 -0
  13. package/tools/figma/figma-api/{get-all-webhooks-for-team.js → get-current-user.js} +10 -10
  14. package/tools/figma/figma-api/{get-design-node.js → get-file-nodes.js} +17 -15
  15. package/tools/figma/figma-api/get-file-version-history.js +66 -0
  16. package/tools/figma/figma-api/{get-design.js → get-file.js} +8 -8
  17. package/tools/figma/figma-api/{get-image-node.js → get-image-fills.js} +17 -17
  18. package/tools/figma/figma-api/{get-library-analytics.js → get-library-action-analytics.js} +12 -12
  19. package/tools/figma/figma-api/{get-actions-analytics.js → get-library-usage-analytics.js} +12 -13
  20. package/tools/figma/figma-api/list-comments-on-a-file.js +66 -0
  21. package/tools/figma/figma-api/{get-dev-resources.js → list-component-sets-in-a-file.js} +11 -11
  22. package/tools/figma/figma-api/list-components-in-a-file.js +66 -0
  23. package/tools/figma/figma-api/list-dev-resources-for-a-file.js +66 -0
  24. package/tools/figma/figma-api/{get-project-files.js → list-files-in-a-project.js} +12 -11
  25. package/tools/figma/figma-api/{get-team-projects.js → list-projects-in-a-team.js} +11 -11
  26. package/tools/figma/figma-api/{add-webhook.js → list-published-libraries.js} +11 -12
  27. package/tools/figma/figma-api/{get-file-comments.js → list-styles-in-a-file.js} +11 -11
  28. package/tools/figma/figma-api/{get-images.js → list-variables-for-a-file.js} +13 -13
  29. package/tools/figma/figma-api/post-a-comment-to-a-file.js +102 -0
  30. package/tools/paths.js +23 -17
  31. package/tools/figma/figma-api/delete-webhook.js +0 -64
  32. package/tools/figma/figma-api/post-a-new-comment.js +0 -89
  33. package/tools/figma/figma-api/post-dev-resource.js +0 -93
  34. package/tools/figma/figma-api/reply-to-comment.js +0 -84
package/tools/paths.js CHANGED
@@ -1,19 +1,25 @@
1
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'
2
+ 'figma/figma-api/list-published-libraries.js',
3
+ 'figma/figma-api/get-a-published-component-by-key.js',
4
+ 'figma/figma-api/get-file.js',
5
+ 'figma/figma-api/list-component-sets-in-a-file.js',
6
+ 'figma/figma-api/list-dev-resources-for-a-file.js',
7
+ 'figma/figma-api/get-a-published-library-by-id.js',
8
+ 'figma/figma-api/list-components-in-a-file.js',
9
+ 'figma/figma-api/get-library-usage-analytics.js',
10
+ 'figma/figma-api/list-comments-on-a-file.js',
11
+ 'figma/figma-api/get-image-fills.js',
12
+ 'figma/figma-api/list-variables-for-a-file.js',
13
+ 'figma/figma-api/get-file-version-history.js',
14
+ 'figma/figma-api/list-files-in-a-project.js',
15
+ 'figma/figma-api/get-library-action-analytics.js',
16
+ 'figma/figma-api/create-variable-collections-for-a-file.js',
17
+ 'figma/figma-api/get-file-nodes.js',
18
+ 'figma/figma-api/get-a-published-style-by-key.js',
19
+ 'figma/figma-api/get-current-user.js',
20
+ 'figma/figma-api/create-dev-resources-for-a-file.js',
21
+ 'figma/figma-api/list-styles-in-a-file.js',
22
+ 'figma/figma-api/list-projects-in-a-team.js',
23
+ 'figma/figma-api/get-a-published-component-set-by-key.js',
24
+ 'figma/figma-api/post-a-comment-to-a-file.js'
19
25
  ];
@@ -1,64 +0,0 @@
1
- /**
2
- * Function to delete a specific webhook from Figma.
3
- *
4
- * @param {Object} args - Arguments for the deletion.
5
- * @param {string} args.webhook_id - The ID of the webhook to delete.
6
- * @returns {Promise<Object>} - The result of the deletion operation.
7
- */
8
- const executeFunction = async ({ webhook_id }) => {
9
- const baseUrl = 'https://api.figma.com/v1';
10
- const token = process.env.FIGMA_API_KEY;
11
- const webhookUrl = `${baseUrl}/webhooks/${webhook_id}`;
12
-
13
- try {
14
- // Set up headers for the request
15
- const headers = {
16
- 'X-Figma-Token': token
17
- };
18
-
19
- // Perform the fetch request
20
- const response = await fetch(webhookUrl, {
21
- method: 'DELETE',
22
- headers
23
- });
24
-
25
- // Check if the response was successful
26
- if (!response.ok) {
27
- const errorData = await response.json();
28
- throw new Error(errorData);
29
- }
30
-
31
- // Return the response data (should be empty for successful deletion)
32
- return {};
33
- } catch (error) {
34
- console.error('Error deleting webhook:', error);
35
- return { error: 'An error occurred while deleting the webhook.' };
36
- }
37
- };
38
-
39
- /**
40
- * Tool configuration for deleting a webhook from Figma.
41
- * @type {Object}
42
- */
43
- const apiTool = {
44
- function: executeFunction,
45
- definition: {
46
- type: 'function',
47
- function: {
48
- name: 'delete_webhook',
49
- description: 'Delete a specific webhook from Figma.',
50
- parameters: {
51
- type: 'object',
52
- properties: {
53
- webhook_id: {
54
- type: 'string',
55
- description: 'The ID of the webhook to delete.'
56
- }
57
- },
58
- required: ['webhook_id']
59
- }
60
- }
61
- }
62
- };
63
-
64
- export { apiTool };
@@ -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 };