Skip to main content
Glama

Run ExtendScript

ae_run_script
Destructive

Execute JavaScript/ExtendScript inside After Effects to perform any task the scripting API exposes and return the result as JSON.

Instructions

Execute JavaScript inside After Effects (its ExtendScript scripting API) and return the result. This is the most powerful tool: anything in the After Effects scripting API is available (app, app.project, CompItem, layers, properties, render queue, File/Folder, system.callSystem...).

  • The code runs as the body of a function: use return value to send data back. Returned AE objects (comps, layers, properties, items) are summarized to JSON automatically.

  • args (the JSON you pass in args) and log(...) are available; log output is returned too.

  • Modern JavaScript is fine: let/const, arrow functions, template strings, destructuring, spread, classes, ?. and ??, for...of, plus map/filter/forEach/find/includes, Object.keys/assign and JSON (converted for AE automatically). Not available: async/await, Promise, Map/Set, generators.

  • The aemcp helper library is available: aemcp.findComp(idOrName), aemcp.findLayer(comp, indexOrName), aemcp.findItem(ref), aemcp.resolveProp(layer, 'Transform/Position'), aemcp.color('#ff0000'), aemcp.compInfo(comp, true), aemcp.layerInfo(layer, true), aemcp.propInfo(prop, {depth:2}), aemcp.projectInfo().

  • Collections are 1-based: app.project.item(1), comp.layer(1), prop.property(1).

  • The whole script is one undo step. Errors come back with the failing line and code around it. ae_get_scripting_guide has an API cheat sheet.

  • Prefer the dedicated tools for common edits (clearer validation and results); use this for anything they don't cover. For a script file on disk use ae_run_script_file.

Input Schema

NameRequiredDescriptionDefault
argsNoJSON object exposed to the script as `args`.
codeYesJavaScript source; a function body, use `return` to return data.
depthNoHow deep to serialize the returned value (default 4).
reportNoList what the script changed in the project (default true). Set false for read-only queries on huge projects.
transpileNoConvert modern JS for ExtendScript (default true). Set false to send the code exactly as written.
undoGroupNoUndo step name (default "Surehand MCP Script"). Pass "" to skip the undo group.
timeoutSecondsNoMax seconds to wait for the result (default 120).

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and openWorldHint=true, and the description layers on execution semantics the agent could not otherwise know: the script runs as a function body, the whole script is one undo step, errors return with the failing line and surrounding code, log output is returned, and returned AE objects are auto-summarized to JSON. It also names the language limits (no async/await, Promise, Map/Set, generators) and the 1-based collection indexing, which materially affect how code is written.

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 one-line purpose, then bulleted detail with zero filler sentences. The aemcp helper enumeration and the JavaScript feature list are dense but each entry carries actionable information; a slightly tighter presentation could trim a few characters without losing meaning.

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, and the description compensates fully: it describes what comes back (returned value, summarized AE objects, log output, errors with line context) and how deeply objects are serialized. For a 7-parameter, open-world, destructive execution tool, nothing an agent needs to invoke it safely 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 genuine meaning on top: it explains that `code` is a function body using `return`, that `args` is exposed to the script as a variable, and that transpilation exists because of ExtendScript's older JS dialect (with the exact supported/unsupported feature list). `depth` and `report` are left to the schema, which already documents them well.

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 (execute) and resource (JavaScript inside After Effects' ExtendScript API) plus the return behavior. It explicitly differentiates itself from siblings by saying dedicated tools are preferable for common edits and that ae_run_script_file handles on-disk scripts, so an agent can place it in the toolset 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 Guidelines5/5

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

Explicit when-to-use (anything the dedicated tools don't cover) and when-not-to-use (common edits → dedicated tools; script file on disk → ae_run_script_file), plus a pointer to ae_get_scripting_guide for the API cheat sheet. Alternatives and the conditions that select them are named, not implied.

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