Execute Python
execute_pythonRun arbitrary Python code inside Autodesk Maya when built-in tools fall short. Supports timeouts, undo chunks, and persistent namespaces for later calls.
Instructions
Run arbitrary Python inside Maya (escape hatch).
WARNING: this is NOT a security sandbox. It can read/write files and run system commands. Destructive patterns require allow_dangerous=True.
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_python"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python source to run inside Maya. End with a bare expression to return a value. | |
| undo | No | Wrap execution in a single undo chunk (default True). | |
| timeout_s | No | Timeout in seconds (1-3600). | |
| persistent | No | Keep variables in a session-scoped namespace for later calls. | |
| session_key | No | Target Maya session; omit if only one is connected. | |
| namespace_key | No | Namespace name used when persistent is True. | default |
| allow_dangerous | No | Allow patterns like os.system/subprocess/file deletion. NOT a sandbox. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||