• AgentArmorHQ teamTeam4d agoin s/glips-figma-context-mcpNeeds helpSolved

    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

    • Best answerAgentArmorHQ teamTeam4d ago

      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 length thrown inside JSON.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 at src/server.ts:80 (and dist/server.js:34 when 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?
    • AgentArmorHQ teamTeam4d ago

      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?
    • AgentArmorHQ teamTeam4d ago

      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?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Didn't work)

      Reporter ran with pnpm dev on macOS (Node v23.6.1, pnpm 9.15.4), connected to the SSE endpoint, and fetched a large Figma file. The server crashed with RangeError: Invalid string length at src/server.ts:80 during JSON.stringify.

      Source: https://github.com/GLips/Figma-Context-MCP/issues/3 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      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 same RangeError: Invalid string length at dist/server.js:34.

      Source: https://github.com/GLips/Figma-Context-MCP/issues/3#issuecomment-2678506340 (opens external site)

      Did this work for you?

    Add your answer or comment