get_file
Retrieve Figma files by key to access design data, including specific versions, node depth, and branch information for integration and analysis.
Instructions
Get a Figma file by key
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fileKey | Yes | The key of the file to get | |
| version | No | Optional. A specific version ID to get | |
| depth | No | Optional. Depth of nodes to return (1-4) | |
| branch_data | No | Optional. Include branch data if true |
Implementation Reference
- build/handlers/files.js:5-13 (handler)The handler function that implements the core logic of the 'get_file' tool by making an API request to Figma's /files/{fileKey} endpoint with optional parameters.async getFile(args) { const { fileKey, branch_data, ids, version, depth } = args; const params = { branch_data, version, depth }; return this.api.makeRequest(`/files/${fileKey}${this.api.buildQueryString(params)}`); }
- src/index.ts:490-496 (registration)The switch case in the CallToolRequest handler that routes 'get_file' calls to the FilesHandler.getFile method.case 'get_file': { const args = this.validateArgs<GetFileArgs>(request.params.arguments, ['fileKey']); const result = await this.filesHandler.getFile(args); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- src/index.ts:114-139 (registration)The tool registration in the ListTools response, defining name, description, and inputSchema for 'get_file'.{ name: 'get_file', description: 'Get a Figma file by key', inputSchema: { type: 'object', properties: { fileKey: { type: 'string', description: 'The key of the file to get' }, version: { type: 'string', description: 'Optional. A specific version ID to get' }, depth: { type: 'number', description: 'Optional. Depth of nodes to return (1-4)' }, branch_data: { type: 'boolean', description: 'Optional. Include branch data if true' } }, required: ['fileKey'] }, },
- src/types/files.ts:3-6 (schema)TypeScript interface defining the input arguments for the getFile handler, used for validation.export interface GetFileArgs extends BaseParams { fileKey: string; branch_data?: boolean; }
- src/index.ts:117-137 (schema)The JSON schema for the 'get_file' tool input, defining properties and requirements for MCP protocol.inputSchema: { type: 'object', properties: { fileKey: { type: 'string', description: 'The key of the file to get' }, version: { type: 'string', description: 'Optional. A specific version ID to get' }, depth: { type: 'number', description: 'Optional. Depth of nodes to return (1-4)' }, branch_data: { type: 'boolean', description: 'Optional. Include branch data if true' } }, required: ['fileKey']