Skip to main content
Glama
figma-mcp
by ivn4k

Run Plugin API code

execute_code
Destructive

Run JavaScript in the Figma plugin to perform tasks other tools don't cover, such as styles, variables, components, prototyping, and bulk edits, then return the result.

Instructions

Run JavaScript inside the Figma plugin (body of an async function; use await and return a value). Full Figma Plugin API via figma (document uses dynamic page loading: use figma.getNodeByIdAsync, await page.loadAsync() before reading other pages, await figma.loadFontAsync(font) before editing text). Helpers in scope: getNode(id) (throws if missing), setProps(node, props) (same PROPS as update_nodes), serialize(node, depth=1, "full"|"outline"), parseColor("#hex") → {r,g,b,a}, loadFonts(textNode), log(...args). The returned value is JSON-serialized (nodes become {id,name,type}); log() output is returned too. One undo step. Use it for anything the other tools do not cover: styles, variables, components, prototyping, plugin data, bulk edits.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "code": "<code>"
    },
    "name": "execute_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
timeoutMsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.5/5.0
Behavior5/5

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

Annotations supply only destructiveHint=true; the description adds substantial beyond that: exactly one undo step, return values are JSON-serialized with nodes reduced to {id,name,type}, log() output is included, getNode throws on missing nodes, and there are hard constraints (dynamic page loading requires getNodeByIdAsync and await page.loadAsync(); await figma.loadFontAsync before editing text). These are non-obvious execution semantics that would otherwise cause silent failures.

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

Conciseness4/5

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

Front-loaded with the core action and return contract, followed by scoping and routing guidance; every sentence carries information. It is very dense, though — parenthetical nesting around helpers and loading rules makes it slightly harder to scan than it could be.

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

Completeness4/5

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

For an arbitrary-code-execution tool with no output schema and no schema descriptions, the definition covers return format, error behavior, undo semantics, helper surface, and known API gotchas — the things an agent most needs to write working code. The only material gap is the undocumented timeoutMs parameter and its behavior on expiry.

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

Parameters4/5

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

Schema description coverage is 0%, so the description carries the load: it defines `code` as an async function body supporting await and return, enumerates the in-scope helpers (getNode, setProps, serialize, parseColor, loadFonts, log) with signatures and caveats, and explains how return values are serialized. The second parameter, timeoutMs, is never mentioned, leaving its bounds (1000–300000, default 15000) discoverable only from the schema.

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?

States a specific verb and resource — run JavaScript inside the Figma plugin as the body of an async function — and immediately frames its position among siblings as the escape hatch for anything the other tools do not cover (styles, variables, components, prototyping, plugin data, bulk edits). An agent can tell this apart from update_nodes/find_nodes/etc. without opening any schema.

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 routing rule is explicit: use this for anything the other tools do not cover, with concrete categories listed. It does not name specific siblings or state the inverse (prefer update_nodes/set_selection when they suffice), so the agent must infer when *not* to reach for it, but the intended context is clear.

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