Run ExtendScript
ae_run_scriptExecute 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 valueto send data back. Returned AE objects (comps, layers, properties, items) are summarized to JSON automatically.args(the JSON you pass inargs) andlog(...)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
aemcphelper 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
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | JSON object exposed to the script as `args`. | |
| code | Yes | JavaScript source; a function body, use `return` to return data. | |
| depth | No | How deep to serialize the returned value (default 4). | |
| report | No | List what the script changed in the project (default true). Set false for read-only queries on huge projects. | |
| transpile | No | Convert modern JS for ExtendScript (default true). Set false to send the code exactly as written. | |
| undoGroup | No | Undo step name (default "Surehand MCP Script"). Pass "" to skip the undo group. | |
| timeoutSeconds | No | Max seconds to wait for the result (default 120). |