max-ultra-mcp-community-skills

The tool without its window: the API

Every tool made with this skill has an API by default: the same operations its window offers, callable from MAXScript, from Python and by AI assistants through Max Ultra MCP, with no window open. Build it with the tool, not afterwards: the window is one caller of the API, scripts and assistants are others.

The parts

File What it does
python/mytool/max_api.py The scene work, on Max’s main thread only; pymxs lives here and nowhere else. Plain values in, plain data out (handles, names, counts); a change takes dry_run and runs in one undo record.
python/mytool/api.py The public operations: a table of name, function, summary, changes_scene, parameters (type, required, default, choices, limits, pattern, text) and an example; describe, call, call_json, call_from_maxscript.
python/api_entry.py Loads the package without the window: the same copy the window starts (bootstrap.pick_root), or the window’s own modules when it is open. Imports bootstrap.py with _MYTOOL_IMPORT_ONLY so it does not start a window.
MyToolAPI.ms Defines the MAXScript global MyToolAPI with call operation params:"{...}". StartMyTool.ms runs it first; a startup script may run it alone so the API is there from Max’s start. Nothing loads until the first call.

The starter’s operations are examples to replace: describe, scene_summary (read-only), add_prefix (changes names, with dry_run), get_settings and set_setting (the settings an assistant may touch, listed in PUBLIC_SETTINGS; a theme change shows at once in an open window).

Rules

Calling it

MyToolAPI.call "describe"
MyToolAPI.call "scene_summary" params:"{\"selection_only\": true}"
MyToolAPI.call "add_prefix" params:"{\"prefix\": \"SM_\", \"dry_run\": true}"
from mytool import api
api.call("add_prefix", prefix="SM_", dry_run=True)

An assistant with Max Ultra MCP runs the MAXScript lines through max_execute (or the Python through python.Execute), reads the JSON, and shows the user what a dry_run would change before it runs the real call.

In the trainer

The Windows section’s panel “Without the window (API)” shows the calls and three buttons (Describe, Scene Summary, a dry run of Add Prefix) that call the same API and print its JSON answer.

The API panel in the trainer

Checks

The trainer’s checks call describe, refuse an unknown operation, a missing parameter, an unknown parameter and a wrong value, read the scene, try add_prefix only with dry_run, read JSON in and out, call MyToolAPI.call through MAXScript (and put the owner’s MyToolAPI back), load api_entry.py without a new window session, and press the panel’s button. They never change settings or the scene through the API.

MaxPkg: MyToolAPI.ms, python/api_entry.py, python/mytool/api.py and python/mytool/max_api.py are runtime files; add them to the packager’s explicit file list (MaxPkg delivery).