yade-mcp connects AI agents with YADE (the open-source Discrete Element Method engine) through the Model Context Protocol. Agents can browse the YADE API, run code in a live YADE session, launch long-running simulations as background tasks, and read what the user types in the YADE console.
Main capabilities
yade-mcp provides two types of documentation tools (no bridge required) and five execution tools (bridge required):
- Live REPL: execute Python inside a running YADE process; yade_execute_code runs in the session's own namespace, so state persists across calls; intermediate results can still be read while a task is running without stopping the simulation.
- Task lifecycle: submit scripts as background tasks, track their output, stop at iteration boundaries, modify and resubmit. Tasks are queued and run one at a time in order, so multi-stage pipelines can be arranged in a single submission.
- Cross-session task history: each task's script, output, and final state are preserved in records; a new agent session can list what has been run and continue the work.
- Console input can reach the agent: lines typed in the YADE console enter the agent's context on its next call, making it possible to work in the console and at the agent simultaneously.
- API documentation without a bridge: the class tree and BM25-based YADE Python API search work offline, and the corpus is refreshed according to the current YADE version.
- Multi-client: supports Claude Code, Codex CLI, Gemini CLI, GitHub Copilot CLI, OpenCode, toyoura-nagisa, and other MCP clients.
Example prompts
- "Set up a triaxial compression test on a dense packing and plot deviatoric stress versus axial strain"
- "Build an irregular particle as a horizontal collective and let it fall onto a plane"
- "The simulation is still running, check the unbalanced force, but do not stop it"
- "Look up how GlobalStiffnessTimeStepper chooses the time step, then add it to this model"
- "The command I just typed in the console errored, what went wrong?"
- "List what was run yesterday and summarize what each task produced"
Usage
First-time setup
Requires: uv installed (provides the uvx launcher that agent clients use to run yade-mcp; without it the client reports No such file or directory); an AI agent (Claude Code, Codex CLI, Gemini CLI, or any MCP-capable client).
Recommended agent setup flow:
-
Register the MCP server with your agent (choose the line corresponding to your client), or manually fill in the MCP configuration file.
-
Install the bridge into YADE's Python. YADE embeds a specific interpreter (Debian and Ubuntu packages use the system python3, or the interpreter it was built against). A conda or venv Python is a different interpreter, and packages installed there are not visible to YADE. The reliable method is to install inside YADE, where sys.executable is that interpreter. Execute in the YADE console.
Two problems may occur: No module named pip, meaning the interpreter has no pip, which can be installed with the system package manager, e.g. sudo apt install python3-pip; externally-managed-environment (Debian 12, Ubuntu 23.04 and later), where pip refuses --user by default, can be handled by adding "--break-system-packages" after --user in the above command.
Then exit and restart YADE to recognize the new package directory.
The bridge has been proposed for inclusion in YADE itself (yade-dev/trunk !1187). Once it ships with YADE, this step can be omitted, and the bridge is started via from yade import mcpbridge.
- Start the bridge in the YADE console. It will print a line: YADE MCP Bridge on http://localhost:9002, log: <cwd>/.yade-mcp/bridge.log.
Restart the AI agent and have it check whether it is connected to YADE. It will call yade_execute_code; ok: true in the response indicates that the entire chain is working properly.
After the initial setup is complete, each new YADE session only requires starting the bridge again (executed in the YADE console); the MCP client configuration will be retained.
Ports and Containers
The bridge listens on 9002 by default. To use a different port, pass it to start(). Unless otherwise specified, the MCP server connects to 9002, so a matching URL must be used when registering.
When YADE runs in a container, bind the bridge to all interfaces so it can be accessed from outside; publish that port when starting the container (for example, Docker uses -p 9002:9002).
Applicable Scenarios
Suitable for tasks that require driving YADE through natural conversation for discrete element simulation, such as setting up triaxial compression tests, constructing irregular particles, checking unbalanced forces during a simulation run, consulting the API to configure the time step, diagnosing console command errors, and reviewing and summarizing task records across sessions.
Limitations
Execution-type tools require the bridge, and the bridge must be manually installed into YADE's embedded interpreter and started; documentation tools do not require the bridge. Installation may encounter missing pip or externally-managed-environment issues, which must be handled as described above. Other feature details, fees, and pricing information are not currently provided.