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.
- package/.env.example +1 -0
- package/LICENSE +1 -0
- package/README.md +29 -38
- package/bun.lock +195 -0
- package/index.js +1 -2
- package/lib/tools.js +1 -5
- package/mcpServer.js +19 -12
- package/package.json +3 -2
- 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 -9
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get metadata for a published component set by its key from Figma.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.key - The key of the component set to retrieve.
|
|
6
|
-
* @returns {Promise<Object>} - The metadata for the component set.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ 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 with the component set key
|
|
13
5
|
const url = `${baseUrl}/v1/component_sets/${key}`;
|
|
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 ({ key }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for retrieving component set metadata from Figma.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get metadata for a published library in Figma by its ID.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the library retrieval.
|
|
5
|
-
* @param {string} args.library_id - The ID of the library to retrieve.
|
|
6
|
-
* @returns {Promise<Object>} - The metadata of the published library.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ library_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 with the library ID
|
|
13
5
|
const url = `${baseUrl}/v1/libraries/${library_id}`;
|
|
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 ({ library_id }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for retrieving library metadata in Figma.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get a published style from Figma by its key.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.key - The key of the published style to retrieve.
|
|
6
|
-
* @returns {Promise<Object>} - The metadata for the published style.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ 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 with the style key
|
|
13
5
|
const url = `${baseUrl}/v1/styles/${key}`;
|
|
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 ({ key }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for getting a published style from Figma.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get the current user information from Figma.
|
|
3
|
-
*
|
|
4
|
-
* @returns {Promise<Object>} - The information about the user associated with the access token.
|
|
5
|
-
*/
|
|
6
1
|
const executeFunction = async () => {
|
|
7
2
|
const baseUrl = 'https://api.figma.com';
|
|
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}/v1/me`, {
|
|
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 getting the current user information from Figma.
|
|
38
|
-
* @type {Object}
|
|
39
|
-
*/
|
|
40
27
|
const apiTool = {
|
|
41
28
|
function: executeFunction,
|
|
42
29
|
definition: {
|
|
@@ -1,39 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get specific nodes from a Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file.
|
|
6
|
-
* @param {string} [args.node_id] - The ID of the node to retrieve. If not provided, all nodes will be returned.
|
|
7
|
-
* @returns {Promise<Object>} - The result of the node retrieval.
|
|
8
|
-
*/
|
|
9
1
|
const executeFunction = async ({ file_key, node_id }) => {
|
|
10
2
|
const baseUrl = 'https://api.figma.com';
|
|
11
3
|
const token = process.env.FIGMA_API_KEY;
|
|
12
4
|
try {
|
|
13
|
-
// Construct the URL
|
|
14
5
|
const url = new URL(`${baseUrl}/v1/files/${file_key}/nodes`);
|
|
15
6
|
if (node_id) {
|
|
16
7
|
url.searchParams.append('ids', node_id);
|
|
17
8
|
}
|
|
18
9
|
|
|
19
|
-
// Set up headers for the request
|
|
20
10
|
const headers = {
|
|
21
11
|
'X-Figma-Token': token
|
|
22
12
|
};
|
|
23
13
|
|
|
24
|
-
// Perform the fetch request
|
|
25
14
|
const response = await fetch(url.toString(), {
|
|
26
15
|
method: 'GET',
|
|
27
16
|
headers
|
|
28
17
|
});
|
|
29
18
|
|
|
30
|
-
// Check if the response was successful
|
|
31
19
|
if (!response.ok) {
|
|
32
20
|
const errorData = await response.json();
|
|
33
21
|
throw new Error(errorData);
|
|
34
22
|
}
|
|
35
23
|
|
|
36
|
-
// Parse and return the response data
|
|
37
24
|
const data = await response.json();
|
|
38
25
|
return data;
|
|
39
26
|
} catch (error) {
|
|
@@ -42,10 +29,6 @@ const executeFunction = async ({ file_key, node_id }) => {
|
|
|
42
29
|
}
|
|
43
30
|
};
|
|
44
31
|
|
|
45
|
-
/**
|
|
46
|
-
* Tool configuration for getting nodes from a Figma file.
|
|
47
|
-
* @type {Object}
|
|
48
|
-
*/
|
|
49
32
|
const apiTool = {
|
|
50
33
|
function: executeFunction,
|
|
51
34
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get the version history of a 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 retrieve version history.
|
|
6
|
-
* @returns {Promise<Object>} - The version history of 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}/versions`;
|
|
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 retrieving the version history of a Figma file.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get the full document tree of a Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the file retrieval.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file to retrieve.
|
|
6
|
-
* @returns {Promise<Object>} - The result of the file retrieval.
|
|
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}`;
|
|
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 retrieving a Figma file.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,39 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get image fills from a Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the image fills request.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file.
|
|
6
|
-
* @param {string} [args.node_id] - The ID of the specific node to retrieve images for (optional).
|
|
7
|
-
* @returns {Promise<Object>} - The URLs for rendered images of specific nodes.
|
|
8
|
-
*/
|
|
9
1
|
const executeFunction = async ({ file_key, node_id }) => {
|
|
10
2
|
const baseUrl = 'https://api.figma.com';
|
|
11
3
|
const token = process.env.FIGMA_API_KEY;
|
|
12
4
|
try {
|
|
13
|
-
// Construct the URL with the file key and optional node ID
|
|
14
5
|
const url = new URL(`${baseUrl}/v1/images/${file_key}`);
|
|
15
6
|
if (node_id) {
|
|
16
7
|
url.searchParams.append('ids', node_id);
|
|
17
8
|
}
|
|
18
9
|
|
|
19
|
-
// Set up headers for the request
|
|
20
10
|
const headers = {
|
|
21
11
|
'X-Figma-Token': token
|
|
22
12
|
};
|
|
23
13
|
|
|
24
|
-
// Perform the fetch request
|
|
25
14
|
const response = await fetch(url.toString(), {
|
|
26
15
|
method: 'GET',
|
|
27
16
|
headers
|
|
28
17
|
});
|
|
29
18
|
|
|
30
|
-
// Check if the response was successful
|
|
31
19
|
if (!response.ok) {
|
|
32
20
|
const errorData = await response.json();
|
|
33
21
|
throw new Error(errorData);
|
|
34
22
|
}
|
|
35
23
|
|
|
36
|
-
// Parse and return the response data
|
|
37
24
|
const data = await response.json();
|
|
38
25
|
return data;
|
|
39
26
|
} catch (error) {
|
|
@@ -42,10 +29,6 @@ const executeFunction = async ({ file_key, node_id }) => {
|
|
|
42
29
|
}
|
|
43
30
|
};
|
|
44
31
|
|
|
45
|
-
/**
|
|
46
|
-
* Tool configuration for getting image fills from a Figma file.
|
|
47
|
-
* @type {Object}
|
|
48
|
-
*/
|
|
49
32
|
const apiTool = {
|
|
50
33
|
function: executeFunction,
|
|
51
34
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get library action analytics from Figma.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the analytics request.
|
|
5
|
-
* @param {string} args.library_file_key - The key of the library file for which to retrieve action analytics.
|
|
6
|
-
* @returns {Promise<Object>} - The result of the library action analytics request.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ library_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/analytics/libraries/${library_file_key}/actions`;
|
|
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 ({ library_file_key }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for getting library action analytics from Figma.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to get library usage analytics from Figma.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the analytics request.
|
|
5
|
-
* @param {string} args.library_file_key - The key of the library file for which to retrieve usage analytics.
|
|
6
|
-
* @returns {Promise<Object>} - The result of the library usage analytics request.
|
|
7
|
-
*/
|
|
8
1
|
const executeFunction = async ({ library_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/analytics/libraries/${library_file_key}/usages`;
|
|
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 ({ library_file_key }) => {
|
|
|
38
26
|
}
|
|
39
27
|
};
|
|
40
28
|
|
|
41
|
-
/**
|
|
42
|
-
* Tool configuration for getting library usage analytics from Figma.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Function to list comments on a Figma file.
|
|
3
|
-
*
|
|
4
|
-
* @param {Object} args - Arguments for the comment listing.
|
|
5
|
-
* @param {string} args.file_key - The key of the Figma file to list comments from.
|
|
6
|
-
* @returns {Promise<Array>} - A promise that resolves to an array of comments.
|
|
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 API request
|
|
13
5
|
const url = `${baseUrl}/v1/files/${file_key}/comments`;
|
|
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.comments || [];
|
|
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 comments on 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 component sets 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 component sets from.
|
|
6
|
-
* @returns {Promise<Object>} - The response containing the list of component sets.
|
|
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}/component_sets`;
|
|
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 component sets 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 components 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 components from.
|
|
6
|
-
* @returns {Promise<Object>} - The list of components 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}/components`;
|
|
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 components in a Figma file.
|
|
43
|
-
* @type {Object}
|
|
44
|
-
*/
|
|
45
29
|
const apiTool = {
|
|
46
30
|
function: executeFunction,
|
|
47
31
|
definition: {
|
|
@@ -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: {
|