figma-mcp-server 0.1.1 → 2.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.
Files changed (32) hide show
  1. package/.env.example +1 -0
  2. package/LICENSE +1 -0
  3. package/README.md +29 -38
  4. package/bun.lock +195 -0
  5. package/index.js +1 -2
  6. package/lib/tools.js +1 -5
  7. package/mcpServer.js +19 -12
  8. package/package.json +3 -2
  9. package/tools/figma/figma-api/create-dev-resources-for-a-file.js +0 -20
  10. package/tools/figma/figma-api/create-variable-collections-for-a-file.js +0 -18
  11. package/tools/figma/figma-api/get-a-published-component-by-key.js +0 -16
  12. package/tools/figma/figma-api/get-a-published-component-set-by-key.js +0 -16
  13. package/tools/figma/figma-api/get-a-published-library-by-id.js +0 -16
  14. package/tools/figma/figma-api/get-a-published-style-by-key.js +0 -16
  15. package/tools/figma/figma-api/get-current-user.js +0 -13
  16. package/tools/figma/figma-api/get-file-nodes.js +0 -17
  17. package/tools/figma/figma-api/get-file-version-history.js +0 -16
  18. package/tools/figma/figma-api/get-file.js +0 -16
  19. package/tools/figma/figma-api/get-image-fills.js +0 -17
  20. package/tools/figma/figma-api/get-library-action-analytics.js +0 -16
  21. package/tools/figma/figma-api/get-library-usage-analytics.js +0 -16
  22. package/tools/figma/figma-api/list-comments-on-a-file.js +0 -16
  23. package/tools/figma/figma-api/list-component-sets-in-a-file.js +0 -16
  24. package/tools/figma/figma-api/list-components-in-a-file.js +0 -16
  25. package/tools/figma/figma-api/list-dev-resources-for-a-file.js +0 -16
  26. package/tools/figma/figma-api/list-files-in-a-project.js +0 -16
  27. package/tools/figma/figma-api/list-projects-in-a-team.js +0 -16
  28. package/tools/figma/figma-api/list-published-libraries.js +0 -13
  29. package/tools/figma/figma-api/list-styles-in-a-file.js +0 -16
  30. package/tools/figma/figma-api/list-variables-for-a-file.js +0 -16
  31. package/tools/figma/figma-api/post-a-comment-to-a-file.js +1 -23
  32. package/Dockerfile +0 -9
@@ -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,9 +0,0 @@
1
- FROM node:22.12-alpine AS builder
2
-
3
- WORKDIR /app
4
- COPY package.json package-lock.json ./
5
- RUN npm install
6
-
7
- COPY . .
8
-
9
- ENTRYPOINT ["node", "mcpServer.js"]