Skip to main content
Glama

Edit Design

use_figma
Destructive

Run JavaScript against the Figma plugin API to create or edit designs in the file open in Figma Desktop, then return node IDs and screenshots for verification.

Instructions

Create or edit designs in the file open in Figma Desktop by running JavaScript against the Figma plugin API. code is the body of an async function with figma in scope: use await, and return a value (nodes come back as {id, name, type, x, y, width, height}); console.log output is returned too. The whole run is one undo step. If the script throws, the changes it made before the error stay.

Rules of the plugin API here:

  • The file uses dynamic page loading: use figma.getNodeByIdAsync, figma.setCurrentPageAsync, await page.loadAsync() before reading another page, getMainComponentAsync, and the *Async style/variable getters.

  • Load every font before setting text or text properties: await figma.loadFontAsync({ family: "Inter", style: "Regular" }). Check figma.listAvailableFontsAsync() when unsure a font exists.

  • Colours are 0-1 RGB: fills = [{ type: "SOLID", color: { r: 1, g: 0.4, b: 0 } }]. Paint arrays are immutable: assign a new array.

  • Prefer auto layout: layoutMode, itemSpacing, padding*, primaryAxisAlignItems, counterAxisAlignItems; set layoutSizingHorizontal/Vertical ("FILL", "HUG", "FIXED") only after the node is appended to an auto-layout parent.

  • New nodes land on the current page: place top-level frames clear of existing ones, and append children with parent.appendChild(node).

  • Reuse what the file has: find its components, styles and variables with search_design_system first, and set bound variables with figma.variables.setBoundVariableForPaint.

  • Images from the web: const img = await figma.createImageAsync(url), then fills = [{ type: "IMAGE", imageHash: img.hash, scaleMode: "FILL" }]. fetch(url) works too (e.g. an SVG for figma.createNodeFromSvg). Local files go in with place_image.

  • figma.currentPage.selection = [node] and figma.viewport.scrollAndZoomIntoView([node]) show the result.

Build a screen in a few calls (structure, then sections), return the ids, and check each step with get_screenshot.

Input Schema

NameRequiredDescriptionDefault
codeYesBody of an async function run with `figma` in scope.
fileKeyNoThe key of the Figma file. Accepted for compatibility; the file open in Figma Desktop is always used.
timeoutMsNoHow long to wait for the script, in ms (default 60000).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.5.1

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already flag destructiveHint=true and non-idempotent, and the description adds genuinely non-obvious behavior: the whole run is a single undo step, partial changes persist if the script throws, code runs as an async body with return values and console.log surfaced. It also discloses API-level constraints (dynamic page loading requires the *Async APIs, fonts must be loaded before text edits), which an agent could not infer elsewhere.

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: purpose, then return semantics, then a compact bulleted rules block, then a workflow closer. Dense and every bullet carries operational value, but the volume is very large for a tool description and sits close to documentation rather than selection guidance.

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?

For a destructive, arbitrary-code-execution tool with no output schema, the description covers failure semantics, undo scope, async API requirements, mutation patterns (immutable paint arrays, append before sizing) and verification path. Nothing essential to calling it correctly is missing.

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 coverage is 100%, so the baseline is 3, but the description adds real semantics for `code`: async function body with `figma` in scope, use await, `return` a value, node shape {id, name, type, x, y, width, height}, console.log captured. Only timeoutMs is left to 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+resource+mechanism: 'Create or edit designs in the file open in Figma Desktop by running JavaScript against the Figma plugin API.' This is clearly separable from siblings like search_design_system (read-only lookup) and get_screenshot (verification), and it names its execution environment explicitly.

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?

Gives concrete workflow guidance: reuse the file's components via search_design_system first, use place_image for local files, build in a few calls (structure then sections), and verify each step with get_screenshot. It does not explicitly state when NOT to use this tool (e.g. when a narrower sibling suffices), so it stops short of the top band.

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