execute_script
Run Python inside Omniverse Kit apps on the main thread to perform tasks no dedicated tool covers and return serialisable results, output, or errors.
Instructions
Run Python inside the Kit app (Isaac Sim, USD Composer, ...) on its main thread, for what no tool does.
Prefer a tool that does the job: it checks its input and bounds its waits. The script has omni, carb, Usd, UsdGeom, UsdLux, UsdPhysics, Sdf, Gf and mcp. Assign to 'result' to return JSON-serialisable data (anything else comes back as its str); stdout and stderr come back too, and an exception as an error with the traceback's last lines. A script that blocks freezes Kit: the call gives up after 120 s, and the script runs on. For work that may outlast 120 s, such as settling many objects under physics, use run_script_job: it runs as a job while Kit renders and other tools answer, and get_job reads its progress and result.
mcp calls the tools' handlers from the script, each returning a dict with "status" and "result". Await them,
which makes the script async: bounds = await mcp.prim_bounds("/World/Cube"), then
result = bounds["result"]. Its methods: capture_viewport(width, height, camera_path), set_camera(position,
target), look_at(prim_path, distance, azimuth, elevation), inspect(prim_path, angles, width, height,
zoom_offset=0.0, isolate=False), scene_tree(root, max_depth), prim_properties(prim_path),
prim_bounds(prim_path), set_transform(prim_path, position, rotation, scale), create_prim(prim_path, prim_type,
**kwargs), delete_prim(prim_path), set_material(prim_path, color, opacity, roughness, metallic),
sim_control(action), sim_state(), get_logs(count, min_level, channel, search).
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_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python to run inside the Kit app; assign to result to return data |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |