get_file_components
Extract reusable design components from Figma files to maintain consistency across projects and streamline UI development workflows.
Instructions
Get components from a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fileKey | Yes | The key of the file to get components from |
Implementation Reference
- src/handlers/projects.ts:38-42 (handler)The core handler function that destructures the fileKey from args and calls the Figma API to retrieve components from the specified file.async getFileComponents(args: GetFileComponentsArgs) { const { fileKey } = args; return this.api.makeRequest(`/files/${fileKey}/components`); }
- src/types/projects.ts:16-18 (schema)TypeScript interface defining the input parameters for the get_file_components tool, requiring a fileKey string.export interface GetFileComponentsArgs { fileKey: string; }
- src/index.ts:361-374 (registration)Registers the get_file_components tool in the MCP server, including name, description, and input schema specification.{ name: 'get_file_components', description: 'Get components from a file', inputSchema: { type: 'object', properties: { fileKey: { type: 'string', description: 'The key of the file to get components from' } }, required: ['fileKey'] }, },
- src/index.ts:570-576 (registration)Dispatcher in the tool request handler that validates arguments, calls the projectsHandler.getFileComponents method, and returns the result as JSON text.case 'get_file_components': { const args = this.validateArgs<GetFileComponentsArgs>(request.params.arguments, ['fileKey']); const result = await this.projectsHandler.getFileComponents(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }