ae_run_script
Executes custom ExtendScript in the open After Effects project and returns JSON-serialized results; use it to automate project edits, inspect layers/comps, and wrap changes in a named Undo group.
Instructions
Run any ExtendScript in the open After Effects project and return its result. Write the body of a function: use return to send data back (objects/arrays are JSON-serialized). Helpers: KAI.comp(nameOrId), KAI.layer(comp, nameOrIndex), KAI.prop(layerOrGroup, "ADBE Transform Group/ADBE Position"), KAI.find(name, kind), KAI.walk(group, {onlyChanged, filter}), KAI.layerInfo(layer), KAI.itemInfo(item). ARGS holds the args object. Edits are wrapped in one Undo group named by undo_name (pass it whenever the script changes the project).
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": "ae_run_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | ||
| code | Yes | ExtendScript function body | |
| undo_name | No | Undo group name; required for scripts that modify the project | |
| timeout_sec | No | ||
| expected_project | No | Project guard: refuse to run unless the open project path contains this text (e.g. the .aep file name). Use it for every edit to a client project. |