You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
RangeError: Invalid string length when fetching large Figma files #3
Hi guys this is a really cool concept but I can't seem to get it to work properly. When I include a link to a Figma page I get errors in your MCP app. This happens on full pages. When trying small components it just hangs on "successfully found page"
Bug Description
When fetching certain Figma files, the server crashes with a RangeError: Invalid string length error during JSON stringification.
Steps to Reproduce
Start the server with pnpm dev
Connect to the SSE endpoint
Attempt to fetch a large Figma file (e.g. file ID: 'my-file-id-placeholder')
Error Output
Error fetching file 'my-file-id-placeholder': RangeError: Invalid string length
at JSON.stringify (<anonymous>)
at /Users/mike/dev/personal/mcp/Figma-Context-MCP/src/server.ts:80:28
Expected Behavior
The server should handle large Figma files gracefully, either by:
Implementing streaming for large responses
Chunking the response data
Adding proper error handling with user-friendly messages
Additional Context
The error occurs during JSON.stringify() operation
Seems to happen with specific large Figma files
Successfully finds smaller files (e.g. file ID: 'my-file-id-placeholder') but then hangs
Thanks for the detailed bug report! I'll look into this, but can you provide some more context on your use case? Did you want to feed in an entire Figma file and just have it implement everything in there?
Thanks for the detailed bug report! I'll look into this, but can you provide some more context on your use case? Did you want to feed in an entire Figma file and just have it implement everything in there?
Thanks @GLips my first attempt was to try and push Cursor to see if it could build a full UI and how far it would get. Then I quickly realized that wasn't feasible so I tried to use a smaller component like a card with some features in it. That still gave me the same error so I decided to open up a bug ticket.
I just pushed an update (version 0.1.4) that should improve problems here.
Full file responses now get parsed and simplified so the total response returned isn't as large and is better tuned to development needs (i.e. irrelevant Figma design metadata is stripped, making the total response anywhere from 40–60% smaller on average).
It's also now stringifying each top-level node in the file individually to further reduce the likelihood this crops up.
I'm now running into MCP server timeout issues though. It looks like a PR was merged into @modelcontextprotocol/typescript-sdk 2 hours ago that might help here, but there's no documentation on how to leverage it yet. I'm keeping an eye on things there—hopefully it'll let us grab Figma files of any size without dealing with the hardcoded timeout currently in the SDK.
Will keep this thread open for more reports and updates on my end when they're available.
Activity
GLips commentedon Feb 24, 2025
Thanks for the detailed bug report! I'll look into this, but can you provide some more context on your use case? Did you want to feed in an entire Figma file and just have it implement everything in there?
max-arias commentedon Feb 24, 2025
I'm having the same issue:
Error fetching file xxxx: { status: 404, err: 'Not found' } Error fetching file xxx: RangeError: Invalid string length at JSON.stringify (<anonymous>) at /Users/maxarias/.npm/_npx/e05028111420be70/node_modules/figma-developer-mcp/dist/server.js:34:58 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /Users/maxarias/.npm/_npx/e05028111420be70/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js:76:28I'm giving it a link to one layer of the figma file, it's not huge but it's not small
EDIT: Giving it a much smaller piece it worked fine, so yeah it seems that size of the copied section is the issue
mikecfisher commentedon Feb 24, 2025
Thanks @GLips my first attempt was to try and push Cursor to see if it could build a full UI and how far it would get. Then I quickly realized that wasn't feasible so I tried to use a smaller component like a card with some features in it. That still gave me the same error so I decided to open up a bug ticket.
GLips commentedon Feb 24, 2025
I just pushed an update (version 0.1.4) that should improve problems here.
Full file responses now get parsed and simplified so the total response returned isn't as large and is better tuned to development needs (i.e. irrelevant Figma design metadata is stripped, making the total response anywhere from 40–60% smaller on average).
It's also now stringifying each top-level node in the file individually to further reduce the likelihood this crops up.
I'm now running into MCP server timeout issues though. It looks like a PR was merged into @modelcontextprotocol/typescript-sdk 2 hours ago that might help here, but there's no documentation on how to leverage it yet. I'm keeping an eye on things there—hopefully it'll let us grab Figma files of any size without dealing with the hardcoded timeout currently in the SDK.
Will keep this thread open for more reports and updates on my end when they're available.
GLips commentedon Feb 27, 2025
Closing this for now. Reopen a new issue if it arises again.