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.
- package/.env.example +1 -0
- package/Dockerfile +21 -2
- package/README.md +40 -40
- package/mcpServer.js +59 -35
- package/package.json +5 -4
- package/smithery.yaml +39 -0
- 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
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
const executeFunction = async ({ key }) => {
|
|
9
|
+
const baseUrl = 'https://api.figma.com';
|
|
10
|
+
const token = process.env.FIGMA_API_KEY;
|
|
11
|
+
try {
|
|
12
|
+
// Construct the URL with the component set key
|
|
13
|
+
const url = `${baseUrl}/v1/component_sets/${key}`;
|
|
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 component set metadata:', error);
|
|
37
|
+
return { error: 'An error occurred while retrieving component set metadata.' };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Tool configuration for retrieving component set metadata from Figma.
|
|
43
|
+
* @type {Object}
|
|
44
|
+
*/
|
|
45
|
+
const apiTool = {
|
|
46
|
+
function: executeFunction,
|
|
47
|
+
definition: {
|
|
48
|
+
type: 'function',
|
|
49
|
+
function: {
|
|
50
|
+
name: 'get_component_set',
|
|
51
|
+
description: 'Retrieve metadata for a published component set by its key.',
|
|
52
|
+
parameters: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
key: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'The key of the component set to retrieve.'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
required: ['key']
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { apiTool };
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
const executeFunction = async ({ library_id }) => {
|
|
9
|
+
const baseUrl = 'https://api.figma.com';
|
|
10
|
+
const token = process.env.FIGMA_API_KEY;
|
|
11
|
+
try {
|
|
12
|
+
// Construct the URL with the library ID
|
|
13
|
+
const url = `${baseUrl}/v1/libraries/${library_id}`;
|
|
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 library metadata:', error);
|
|
37
|
+
return { error: 'An error occurred while retrieving library metadata.' };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Tool configuration for retrieving library metadata in Figma.
|
|
43
|
+
* @type {Object}
|
|
44
|
+
*/
|
|
45
|
+
const apiTool = {
|
|
46
|
+
function: executeFunction,
|
|
47
|
+
definition: {
|
|
48
|
+
type: 'function',
|
|
49
|
+
function: {
|
|
50
|
+
name: 'get_library_by_id',
|
|
51
|
+
description: 'Retrieve metadata for a published library by its ID.',
|
|
52
|
+
parameters: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
library_id: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'The ID of the library to retrieve.'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
required: ['library_id']
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { apiTool };
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
const executeFunction = async ({ key }) => {
|
|
9
|
+
const baseUrl = 'https://api.figma.com';
|
|
10
|
+
const token = process.env.FIGMA_API_KEY;
|
|
11
|
+
try {
|
|
12
|
+
// Construct the URL with the style key
|
|
13
|
+
const url = `${baseUrl}/v1/styles/${key}`;
|
|
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 published style:', error);
|
|
37
|
+
return { error: 'An error occurred while retrieving the published style.' };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Tool configuration for getting a published style from Figma.
|
|
43
|
+
* @type {Object}
|
|
44
|
+
*/
|
|
45
|
+
const apiTool = {
|
|
46
|
+
function: executeFunction,
|
|
47
|
+
definition: {
|
|
48
|
+
type: 'function',
|
|
49
|
+
function: {
|
|
50
|
+
name: 'get_published_style',
|
|
51
|
+
description: 'Retrieve metadata for a published style by its key.',
|
|
52
|
+
parameters: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
key: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'The key of the published style to retrieve.'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
required: ['key']
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { apiTool };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Function to get
|
|
2
|
+
* Function to get the current user information from Figma.
|
|
3
3
|
*
|
|
4
|
-
* @returns {Promise<Object>} - The
|
|
4
|
+
* @returns {Promise<Object>} - The information about the user associated with the access token.
|
|
5
5
|
*/
|
|
6
6
|
const executeFunction = async () => {
|
|
7
|
-
const
|
|
7
|
+
const baseUrl = 'https://api.figma.com';
|
|
8
8
|
const token = process.env.FIGMA_API_KEY;
|
|
9
9
|
try {
|
|
10
10
|
// Set up headers for the request
|
|
@@ -13,14 +13,14 @@ const executeFunction = async () => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
// Perform the fetch request
|
|
16
|
-
const response = await fetch(
|
|
16
|
+
const response = await fetch(`${baseUrl}/v1/me`, {
|
|
17
17
|
method: 'GET',
|
|
18
18
|
headers
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
// Check if the response was successful
|
|
22
22
|
if (!response.ok) {
|
|
23
|
-
const errorData = await response.
|
|
23
|
+
const errorData = await response.json();
|
|
24
24
|
throw new Error(errorData);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -28,13 +28,13 @@ const executeFunction = async () => {
|
|
|
28
28
|
const data = await response.json();
|
|
29
29
|
return data;
|
|
30
30
|
} catch (error) {
|
|
31
|
-
console.error('Error
|
|
32
|
-
return { error: 'An error occurred while
|
|
31
|
+
console.error('Error getting current user information:', error);
|
|
32
|
+
return { error: 'An error occurred while getting user information.' };
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Tool configuration for getting
|
|
37
|
+
* Tool configuration for getting the current user information from Figma.
|
|
38
38
|
* @type {Object}
|
|
39
39
|
*/
|
|
40
40
|
const apiTool = {
|
|
@@ -42,8 +42,8 @@ const apiTool = {
|
|
|
42
42
|
definition: {
|
|
43
43
|
type: 'function',
|
|
44
44
|
function: {
|
|
45
|
-
name: '
|
|
46
|
-
description: '
|
|
45
|
+
name: 'get_current_user',
|
|
46
|
+
description: 'Get the current user information from Figma.',
|
|
47
47
|
parameters: {
|
|
48
48
|
type: 'object',
|
|
49
49
|
properties: {},
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Function to
|
|
2
|
+
* Function to get specific nodes from a Figma file.
|
|
3
3
|
*
|
|
4
|
-
* @param {Object} args - Arguments for the
|
|
4
|
+
* @param {Object} args - Arguments for the request.
|
|
5
5
|
* @param {string} args.file_key - The key of the Figma file.
|
|
6
|
-
* @param {string} args.node_id - The
|
|
6
|
+
* @param {string} [args.node_id] - The ID of the node to retrieve. If not provided, all nodes will be returned.
|
|
7
7
|
* @returns {Promise<Object>} - The result of the node retrieval.
|
|
8
8
|
*/
|
|
9
9
|
const executeFunction = async ({ file_key, node_id }) => {
|
|
10
|
-
const baseUrl = 'https://api.figma.com
|
|
10
|
+
const baseUrl = 'https://api.figma.com';
|
|
11
11
|
const token = process.env.FIGMA_API_KEY;
|
|
12
|
-
|
|
13
12
|
try {
|
|
14
|
-
// Construct the URL
|
|
15
|
-
const url = `${baseUrl}/files/${file_key}/nodes
|
|
13
|
+
// Construct the URL
|
|
14
|
+
const url = new URL(`${baseUrl}/v1/files/${file_key}/nodes`);
|
|
15
|
+
if (node_id) {
|
|
16
|
+
url.searchParams.append('ids', node_id);
|
|
17
|
+
}
|
|
16
18
|
|
|
17
19
|
// Set up headers for the request
|
|
18
20
|
const headers = {
|
|
@@ -20,7 +22,7 @@ const executeFunction = async ({ file_key, node_id }) => {
|
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
// Perform the fetch request
|
|
23
|
-
const response = await fetch(url, {
|
|
25
|
+
const response = await fetch(url.toString(), {
|
|
24
26
|
method: 'GET',
|
|
25
27
|
headers
|
|
26
28
|
});
|
|
@@ -35,13 +37,13 @@ const executeFunction = async ({ file_key, node_id }) => {
|
|
|
35
37
|
const data = await response.json();
|
|
36
38
|
return data;
|
|
37
39
|
} catch (error) {
|
|
38
|
-
console.error('Error
|
|
39
|
-
return { error: 'An error occurred while retrieving
|
|
40
|
+
console.error('Error getting file nodes:', error);
|
|
41
|
+
return { error: 'An error occurred while retrieving file nodes.' };
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
/**
|
|
44
|
-
* Tool configuration for
|
|
46
|
+
* Tool configuration for getting nodes from a Figma file.
|
|
45
47
|
* @type {Object}
|
|
46
48
|
*/
|
|
47
49
|
const apiTool = {
|
|
@@ -49,8 +51,8 @@ const apiTool = {
|
|
|
49
51
|
definition: {
|
|
50
52
|
type: 'function',
|
|
51
53
|
function: {
|
|
52
|
-
name: '
|
|
53
|
-
description: 'Retrieve
|
|
54
|
+
name: 'get_file_nodes',
|
|
55
|
+
description: 'Retrieve specific nodes from a Figma file.',
|
|
54
56
|
parameters: {
|
|
55
57
|
type: 'object',
|
|
56
58
|
properties: {
|
|
@@ -60,10 +62,10 @@ const apiTool = {
|
|
|
60
62
|
},
|
|
61
63
|
node_id: {
|
|
62
64
|
type: 'string',
|
|
63
|
-
description: 'The
|
|
65
|
+
description: 'The ID of the node to retrieve.'
|
|
64
66
|
}
|
|
65
67
|
},
|
|
66
|
-
required: ['file_key'
|
|
68
|
+
required: ['file_key']
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
const executeFunction = async ({ file_key }) => {
|
|
9
|
+
const baseUrl = 'https://api.figma.com';
|
|
10
|
+
const token = process.env.FIGMA_API_KEY;
|
|
11
|
+
try {
|
|
12
|
+
// Construct the URL for the request
|
|
13
|
+
const url = `${baseUrl}/v1/files/${file_key}/versions`;
|
|
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 file version history:', error);
|
|
37
|
+
return { error: 'An error occurred while retrieving the file version history.' };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Tool configuration for retrieving the version history of a Figma file.
|
|
43
|
+
* @type {Object}
|
|
44
|
+
*/
|
|
45
|
+
const apiTool = {
|
|
46
|
+
function: executeFunction,
|
|
47
|
+
definition: {
|
|
48
|
+
type: 'function',
|
|
49
|
+
function: {
|
|
50
|
+
name: 'get_file_version_history',
|
|
51
|
+
description: 'Retrieve the version history of a specified Figma file.',
|
|
52
|
+
parameters: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
file_key: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
description: 'The key of the Figma file for which to retrieve version history.'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
required: ['file_key']
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { apiTool };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Function to
|
|
2
|
+
* Function to get the full document tree of a Figma file.
|
|
3
3
|
*
|
|
4
4
|
* @param {Object} args - Arguments for the file retrieval.
|
|
5
|
-
* @param {string} args.file_key - The
|
|
5
|
+
* @param {string} args.file_key - The key of the Figma file to retrieve.
|
|
6
6
|
* @returns {Promise<Object>} - The result of the file retrieval.
|
|
7
7
|
*/
|
|
8
8
|
const executeFunction = async ({ file_key }) => {
|
|
9
|
-
const baseUrl = 'https://api.figma.com
|
|
9
|
+
const baseUrl = 'https://api.figma.com';
|
|
10
10
|
const token = process.env.FIGMA_API_KEY;
|
|
11
11
|
try {
|
|
12
12
|
// Construct the URL for the request
|
|
13
|
-
const url = `${baseUrl}/files/${file_key}`;
|
|
13
|
+
const url = `${baseUrl}/v1/files/${file_key}`;
|
|
14
14
|
|
|
15
15
|
// Set up headers for the request
|
|
16
16
|
const headers = {
|
|
@@ -26,7 +26,7 @@ const executeFunction = async ({ file_key }) => {
|
|
|
26
26
|
// Check if the response was successful
|
|
27
27
|
if (!response.ok) {
|
|
28
28
|
const errorData = await response.json();
|
|
29
|
-
throw new Error(errorData
|
|
29
|
+
throw new Error(errorData);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// Parse and return the response data
|
|
@@ -47,14 +47,14 @@ const apiTool = {
|
|
|
47
47
|
definition: {
|
|
48
48
|
type: 'function',
|
|
49
49
|
function: {
|
|
50
|
-
name: '
|
|
51
|
-
description: 'Retrieve
|
|
50
|
+
name: 'get_figma_file',
|
|
51
|
+
description: 'Retrieve the full document tree of a Figma file.',
|
|
52
52
|
parameters: {
|
|
53
53
|
type: 'object',
|
|
54
54
|
properties: {
|
|
55
55
|
file_key: {
|
|
56
56
|
type: 'string',
|
|
57
|
-
description: 'The
|
|
57
|
+
description: 'The key of the Figma file to retrieve.'
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
required: ['file_key']
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Function to
|
|
2
|
+
* Function to get image fills from a Figma file.
|
|
3
3
|
*
|
|
4
|
-
* @param {Object} args - Arguments for the image
|
|
4
|
+
* @param {Object} args - Arguments for the image fills request.
|
|
5
5
|
* @param {string} args.file_key - The key of the Figma file.
|
|
6
|
-
* @param {string} [args.
|
|
7
|
-
* @returns {Promise<Object>} - The
|
|
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
8
|
*/
|
|
9
|
-
const executeFunction = async ({ file_key,
|
|
10
|
-
const baseUrl = 'https://api.figma.com
|
|
9
|
+
const executeFunction = async ({ file_key, node_id }) => {
|
|
10
|
+
const baseUrl = 'https://api.figma.com';
|
|
11
11
|
const token = process.env.FIGMA_API_KEY;
|
|
12
12
|
try {
|
|
13
|
-
// Construct the URL with the file key and optional
|
|
14
|
-
const url = new URL(`${baseUrl}/images/${file_key}`);
|
|
15
|
-
if (
|
|
16
|
-
url.searchParams.append('ids',
|
|
13
|
+
// Construct the URL with the file key and optional node ID
|
|
14
|
+
const url = new URL(`${baseUrl}/v1/images/${file_key}`);
|
|
15
|
+
if (node_id) {
|
|
16
|
+
url.searchParams.append('ids', node_id);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Set up headers for the request
|
|
@@ -37,13 +37,13 @@ const executeFunction = async ({ file_key, ids }) => {
|
|
|
37
37
|
const data = await response.json();
|
|
38
38
|
return data;
|
|
39
39
|
} catch (error) {
|
|
40
|
-
console.error('Error
|
|
41
|
-
return { error: 'An error occurred while
|
|
40
|
+
console.error('Error getting image fills:', error);
|
|
41
|
+
return { error: 'An error occurred while getting image fills.' };
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* Tool configuration for
|
|
46
|
+
* Tool configuration for getting image fills from a Figma file.
|
|
47
47
|
* @type {Object}
|
|
48
48
|
*/
|
|
49
49
|
const apiTool = {
|
|
@@ -51,8 +51,8 @@ const apiTool = {
|
|
|
51
51
|
definition: {
|
|
52
52
|
type: 'function',
|
|
53
53
|
function: {
|
|
54
|
-
name: '
|
|
55
|
-
description: '
|
|
54
|
+
name: 'get_image_fills',
|
|
55
|
+
description: 'Get image fills from a Figma file.',
|
|
56
56
|
parameters: {
|
|
57
57
|
type: 'object',
|
|
58
58
|
properties: {
|
|
@@ -60,9 +60,9 @@ const apiTool = {
|
|
|
60
60
|
type: 'string',
|
|
61
61
|
description: 'The key of the Figma file.'
|
|
62
62
|
},
|
|
63
|
-
|
|
63
|
+
node_id: {
|
|
64
64
|
type: 'string',
|
|
65
|
-
description: '
|
|
65
|
+
description: 'The ID of the specific node to retrieve images for.'
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
required: ['file_key']
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Function to get library analytics from Figma.
|
|
2
|
+
* Function to get library action analytics from Figma.
|
|
3
3
|
*
|
|
4
|
-
* @param {Object} args - Arguments for the
|
|
5
|
-
* @param {string} args.library_file_key - The
|
|
6
|
-
* @returns {Promise<Object>} - The result of the library analytics request.
|
|
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
7
|
*/
|
|
8
8
|
const executeFunction = async ({ library_file_key }) => {
|
|
9
|
-
const baseUrl = 'https://api.figma.com
|
|
9
|
+
const baseUrl = 'https://api.figma.com';
|
|
10
10
|
const token = process.env.FIGMA_API_KEY;
|
|
11
11
|
try {
|
|
12
12
|
// Construct the URL for the request
|
|
13
|
-
const url = `${baseUrl}/analytics/libraries/${library_file_key}/
|
|
13
|
+
const url = `${baseUrl}/v1/analytics/libraries/${library_file_key}/actions`;
|
|
14
14
|
|
|
15
15
|
// Set up headers for the request
|
|
16
16
|
const headers = {
|
|
@@ -33,13 +33,13 @@ const executeFunction = async ({ library_file_key }) => {
|
|
|
33
33
|
const data = await response.json();
|
|
34
34
|
return data;
|
|
35
35
|
} catch (error) {
|
|
36
|
-
console.error('Error
|
|
37
|
-
return { error: 'An error occurred while retrieving library analytics.' };
|
|
36
|
+
console.error('Error retrieving library action analytics:', error);
|
|
37
|
+
return { error: 'An error occurred while retrieving library action analytics.' };
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Tool configuration for getting library analytics from Figma.
|
|
42
|
+
* Tool configuration for getting library action analytics from Figma.
|
|
43
43
|
* @type {Object}
|
|
44
44
|
*/
|
|
45
45
|
const apiTool = {
|
|
@@ -47,14 +47,14 @@ const apiTool = {
|
|
|
47
47
|
definition: {
|
|
48
48
|
type: 'function',
|
|
49
49
|
function: {
|
|
50
|
-
name: '
|
|
51
|
-
description: 'Retrieve
|
|
50
|
+
name: 'get_library_action_analytics',
|
|
51
|
+
description: 'Retrieve action analytics for a specific published library file.',
|
|
52
52
|
parameters: {
|
|
53
53
|
type: 'object',
|
|
54
54
|
properties: {
|
|
55
55
|
library_file_key: {
|
|
56
56
|
type: 'string',
|
|
57
|
-
description: 'The
|
|
57
|
+
description: 'The key of the library file for which to retrieve action analytics.'
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
required: ['library_file_key']
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Function to get
|
|
2
|
+
* Function to get library usage analytics from Figma.
|
|
3
3
|
*
|
|
4
|
-
* @param {Object} args - Arguments for the request.
|
|
5
|
-
* @param {string} args.library_file_key - The key of the library file for which to retrieve
|
|
6
|
-
* @returns {Promise<Object>} - The
|
|
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
7
|
*/
|
|
8
8
|
const executeFunction = async ({ library_file_key }) => {
|
|
9
|
-
const baseUrl = 'https://api.figma.com
|
|
9
|
+
const baseUrl = 'https://api.figma.com';
|
|
10
10
|
const token = process.env.FIGMA_API_KEY;
|
|
11
|
-
|
|
12
11
|
try {
|
|
13
12
|
// Construct the URL for the request
|
|
14
|
-
const url = `${baseUrl}/analytics/libraries/${library_file_key}/
|
|
13
|
+
const url = `${baseUrl}/v1/analytics/libraries/${library_file_key}/usages`;
|
|
15
14
|
|
|
16
15
|
// Set up headers for the request
|
|
17
16
|
const headers = {
|
|
@@ -34,13 +33,13 @@ const executeFunction = async ({ library_file_key }) => {
|
|
|
34
33
|
const data = await response.json();
|
|
35
34
|
return data;
|
|
36
35
|
} catch (error) {
|
|
37
|
-
console.error('Error
|
|
38
|
-
return { error: 'An error occurred while retrieving
|
|
36
|
+
console.error('Error retrieving library usage analytics:', error);
|
|
37
|
+
return { error: 'An error occurred while retrieving library usage analytics.' };
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
|
-
* Tool configuration for getting
|
|
42
|
+
* Tool configuration for getting library usage analytics from Figma.
|
|
44
43
|
* @type {Object}
|
|
45
44
|
*/
|
|
46
45
|
const apiTool = {
|
|
@@ -48,14 +47,14 @@ const apiTool = {
|
|
|
48
47
|
definition: {
|
|
49
48
|
type: 'function',
|
|
50
49
|
function: {
|
|
51
|
-
name: '
|
|
52
|
-
description: 'Retrieve
|
|
50
|
+
name: 'get_library_usage_analytics',
|
|
51
|
+
description: 'Retrieve usage analytics for a specific published library file.',
|
|
53
52
|
parameters: {
|
|
54
53
|
type: 'object',
|
|
55
54
|
properties: {
|
|
56
55
|
library_file_key: {
|
|
57
56
|
type: 'string',
|
|
58
|
-
description: 'The key of the library file for which to retrieve
|
|
57
|
+
description: 'The key of the library file for which to retrieve usage analytics.'
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
required: ['library_file_key']
|