Skip to main content
Glama
Chandelier

Chandelier

by acidka

run_script

Run ExtendScript in Adobe Illustrator on the active document to execute design code or .jsx files, pass arguments, use built-in recipes, retry failures, and return JSON results.

Instructions

Run ExtendScript in Illustrator on the active document in ONE call: a whole design in one script, details in small ones. Give "code" (a function BODY: use return to get a value back as JSON; Illustrator objects come back as {type, uuid, name, box}) or "file" (a UTF-8 .jsx file with the same body; "args" are arguments[0..]). Non-ASCII text is safe in both. ExtendScript is ES3: var only, no let/const/arrow functions/template strings, no Array.indexOf/map/forEach, no JSON object (use AIA.json / AIA.parse). Errors return the message and the line number in your code. retries:n re-runs on MRAP or a "RETRY" result. recipe: a built-in builder instead of code, options in args[0] (recipe:"list" names them). Helpers (global AIA, always loaded; positions/sizes in session units, origin per configure — default pt, artboard top-left, y down): AIA.layer(name) → get/create layer and make it active (new items go to the active layer) · AIA.fresh(name): same, emptied first (re-runnable builders) AIA.group(name, parent?) → new GroupItem (parent = a Layer or GroupItem object) AIA.swatch(name, color) → global process swatch (create/update); then use colour "swatch:Name" AIA.pstyle(name, {font,size,color,leading,tracking,hscale,align}) → paragraph style (create/update) AIA.text(str, {x,y,font,size,color,align,style,leading,tracking,hscale,name,parent}) → point text; y = BASELINE; "\n" = new line; align left|center|right (anchor at x) Every helper takes its options as the LAST argument, an object; parent goes there (extra positional arguments are ignored). AIA.rect(x,y,w,h,{fill,stroke,sw,name,parent}) · AIA.ellipse(x,y,w,h,{…}) · AIA.line(x1,y1,x2,y2,{stroke,sw,cap:"butt|round|square",dash,name,parent}) · AIA.path([[x,y],…],{closed,fill,stroke,…}) AIA.font(name) → TextFont, fuzzy ("Arial Bold" → Arial-BoldMT) · AIA.box(item) → [x,y,w,h] · AIA.mm(v) → pt · AIA.doc() → active Document · AIA.find(name) AIA.refs(ref) → items for a uuid / "selection" / "name:X*" / "layer:X" / "artboard:N" · AIA.color(spec) → Color · AIA.colorStr(color) → spec AIA.at(k, fn) → run fn with coordinates from artboard k's top-left (multi-artboard builders) AIA.P(x,y) → document coordinates [x, y-up] for raw API calls · AIA.u(v) session units → pt · AIA.warn(msg) Font size, leading, tracking and stroke width are always pt. Colours as in every tool; "gray(60)" is K60 in CMYK documents.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "run_script"
  }
}

Input Schema

NameRequiredDescriptionDefault
argsNo
codeNo
fileNo
recipeNo
retriesNo
timeoutNoseconds, default from configure (300)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.1

TDQS

A4.3/5.0
Behavior5/5

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

With no annotations, the description carries the full behavioral burden and does so thoroughly: it discloses that returned values come back as JSON, that Illustrator objects serialize as {type, uuid, name, box}, that errors return the message plus the offending line number, and exactly what 'retries:n' re-runs on (MRAP or a 'RETRY' result). It also states the ES3 language restrictions that will silently break user code and pins the coordinate/unit conventions.

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?

It is long, but front-loaded with the one-sentence summary, then the invocation modes, then the helper reference as a scannable bulleted list. Almost every line carries operational information an agent needs (units, origin, ES3 limits, helper signatures). The helper catalog pushes it toward reference documentation rather than description, costing a point, but nothing is redundant filler.

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?

There is no output schema, so the description must explain return values and it does — JSON conversion, the {type, uuid, name, box} shape, and error-with-line-number behavior. For a six-parameter, high-complexity scripting tool it also covers coordinate origin, session units, font-size unit conventions, and colour spec syntax. An agent could call this correctly from the description alone.

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?

Schema description coverage is only 17% (just 'timeout'), so the description must compensate and largely does: it explains that 'code' is a function BODY where `return` yields a value, that 'file' is a UTF-8 .jsx with the same body, that 'args' surface as arguments[0..], that 'recipe' is a built-in builder expecting options in args[0] with recipe:"list" enumerating names, and that 'retries' is a re-run count. Only 'timeout' is left to the schema, which does define it.

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

Purpose4/5

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

The first sentence names a specific verb and resource: run ExtendScript against the active Illustrator document, and adds the scope qualifier 'in ONE call: a whole design in one script, details in small ones.' An agent can tell this is the general scripting escape hatch rather than a structured builder tool, though it never names a sibling (e.g. create_shape or menu_command) as the alternative for simple operations.

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

Usage Guidelines3/5

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

There is rich guidance on HOW to invoke it — choose 'code' for a function body, 'file' for an equivalent .jsx, 'recipe' for a built-in builder, and 'retries' for MRAP failures. What is missing is when to prefer this over the many structured siblings; the definition never states that simple shapes/text should go through create_shape/create_text instead. Usage is implied ('a whole design in one script, details in small ones') rather than stated as a routing rule.

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