Skip to main content
Glama

figma_eval

Run JavaScript directly inside the open Figma file with full plugin API access to read, modify, and return data, solving the need for custom automations and precise design operations without leaving the editor.

Instructions

Run JavaScript inside the Figma plugin sandbox, against the file where the bridge plugin is running.

  • The code body is wrapped in an async function: top-level await and return both work.

  • Globals: figma (full Plugin API) and helpers.

  • Use figma.getNodeByIdAsync(id) — the sync getNodeById is unavailable under dynamic-page access.

  • Switch pages with: await figma.setCurrentPageAsync(page)

  • Load fonts before ANY text mutation, or use helpers.setText / helpers.loadNodeFonts.

  • The return value is JSON-serialized (figma.mixed -> "mixed", cycles pruned). Real Figma nodes collapse to {id,name,type}; return plain data (ids, numbers, strings) instead.

  • resize() RESETS sizing: on TEXT it sets textAutoResize to NONE (resize first, then set textAutoResize = "HEIGHT"); on auto-layout frames it sets both sizing modes to FIXED (set them after resizing, or use helpers.set / helpers.createText, which order this correctly).

  • Heights of text and hug-sized frames read back correctly right after the change — if you see h=10 on a text you resized, the auto-resize was reset (see above).

  • Each mutating tool call becomes ONE undo step for the person (checkpointed with figma.commitUndo); figma_history {action:"undo"} reverts the last call if asked within 60 s. Call helpers.reveal(nodes) at the end so what you built is on their screen.

  • For structure + styles (fills, fonts, effects, auto-layout, bound variables, components) of an existing frame, prefer figma_metadata with styles:true over a hand-written walker; figma_tokens lists the file's variable collections and styles.

helpers: setText(node, chars), loadNodeFonts(node), createText({characters, font:{family,style}, fontSize, color:"#hex", width, lineHeight(%), letterSpacing(px), textCase, textAlign, name, parent, x, y}), rgb("#hex"), set(node, props), query(root, selector), createAutoLayout(dir, props), reveal(nodes), notify(msg), rgba("#hex8"), collection(name, [modes]), token(collection, name, "COLOR"|"FLOAT"|"STRING"|"BOOLEAN", value | {mode: value}), bind(node, "fills"|"strokes"|prop, variable), importComponent(key), instance(key, parent, props), command(kind, payload) — runs a typed command (tokens, metadata, find, changes...) from inside eval and returns {result}.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript to run. Use return to send data back.
timeoutMsNoDefault 60000.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the lone openWorldHint annotation, the description discloses critical runtime behavior: async wrapping, available globals, JSON serialization with node collapsing, resize() side effects on text/auto-layout frames, undo checkpointing, and the need for helpers.reveal(). It also explains font loading requirements before text mutation. This is unusually transparent for a code-execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but every sentence earns its place; it uses bullets to separate behavioral gotchas and a compact helper reference. The main purpose is front-loaded, and subsequent details address exactly the failure modes an agent would encounter when calling eval. No filler or redundant restatement of schema fields appears.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of arbitrary code execution and no output schema, the description is remarkably complete: it covers what can be returned, how nodes serialize, how to handle fonts and resizing, undo semantics, page switching, and available helpers. An agent has enough information to write correct eval calls and recover from common mistakes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although schema coverage is 100%, the description richly extends the code parameter's meaning by documenting the execution model, supported syntax, helper functions, return-value behavior, and common pitfalls. It transforms 'JavaScript to run' into a practical programming contract. The timeoutMs parameter is simple, and 'Default 60000' already suffices.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a precise verb and resource: 'Run JavaScript inside the Figma plugin sandbox, against the file where the bridge plugin is running.' It clearly distinguishes this from sibling tools like figma_metadata and figma_find, which inspect or search rather than execute arbitrary code. No ambiguity exists about what the tool does.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives explicit alternative guidance for structure and style extraction: 'prefer figma_metadata with styles:true over a hand-written walker' and 'figma_tokens lists the file's variable collections and styles.' It does not exhaustively enumerate when not to use eval against every sibling, but it provides clear context for the most common overlapping case.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.