Skip to main content
Glama
Figma Local Bridge

Figma Local Bridge

by Miart

figma_use

Runs Plugin API JavaScript inside an open Figma file with automatic rollback if edits escape the given scope. Each call is one undo step, so agents can create or modify nodes safely.

Instructions

Run Plugin API JavaScript inside the open Figma file (async function body; figma and a capturing console are in scope; return a value to get it back). One call = one undo step. SAFETY: arbitrary code cannot be sandboxed, so the plugin indexes the page before and after, and ROLLS BACK the call if anything outside scopeNodeId was created, deleted, reparented or altered, if the scope root itself disappeared, or if page-global state (variables/styles/paints) changed. Known limits: fire-and-forget async work that lands after the diff is not covered, and edits inside an existing node are detected only by a cheap signature (type, name, child count, text length), not pixel-exact. Enum literals assigned in the snippet are checked locally BEFORE sending: a known cross-API spelling or near-miss (e.g. overflowDirection="VERTICAL_SCROLLING") is refused with the accepted values, so nothing is applied; an unfamiliar value is passed through for the runtime to judge. Requires allowDestructive:true, and scopeNodeId unless allowPageWide:true. Prefer small calls and return the ids you create. A third argument flb is a small helper set for this manifest's traps (dynamic-page mode, font loading, absolute vs parent-relative coordinates): await flb.byId(id) resolves a node id (figma.getNodeById throws in dynamic-page mode; the error says an id from another file never resolves); flb.find({within, name, match, type}) / flb.one(...) search descendants and refuse to answer with a truncated list or an ambiguous pick; flb.bbox(node, {render:true}) gives ABSOLUTE bounds (render bounds include shadows/strokes — the ones packing needs); flb.clear(node) removes children and returns what went; flb.flatten(node) detaches every instance in a subtree (outermost first) and throws rather than leave it half flat — the node passed in is invalidated by the detach, so use the returned root; flb.grid(nodes, {parent, cell, columns, gap, origin, fit}) lays nodes out in uniform atlas cells at ABSOLUTE coordinates, optionally scaling them down to fit; await flb.text(content, {parent, x, y, size, font, fills}) loads the font before writing characters. The write helpers refuse a target outside scopeNodeId, or on a page other than the current one (the scope guard only indexes one page), BEFORE writing anything.

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>",
      "allowDestructive": "<allowDestructive>"
    },
    "name": "figma_use"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesBody of an async function. Example: `const f = figma.createFrame(); f.name='Card'; return f.id`
fileKeyNoWhich connected Figma file to use: its fileKey (figma_whoami) or, when omitted, the only connected file. Required once more than one file is connected; figma_ping lists them.
verboseNoReturn full node objects instead of the compact id/type/name form.
timeoutMsNo
descriptionNoOne line on what this does — recorded in the local journal (figma_journal)
scopeNodeIdNoThe only subtree the code may touch. Anything outside is rolled back. Required unless allowPageWide.
allowPageWideNoRun unconfined — refused by default.
allowDestructiveYesMust be true. Acknowledges that this runs arbitrary Plugin API code.
allowGlobalChangesNoPermit variables/styles/paints changes, which are not inside any subtree.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.36.0

TDQS

A4.5/5.0
Behavior5/5

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

No annotations exist, so the description carries the full burden and does so unusually well: it discloses the before/after page indexing, the rollback conditions (creation, deletion, reparenting, alteration outside scope; scope root disappearance; page-global state changes), and the local enum-literal pre-check that refuses known-bad values before anything is applied. It goes further to state its own detection limits (fire-and-forget async work, cheap signature vs pixel-exact) — exactly the caveats an agent needs before trusting a rollback guarantee.

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

Conciseness3/5

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

Front-loaded with purpose and safety, which is correct for a high-risk tool, but the body is two very dense paragraphs of prose with the `flb` helper catalogue crammed into run-on semicolon chains. The helper reference is genuinely useful yet would be far more scannable as a list; as written it forces the agent to parse a wall of text.

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 9-parameter arbitrary-code tool with no annotations and no output schema, the definition covers prerequisites, mutation semantics, rollback behavior, known failure modes, and the helper affordances for this manifest's specific traps. An agent has enough to decide whether to call it and how to call it safely.

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?

With 89% schema coverage the baseline is 3, and the description adds real meaning beyond it: `code` is described as an async function body with a return channel, `scopeNodeId` gains the 'anything outside is rolled back' consequence, and the unconfined mode is framed as 'refused by default'. It says nothing about `verbose`, `timeoutMs`, `fileKey`, or `description`, so it is not exhaustive.

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?

Opens with a precise verb+resource: 'Run Plugin API JavaScript inside the open Figma file', immediately clarifying the execution model ('async function body; `figma` and a capturing `console` are in scope'). It also states the atomicity contract ('One call = one undo step'), which distinguishes it from any granular edit sibling.

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 operating guidance: 'Prefer small calls and return the ids you create', the required `allowDestructive:true`, and the scopeNodeId-vs-allowPageWide choice. It does not explicitly contrast this tool against siblings like figma_batch_edit or figma_build, so an agent must infer when general code execution beats a purpose-built tool.

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