Run ExtendScript
run_scriptExecute arbitrary ExtendScript in After Effects for tasks that dedicated tools do not cover; returns the last expression and can wrap code as a function with args.
Instructions
Execute arbitrary ExtendScript (ES3 JavaScript) inside After Effects and return the value of the last expression. Use it for anything no dedicated tool covers. The full AE scripting DOM is available (app, app.project, CompItem, ...), plus the AEMCP helper library (AEMCP.getComp(ref), AEMCP.getLayer(comp, ref), AEMCP.getProp(layer, path), AEMCP.describeLayer(L), AEMCP.call('', args)). AE objects in the result are summarized to JSON. With wrapInFunction=true the code is a function body: use return, and read inputs from args. Runs inside one undo group.
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>"
},
"name": "run_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Values passed to the function as `args` (wrapInFunction only). | |
| code | Yes | ExtendScript source. No let/const/arrow functions (ES3). | |
| timeoutSeconds | No | Max seconds to wait (default 60). | |
| wrapInFunction | No | Treat code as a function body (use return). |