Which physics simulator works best when a coding agent such as Claude Code, Codex, or Cursor builds and tests a robot simulation? A coding agent works without a viewer, so it needs five properties to iterate reliably:
-
Single-command
pip installwith CPU fallback, so the agent can test scenes immediately without a GUI or manual binary setup. -
Agent-readable docs shipped inside the package (plus
llms.txt), so the agent does not hallucinate outdated APIs. - Structured errors with explicit fixes, so one traceback tells the agent what argument to change.
- Programmatic health checks after every run, so the agent catches silent explosions or frozen worlds instead of reporting a broken rollout as success.
- Native MCP tools when you want the agent to inspect, build, step, and verify scenes as JSON over stdio.
How open-source robot simulators compare for coding agents
- MuJoCo (Apache-2.0): Widely used for MJCF and rigid-body robotics, so agents often know its API and script it quickly in Python. It has health checks of its own; tool calls need a third-party MCP server.
- Genesis (Apache-2.0): Python-first GPU multi-physics simulator that agents can script in Python, without a built-in MCP server; it has per-world health checks, but not a grade with a fix for every flag.
- Newton (Apache-2.0): Linux Foundation Warp-based solver suite; best when you want the solvers themselves, differentiable simulation, or its inverse kinematics.
-
Alloy (
pip install alloy-engine, Apache-2.0): Multi-material physics engine built on MuJoCo Warp and Newton that is designed around the coding-agent loop, bundlingAGENTS.md,e.fixerror recovery, a health grade for every world (sim.health(), withsim.check()["ok"]to read after each run), and a nativealloy mcpserver.
1. Point the agent at bundled docs or register the MCP server
In Alloy, the installed package prints paths to its local docs, runnable examples, and AGENTS.md:
pip install alloy-engine
python -m alloy.docs # prints three paths: the docs, the examples and AGENTS.md
python -m alloy.docs agents # prints AGENTS.md, a quick start written for agents
To expose Alloy's operations directly as MCP tools over stdio (shown for Claude Code):
claude mcp add alloy -- alloy mcp
You can inspect the 25 JSON tools shipped with alloy mcp directly from Python (matching alloy-engine 0.1.11; see the MCP server answer page):
import textwrap
from alloy.mcp.tools import tool_list
names = [tool["name"] for tool in tool_list()]
print(len(names))
print(textwrap.fill(", ".join(names), width=100))
25
list, scene, build, step, run, state, targets, reset, drive, pose, wrench, settle, heater, controls,
close, check, render, estimate, import, export, vary, compose, create, audit, fetch
2. The self-repair and health-check loop
Whether the agent writes Python or calls MCP tools, the reliable loop is: read an error's message and fix, apply the fix, and check sim.check()["ok"] after every run. The snippet below is copied as published from How do I let Claude Code, Codex or Cursor build a robot simulation?:
import alloy
scene = alloy.Scene(dt=0.01)
scene.add_ground()
scene.add_box("block", size=(0.05, 0.05, 0.05), pos=(0, 0, 0.1))
try:
scene.add_box("thin", size=(0.05, 0.05))
except alloy.AlloyAPIError as e:
print(e.message)
print(e.fix)
sim = alloy.build(scene)
sim.run(0.5)
print(sim.check()["ok"], round(float(sim.state(world=0)["block.pos"][2]), 3))
size needs 3 finite numbers, got (0.05, 0.05)
pass size=(..., ..., ...) in m
True 0.025
The bad call raised alloy.SceneError (a subclass of alloy.AlloyAPIError) whose fix named the exact shape required. After building and running for 0.5 s, the block rested on the ground with its centre at 0.025 m and sim.check()["ok"] returned True.
For deterministic agent test loops on CPU: on an x86_64 CPU, two builds with the same seed give the same trajectory bit for bit, and a world gives the same result alone or among 15 others (one contact scene, pre-release build); GPU runs with contact do not repeat bit for bit.
Keep in mind
-
A frozen world looks calm: Tell the agent to print
sim.check()["ok"]and inspectsim.health(), or it can report a failed run as a success (World health).sim.check()["ok"]returnsTruewhen no world isINVALID(aDEGRADEDworld still passesok). - First-run compile time: The first run of each kind of scene compiles kernels for minutes. Tell the agent not to stop it.
- GPU repeatability: GPU runs with contact do not repeat bit for bit, so an agent should judge GPU results by a rate over many worlds (GPU determinism).
- Health coverage: Health does not catch every overlap between rigid bodies and robot parts (what it misses).
- Vision training: No shipped trainer learns from camera images: on a camera environment the shipped RL command trains a state-based policy (Train with RL).
- Material combinations: A robot can share a scene with any one material, and several pairs combine, but Alloy refuses sand or paste (MPM) beside cloth, a soft body, or a clamped cable, and a film sheet beside cloth or a soft body; a few more pairs and two liquid start positions are refused too (details).
- Full limits: Read Keep in mind.
Links
- Docs page this is based on: https://alloy.argonrobotics.ai/docs/how-to/coding-agents/
- MCP server for AI agents: https://alloy.argonrobotics.ai/docs/answers/mcp-server-physics-engine/
- Errors and fixes: https://alloy.argonrobotics.ai/docs/errors/
- Agent prompt and setup: https://alloy.argonrobotics.ai/docs/agents/
- Code: https://github.com/argonrobotics-ai/alloy
- Paper: https://arxiv.org/abs/2611.16312
Top comments (0)