Figma-Context-MCP: RangeError: Invalid string length when fetching large Figma files
How do I fix 'RangeError: Invalid string length' when fetching large Figma files in Figma-Context-MCP? The server crashes during JSON.stringify when I select a full page or a moderately sized layer in Figma and paste its link. Running on macOS with Node v23.6.1 via
pnpm dev.Originally asked on GitHub: https://github.com/GLips/Figma-Context-MCP/issues/3
5 answers
Status: mitigated but not confirmed fixed. The owner pushed version 0.1.4 (commit 778ac9d) to address this crash and then closed the issue on 2025-02-27, asking that new problems be reported in a fresh issue.
The crash is a Node.js
RangeError: Invalid string lengththrown insideJSON.stringify()while serializing the response. Fetching a large Figma file (a whole page, or even a moderately sized layer) could exceed Node's maximum string length, as seen in the stack trace atsrc/server.ts:80(anddist/server.js:34when run via npx).What changed in 0.1.4:
- Full-file responses are now parsed and simplified before being returned; irrelevant Figma design metadata is stripped, making responses 40–60% smaller on average.
- Each top-level node in the file is stringified individually, which reduces the chance of a single
JSON.stringify()call hitting the limit.
The only workaround confirmed in the thread is to feed the server a much smaller selection: one commenter reported that a much smaller copied piece of the file worked fine, while a moderately sized layer still crashed with the same error. So a single small component instead of a full page is likely to succeed, though the owner still hit MCP server timeout issues on large files after the 0.1.4 change. A merged PR in
@modelcontextprotocol/typescript-sdk(#152) was expected to help with those timeouts, but there was no documentation on it yet when the issue closed.Did this work for you?What @GLips tried on GitHub (Partly worked)
Owner released version 0.1.4: full-file responses are parsed and simplified (40–60% smaller on average) and each top-level node is stringified individually. The owner said it “should improve problems here” but also noted remaining MCP server timeout issues, then closed the issue.
Source: https://github.com/GLips/Figma-Context-MCP/issues/3#issuecomment-2679907339 (opens external site)
Did this work for you?What @max-arias tried on GitHub (Worked)
In an edit, the same commenter reported that giving the server a much smaller copied piece of the Figma file worked fine, confirming the crash is size-related.
Source: https://github.com/GLips/Figma-Context-MCP/issues/3#issuecomment-2678506340 (opens external site)
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Reporter ran with
pnpm devon macOS (Node v23.6.1, pnpm 9.15.4), connected to the SSE endpoint, and fetched a large Figma file. The server crashed withRangeError: Invalid string lengthatsrc/server.ts:80during JSON.stringify.Source: https://github.com/GLips/Figma-Context-MCP/issues/3 (opens external site)
Did this work for you?What @max-arias tried on GitHub (Didn't work)
Another user ran the server via npx (
figma-developer-mcp) and fetched one layer of a file that was “not huge but not small”. It crashed with the sameRangeError: Invalid string lengthatdist/server.js:34.Source: https://github.com/GLips/Figma-Context-MCP/issues/3#issuecomment-2678506340 (opens external site)
Did this work for you?
Related questions
- How to use Figma-Context-MCP with VS Code and GitHub Copilot?
- Figma-Context-MCP: why does my AI host pick the wrong tool, and what changed in v0.1.6?
- Figma-Context-MCP fails to connect in Cline — how to configure it?
- Figma-Context-MCP get_figma_data fails: 'Error fetching file: [object Object]'
- Figma-Context-MCP on Windsurf: failed to parse tool input schema for get_figma_data after 0.2.0