Automate Substance 3D Painter: MCP vs Python Plugins vs CLI
There are several ways to automate Adobe Substance 3D Painter, and they suit different jobs. A Python plugin runs inside Painter and is good for UI tools. The remote scripting endpoint lets any external script send code to a running Painter. An MCP server lets an AI agent do the scripting for you, and a CLI wraps the same operations for shell scripts and CI-style batch jobs. This guide compares them and shows working examples of each.
The options at a glance
| Approach | Runs where | Best for | Cost |
|---|---|---|---|
| Python plugin | Inside Painter, loaded at startup | Custom panels, menu actions, event hooks, studio tooling | You write and maintain Python against the substance_painter API |
| Remote scripting endpoint | Any process on the machine, via HTTP to localhost:60041 | Pipeline scripts that drive an already-running Painter | You write the Python snippets and handle errors and API drift |
| MCP server (MCP Pro for Painter) | Your AI client, such as Claude Code or Cursor | One-off and exploratory work described in plain language | No code, but it needs an AI client in the loop |
painter-cli | Your shell or scripts | Repeatable batch jobs built from tested tool calls | Shell scripting only, with JSON output and exit codes |
These approaches stack. MCP Pro for Painter and painter-cli are both built on the remote scripting endpoint, which in turn runs Painter's own Python API. Moving between them is incremental, not a rewrite.
Option 1: Painter Python plugins
Painter embeds a Python interpreter and exposes its API as the substance_painter package, with modules such as project, textureset, layerstack, baking, export, resource and event. A plugin is a Python module placed in Painter's user plugins folder, under python/plugins inside your Painter documents folder. Painter loads it at startup and calls its start_plugin() and close_plugin() functions. You can enable and reload plugins from Painter's Python menu.
Plugins are the right tool when you need something that lives in Painter's UI: a custom dock, a menu command artists click, or a handler that runs on every project open or export. They are also the most work. You own the code, the Qt UI, and updates when the API shifts between Painter releases.
Plugins don't help with "do this across 40 files tonight" unless you also build a way to trigger them from outside. That is what the next option is for.
Option 2: the remote scripting endpoint
Start Painter with --enable-remote-scripting and it accepts JSON requests on http://localhost:60041/run.json. Each request carries a Python (or JavaScript) command, and the reply carries the value of the last expression:
curl -s -X POST http://localhost:60041/run.json \
-H 'Content-Type: application/json' \
-d '{"command": "import json; json.dumps(2+2)", "type": "python"}'
# -> {"value": "4"}
From Python, the same call needs only the standard library:
import json, urllib.request
def painter(code: str):
req = urllib.request.Request(
"http://localhost:60041/run.json",
data=json.dumps({"command": code, "type": "python"}).encode(),
headers={"Content-Type": "application/json"},
)
with urllib.request.urlopen(req, timeout=30) as resp:
return json.loads(resp.read())
print(painter("import substance_painter.project as p\np.is_open()"))
This is powerful and raw. Every snippet is code you write and maintain. Errors come back as Python tracebacks inside the response. Long operations such as bakes and exports are asynchronous inside Painter, so you have to wait for their events yourself. API differences between Painter versions are yours to handle too.
Security: the endpoint runs whatever code it receives. Painter listens on localhost, but any process on the machine can reach it. Only enable remote scripting on machines you control, and close Painter, or restart it without the flag, when you don't need it.
Option 3: an AI agent over MCP
MCP Pro for Painter puts a library of tested, version-tolerant snippets behind named tools, 200+ of them, and exposes them to AI clients over the Model Context Protocol. Instead of writing the snippet, you describe the outcome:
For every texture set whose name starts with weapon_, set the resolution to 2048, apply the smart material I name next, then export for Unreal to D:/UE5/Game/Content/Textures/Weapons/.
The agent chains list_texture_sets, batch_set_resolution, batch_apply_smart_material and export_for_unreal. What you get compared with raw scripting:
- Structured results. Every tool returns
{"ok": true, "data": ...}or{"ok": false, "error": ..., "type": ...}, with types such asValidationError,ConnectionError,TimeoutErrorandUnsupportedError, so the agent can recover instead of failing on a traceback. - Version tolerance. Tools try known API variations. Engine export presets, for example, try several preset names and report which one was resolved.
- Undo-safe edits. Layer mutations are wrapped in scoped modifications, so each edit is one Ctrl+Z step in Painter.
- Async handled. Bake and export tools wait for Painter's completion events with sensible timeouts, and
wait_for_bake_complete,wait_for_export_completeandwait_for_project_loadedare available as separate tools.
When no dedicated tool exists, the agent can fall back to execute_python, which works like the raw endpoint but returns the same envelope. Start the server with --no-execute-arbitrary to remove that escape hatch, together with execute_js, when you want the agent limited to the named tools.
The trade-off: an agent is ideal for one-off, exploratory or loosely specified work. For a job you will run unchanged every night, you want something deterministic.
Option 4: painter-cli for scripts and batch jobs
painter-cli ships with MCP Pro for Painter and calls the same tool functions directly, with no MCP client and no AI. The wire behavior matches what the agent sees one-to-one. Commands are grouped:
painter-cli # list groups
painter-cli export # list commands in a group
painter-cli export for-unreal --help
The groups are connect, project, set, layer, mask, material, export, bake, validate, batch, probe and raw. Output is pretty-printed JSON, or one line with --raw for jq. Exit codes are designed for scripts:
| Exit code | Meaning |
|---|---|
| 0 | The tool returned ok: true |
| 1 | The tool returned ok: false |
| 2 | Usage error, such as a bad argument |
| 3 | Painter could not be reached |
Global options --host, --port and --timeout go before the group name.
Example: batch export a folder of projects
This bash script opens every .spp in a folder, runs a stack audit, exports for Unreal into a per-asset folder, and closes the project. close_project closes without saving, so nothing is modified on disk.
#!/usr/bin/env bash
set -u
SRC="D:/Art/props"
OUT="D:/UE5/Game/Content/Textures/Props"
painter-cli connect ping > /dev/null || { echo "Painter not reachable"; exit 1; }
for f in "$SRC"/*.spp; do
name=$(basename "$f" .spp)
echo "== $name"
painter-cli project close > /dev/null
painter-cli project open "$f" > /dev/null || { echo "open failed: $f"; continue; }
painter-cli --raw validate audit > "$OUT/$name.audit.json"
painter-cli export for-unreal "$OUT/$name/" > /dev/null || echo "export failed: $name"
painter-cli project close > /dev/null
done
Because the exit codes are reliable, the same pattern works in a scheduled task or a build step on a machine that keeps Painter open with remote scripting enabled.
Example: a pre-export budget check
painter-cli --raw validate budget --rules '[{"pattern":"prop_*","max_width":1024,"max_height":1024},{"pattern":"char_*","max_width":4096,"max_height":4096}]' \
| jq '.data.total_violations'
The --rules value uses the same {pattern, max_width, max_height} shape as the validate_resolution_budget tool.
Saved workflows: from agent session to repeatable job
A practical path is to let the agent figure out a sequence once, then freeze it. In full mode the workflow tools store a named list of tool calls as JSON:
save_workflow: savescalls, a list of{"tool": ..., "args": {...}}, under a name. Files go to.mcp_workflows/next to the open project, or~/.mcp_workflows/when no project is open.list_workflowsandload_workflow: browse and inspect saved workflows.replay_workflow: runs each call in order. Usedry_run: trueto preview the calls first. A missing tool is reported per call and does not stop the replay.
That audit-and-export sequence worked. Save it as a workflow called unreal_props_export so I can replay it on the next project.
The saved JSON is also readable documentation of exactly what ran, which helps when a teammate asks how a set of textures was produced.
Dealing with Painter version drift
The Python API changes between Painter releases, and that is the main maintenance cost of any automation. MCP Pro for Painter includes tools to detect drift before it breaks a job:
get_painter_environment: Painter version, API version and environment details. Usepainter-cli probe envfrom the shell.run_smoke_tests: read-only checks withcategory: "readonly"that confirm the tools still work on this build. Usepainter-cli probe smoke --category readonly.dump_painter_apiandprobe_api_path: list what asubstance_paintermodule exposes, or check one attribute path such assubstance_painter.layerstack.insert_fill.snapshot_projectanddiff_project_snapshots: capture project state before and after a job to see exactly what changed.
Run the smoke tests after every Painter update. If a check fails, you know which tool to avoid until an update ships, rather than finding out halfway through a batch.
Which one should you use?
- Artists who want help without code: an MCP client with MCP Pro for Painter. Start with the Claude Code setup or the Cursor setup.
- Technical artists building repeatable exports:
painter-cliin a script, with sequences prototyped by the agent and saved as workflows. - Pipeline teams needing in-app UI or event hooks: a Python plugin, possibly alongside the CLI for headless jobs.
- Anything not covered by a tool:
execute_pythonfrom the agent, orpainter-cli raw python, both of which return the standard result envelope.