# run_lua

Run a Lua 5.4 script against a document (sandboxed: io / os / app.fs / file loading and saving only inside allow_paths, everything else is denied; 128 MB memory, 10 s by default, timeout_seconds 1-120 raises the time and the instruction budget with it; source up to 16 MiB) as ONE undo step; if it raises an error the document is left unchanged. The script sees sprite (pixels, layers, frames, cels, tags, slices, tilesets, selection, palette, user data), app and color; print() and app.alert() output is returned. NOTE: in Lua, layers/frames/tags are 1-based (layer 1 = bottom) while pixel coordinates and palette indices are 0-based; sprite.activeLayer/activeFrame are the document's active layer/frame. Files: with allow_paths (folders inside --root or an --allow-dir) a script can read images and sprites (Image{ fromFile=... }, Sprite{ fromFile=... }, app.open(path)) and write files; the script can see only ITS document plus the sprites it opens or creates itself (app.sprites lists exactly those): documents open in this server or in the Pixmith app are NOT visible to it, so doc_save (copy=true) the other document into an allowed folder and app.open it, or move pixels with clipboard / cel copy. Sprites a script creates or opens come back as new headless documents. Read the full API with the help tool (topic lua_api) or the pixmith://docs/lua-api resource. Give source (aliases: script, code) or a .lua path.

Agent View of the PolicyLayer registry record for `run_lua`. HTML page: https://policylayer.com/tools/pixmith-mcp/run-lua

## Facts

- Tool: `run_lua`
- Server: Pixmith (`pixmith-mcp`) — https://policylayer.com/tools/pixmith-mcp.md
- Install: `npx -y pixmith-mcp`
- Homepage: https://www.npmjs.com/package/pixmith-mcp
- Risk category: Execute (High risk)
- Registry record: grade F, identity unverified
- Server rate-limited: no
- Parameters: 7
- Recommended policy verdict: Rate-limited

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `doc` | string | no | Document id (see doc_list); optional when only one document is open. |
| `code` | string | no | Alias of `source`. |
| `path` | string | no | A .lua file to run instead of `source`. |
| `script` | string | no | Alias of `source`. |
| `source` | string | no | Lua source code (up to 16 MiB). |
| `allow_paths` | array | no | Folders (or files) the script may read and write with io / os / app.fs / Image{fromFile} / app.open / saveAs. Everything else is denied (there is nobody to ask) |
| `timeout_seconds` | integer | no | Time limit in seconds, 1-120 (default 10). The instruction budget grows in proportion. |

Parameters from the server's own tool schema.

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "run_lua",
    "arguments": {}
  }
}
```

## Why run_lua is rated High

run_lua triggers real processes with real consequences. An agent gone sideways doesn't fire it once. It starts dozens of builds, sends mass notifications, or burns through compute before anyone looks up.

Risk signals: Accepts freeform code/query input (script) · Accepts file system path (path) · Bulk/mass operation — affects multiple targets · Admin/system-level operation

## Use case

AI agents invoke run_lua to trigger actions in Pixmith. What it does depends on the arguments the agent supplies, and its effects often reach beyond the immediate call: builds kicked off, notifications sent, workflows started.

## Recommended policy (PolicyLayer)

Verdict: **Rate-limited**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches Pixmith:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "run_lua": {
      "limits": [
        {
          "counter": "run_lua_rate",
          "window": "minute",
          "max": 10,
          "scope": "grant"
        }
      ]
    }
  }
}
```

## Other tools on Pixmith (58)

- `brush` — Destructive — https://policylayer.com/tools/pixmith-mcp/brush.md
- `cel` — Destructive — https://policylayer.com/tools/pixmith-mcp/cel.md
- `clipboard` — Destructive — https://policylayer.com/tools/pixmith-mcp/clipboard.md
- `filter` — Destructive — https://policylayer.com/tools/pixmith-mcp/filter.md
- `frame` — Destructive — https://policylayer.com/tools/pixmith-mcp/frame.md
- `help` — Destructive — https://policylayer.com/tools/pixmith-mcp/help.md
- `iso_grid` — Destructive — https://policylayer.com/tools/pixmith-mcp/iso-grid.md
- `layer` — Destructive — https://policylayer.com/tools/pixmith-mcp/layer.md
- `palette` — Destructive — https://policylayer.com/tools/pixmith-mcp/palette.md
- `slice` — Destructive — https://policylayer.com/tools/pixmith-mcp/slice.md
- `tag` — Destructive — https://policylayer.com/tools/pixmith-mcp/tag.md
- `terrain` — Destructive — https://policylayer.com/tools/pixmith-mcp/terrain.md
- `terrain_paint` — Destructive — https://policylayer.com/tools/pixmith-mcp/terrain-paint.md
- `trace` — Destructive — https://policylayer.com/tools/pixmith-mcp/trace.md
- `doc_new` — Execute — https://policylayer.com/tools/pixmith-mcp/doc-new.md
- `draw_curve` — Execute — https://policylayer.com/tools/pixmith-mcp/draw-curve.md
- `draw_text` — Execute — https://policylayer.com/tools/pixmith-mcp/draw-text.md
- `free_transform` — Execute — https://policylayer.com/tools/pixmith-mcp/free-transform.md
- `render` — Execute — https://policylayer.com/tools/pixmith-mcp/render.md
- `sprite_size` — Execute — https://policylayer.com/tools/pixmith-mcp/sprite-size.md
- `transaction` — Execute — https://policylayer.com/tools/pixmith-mcp/transaction.md
- `transform` — Execute — https://policylayer.com/tools/pixmith-mcp/transform.md
- `tween` — Execute — https://policylayer.com/tools/pixmith-mcp/tween.md
- `color_mode` — Other — https://policylayer.com/tools/pixmith-mcp/color-mode.md
- `draw_pixels` — Other — https://policylayer.com/tools/pixmith-mcp/draw-pixels.md
- `draw_polygon` — Other — https://policylayer.com/tools/pixmith-mcp/draw-polygon.md
- `draw_shape` — Other — https://policylayer.com/tools/pixmith-mcp/draw-shape.md
- `draw_stroke` — Other — https://policylayer.com/tools/pixmith-mcp/draw-stroke.md
- `gradient` — Other — https://policylayer.com/tools/pixmith-mcp/gradient.md
- `history_goto` — Other — https://policylayer.com/tools/pixmith-mcp/history-goto.md
- …and 28 more: https://policylayer.com/tools/pixmith-mcp.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=pixmith-mcp · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/pixmith-mcp
