execute
Run a script against the connected Foundry world with the full foundry.* API — reads, writes and deletes. code is the body of an async function (see docs): call foundry..({ ... }), use await, console.log, and return what you want back (JSON, size-limited). Before it runs, a static check refuses the script if it calls a method your tier lacks, an unknown method, or accesses foundry dynamically — the answer lists each with its line. allowPartial: true runs it anyway and each locked call fails inside the script. Writes count against per-script budgets (the limits line of the docs index); the trace lists every call with the ids it touched. Nothing is rolled back when a script fails part-way: the trace shows what already happened — continue from it rather than re-running everything.
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": "execute"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Body of an async function, e.g. `const a = await foundry.actors.create({ name: "Guard", type: "npc" }); return a.id;` | |
| debug | No | Keep the script and its report for the world owner's diagnostics (default false) | |
| allowPartial | No | Run even if the static check finds locked or computed calls; each locked call then fails at runtime (default false) |