read_comments
Retrieve all comments from a Figma file to review feedback and track design discussions within collaborative projects.
Instructions
Get all comments on a Figma file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_key | Yes | The key of the Figma file |
Implementation Reference
- index.ts:217-227 (handler)Dedicated handler function for the read_comments tool that fetches comments using the helper and returns formatted JSON response as CallToolResult.async function doReadComments(fileKey: string): Promise<CallToolResult> { const data = await readComments(fileKey); return { content: [ { type: "text", text: JSON.stringify(data, null, 2), }, ], }; }
- index.ts:68-81 (schema)Tool schema defining name, description, and input schema for read_comments.const READ_COMMENTS: Tool = { name: "read_comments", description: "Get all comments on a Figma file", inputSchema: { type: "object", properties: { file_key: { type: "string", description: "The key of the Figma file", }, }, required: ["file_key"], }, };
- index.ts:138-140 (registration)Registration of the read_comments tool (as READ_COMMENTS) in the list of available tools returned by ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ADD_FIGMA_FILE, VIEW_NODE, READ_COMMENTS, POST_COMMENT, REPLY_TO_COMMENT], }));
- index.ts:275-277 (handler)Dispatch logic within the main CallToolRequest handler that routes calls to the read_comments tool to its dedicated handler.if (request.params.name === "read_comments") { const input = request.params.arguments as { file_key: string }; return doReadComments(input.file_key);
- figma_api.ts:101-108 (helper)Supporting utility function that performs the actual Figma API request to fetch comments for the given file key.export async function readComments(fileKey: string) { const response = await axios.get(`https://api.figma.com/v1/files/${fileKey}/comments`, { headers: { "X-FIGMA-TOKEN": getFigmaApiKey(), }, }); return response.data; }