YADE MCP Server

io.github.yusong652Published by GitHub account yusong652v0.11.2Updated Oct 30, 2026

MCP server for YADE — open-source DEM engine. Browse API docs, run simulations, manage tasks.

Overview

AI-generated overview

Connects an AI assistant to YADE, the open-source DEM engine: browse its Python API docs and run simulations in a live YADE session.

What you can do
  • Browse and keyword-search the YADE Python API class tree and documentation, offline and without a bridge
  • Run Python synchronously in the live YADE process, with state persisting between calls
  • Submit simulation scripts as background tasks, check status and output, list task history, and interrupt or cancel tasks
  • Read runtime context from the YADE process, including console history and simulation status
When to use it
Useful when you build or debug YADE discrete element method models and want an assistant to look up API classes, run setup code, launch long simulations in the background, and inspect results without stopping a running simulation.
Requirements
Runs locally via uvx (uv must be installed) and needs a YADE installation. Execution tools require the yade-mcp-bridge package installed into YADE's own Python interpreter and the bridge started inside the YADE console, by default on localhost port 9002; a different port is passed with --bridge-url. Documentation tools work without the bridge.
Before you install
Execution tools run arbitrary Python inside your live YADE process, and side effects persist between calls, so code can modify or delete simulation state and files. The bridge is an HTTP service; binding it to all interfaces for containers exposes it beyond localhost. Task scripts, output and console history are kept on record and passed to the assistant.

Installation

In SourceWeft

  1. Open YADE MCP Server in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

yade-mcp

[yade-mcp header]

English | 简体中文

[PyPI] [Downloads] [GitHub stars] [Glama] [License: MIT] [Python 3.10+]

O.engines += [LLM()] # yet another engine.

yade-mcp connects AI agents to YADE, the open-source discrete element method engine, through the Model Context Protocol. The agent browses the YADE API, runs code in a live YADE session, launches long simulations as background tasks, and reads what you type at the YADE console.

[yade-mcp demo]

Tools (7)

Two documentation tools (no bridge needed) and five execution tools (bridge required):

ToolPurposeBridge
yade_browse_apiWalk the YADE Python class treeNo
yade_query_apiBM25 keyword search across the APINo
yade_execute_codeRun Python in the live YADE process; returns synchronouslyYes
yade_execute_taskSubmit a script as a long-running background taskYes
yade_check_task_statusInspect a running or finished task (output, status)Yes
yade_interrupt_taskStop a running task at an iteration boundary, or cancel a queued oneYes
yade_list_tasksList submitted tasks with metadataYes

Example Prompts

  • "Set up a triaxial compression test on a dense packing and plot deviatoric stress against axial strain"
  • "Build an irregular particle as a level set body and drop it onto a plane"
  • "The simulation is still running, check the unbalanced force without stopping it"
  • "Look up how GlobalStiffnessTimeStepper picks the timestep, then add it to this model"
  • "The command I just typed in the console raised an error, what went wrong?"
  • "List what was run yesterday and summarize what each task produced"

First-time Setup

Prerequisites

  • YADE installed
  • uv installed. It provides the uvx launcher that agent clients use to run yade-mcp; without it the client reports No such file or directory when starting the server.
  • An AI agent: Claude Code, Codex CLI, Gemini CLI, or any MCP-capable client

Agentic Setup (Recommended)

Copy this to your AI agent and let it self-configure:

text
Fetch and follow this bootstrap guide end-to-end:https://raw.githubusercontent.com/yusong652/yade-mcp/master/docs/agentic/yade-mcp-bootstrap.md

Manual Setup

1. Register the MCP server with your agent (use the line for yours):

bash
# Claude Codeclaude mcp add yade-mcp -- uvx yade-mcp
# Codex CLIcodex mcp add yade-mcp -- uvx yade-mcp
# Gemini CLIgemini mcp add yade-mcp uvx yade-mcp

Or fill in the MCP config file by hand:

json
{  "mcpServers": {    "yade-mcp": {      "command": "uvx",      "args": ["yade-mcp"]    }  }}

2. Install the bridge into YADE's Python.

YADE embeds one specific interpreter (the system python3 for the Debian and Ubuntu packages, or the one it was built against). A conda or venv Python is a different interpreter, and a package installed there is invisible to YADE. The reliable way to hit the right one is to install from inside YADE, where sys.executable is that interpreter. In the YADE console:

python
import sys, subprocesssubprocess.check_call([sys.executable, "-m", "pip", "install", "--user", "yade-mcp-bridge"])

Two things can go wrong here:

  • No module named pip: the interpreter has no pip. Install it with the system package manager, for example sudo apt install python3-pip.
  • externally-managed-environment (Debian 12, Ubuntu 23.04 and later): pip refuses --user by default. Add "--break-system-packages" after "--user" in the command above.

Then exit and restart YADE so the new package directory is picked up.

The bridge is proposed for inclusion in YADE itself (yade-dev/trunk !1187). Once it ships with YADE, this step goes away and the bridge starts with from yade import mcpbridge.

3. Start the bridge in the YADE console:

python
import yade_mcp_bridgeyade_mcp_bridge.start()

It prints one line: YADE MCP Bridge on http://localhost:9002, log: <cwd>/.yade-mcp/bridge.log.

Verify

Restart your AI agent and ask it to check that it is connected to YADE. It calls yade_execute_code; ok: true in the response means the whole chain works.

Daily Startup

Once first-time setup is done, each new YADE session only needs the bridge started again. In the YADE console:

python
import yade_mcp_bridgeyade_mcp_bridge.start()

The MCP client config persists.

Configuration

Port

The bridge listens on 9002 by default. To use another port, pass it to start():

python
yade_mcp_bridge.start(port=9008)

The MCP server connects to 9002 unless told otherwise, so register it with the matching URL:

json
{  "mcpServers": {    "yade-mcp": {      "command": "uvx",      "args": ["yade-mcp", "--bridge-url", "http://localhost:9008"]    }  }}

Container

When YADE runs inside a container, bind the bridge to all interfaces so it is reachable from outside:

python
yade_mcp_bridge.start(host="0.0.0.0")

Publish the port when starting the container (for Docker, -p 9002:9002).

Features

  • Live REPL in the running YADE process: yade_execute_code runs Python in the session's own namespace, so state persists between calls. It keeps working while a task runs, for reading intermediate results without stopping the simulation.
  • Task lifecycle: submit a script as a background task, tail its output, stop it at an iteration boundary, fix and resubmit. Tasks queue up and run one at a time, so a multi-stage pipeline can be submitted in one go.
  • Task history across sessions: every task's script, output, and final state stay on record. A new agent session lists what was run and picks up without being told.
  • Console input reaches the agent: lines you type at the YADE console arrive in the agent's context on its next call, so you can work at the console and with the agent at the same time.
  • API documentation without a bridge: the class tree and a BM25 search over the YADE Python API work offline, from a corpus refreshed against current YADE releases.
  • Multi-client: works with Claude Code, Codex CLI, Gemini CLI, GitHub Copilot CLI, OpenCode, toyoura-nagisa, and other MCP clients.

Troubleshooting

See Troubleshooting in the bootstrap guide.

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT, see LICENSE.

Source: README.md at commit 613a243

Tools

7

yade_browse_api

Yade Browse Api

Browse YADE's Python API as a YADE-native class tree. The tree is rooted in YADE's real inheritance hierarchy: paths mirror the class's __mro__ up to its category root. No shortcuts — always drill through parents.

Parameterspath

yade_query_api

Yade Query Api

Search YADE API documentation by keywords (like grep). Returns matching class/function names with descriptions ranked by relevance. Use yade_browse_api for full documentation of a specific class. When to use: - You have keywords but don't know the exact class name - Examples: "friction material", "gravity engine", "contact force", "triaxial stress", "sphere create", "hertz mindlin" Related tools: - yade_browse_api: Get full documentation for a known class path

Parameterslimitqueryrequired

yade_execute_task

Yade Execute Task

Submit a Python script for asynchronous execution in YADE. Returns a task_id immediately; the script is queued and runs in the background. Tasks run one at a time in submit order (they share the YADE process and its single simulation state), so a multi-stage pipeline can be submitted in one go — each stage starts when the previous one finishes. Use the companion tools to manage the task lifecycle: - yade_check_task_status: poll output, progress, and final status - yade_interrupt_task: stop a running task or cancel a queued one - yade_list_tasks: browse task history (also shows queue order) Use this for production simulation runs, long O.run() cycles, and any operation that may take minutes or longer. For quick queries and REPL-style testing, use yade_execute_code. O.engines[0] holds a PyRunner that belongs to yade-mcp-bridge (its command mentions "mcp bridge"). The script does not need to keep it: assign O.engines as usual, the bridge re-adds the PyRunner before every O.run().

Parametersdescriptionrequiredscript_pathrequired

yade_check_task_status

Yade Check Task Status

Check status and output for a submitted YADE task.

Parameterslimitfiltertask_idrequiredskip_newestwait_seconds

yade_list_tasks

Yade List Tasks

List tracked YADE tasks with pagination. Tasks are listed newest first. Queued (pending) tasks run one at a time in submit order, so among the pending entries the one furthest down the list runs next.

Parameterslimitskip_newest

yade_interrupt_task

Yade Interrupt Task

Stop a running YADE task, or cancel one still waiting in the queue. A task that has not started yet is simply removed from the queue and ends in status ``canceled`` (``method`` reports ``canceled_while_queued``). For a running task, two cancellation paths are applied together by the bridge: - ``flag_only`` — sets an interrupt flag that YADE's PyRunner tick observes between simulation iterations (graceful path for ``O.run`` tasks). - ``flag_and_async_exc`` — in addition, injects a ``TaskInterrupt`` exception into the script thread, so pure-Python deadloops with no ``O.run`` on the stack are terminated too. The response ``method`` field reports which path ran. When async-exc is refused (e.g. target thread is a Dummy-N boost::python frame), ``async_exc_skipped_reason`` explains why. Namespace after interrupt: the YADE ``__main__`` namespace is shared between tasks and ``yade_execute_code`` calls. Any variables the interrupted script had already defined — including ``O`` state — are preserved. There's no need to re-run the whole script to continue work: inspect state with ``yade_execute_code`` or resume via a fresh ``yade_execute_task`` that only runs the remaining logic.

Parameterstask_idrequired

yade_execute_code

Yade Execute Code

Execute Python code synchronously in the running YADE process. Returns stdout immediately. Code runs in the YADE Python environment where yade modules are already imported; side effects persist. This tool remains responsive EVEN WHILE a simulation task is running (submitted via yade_execute_task). Use it as a live REPL to inspect simulation state in real time — no need to pre-script print statements. Typical uses: - Query simulation state: O.bodies count, current iteration - Create/modify bodies, engines, interactions - Read or set material properties - Live inspection during a running simulation (e.g. check stress tensor, coordination number, energy balance, or capture viewport screenshots when GUI is available) - Development and REPL-style testing O.engines[0] holds a PyRunner that belongs to yade-mcp-bridge (its command mentions "mcp bridge"). Ignore it: assign O.engines as usual, the bridge re-adds the PyRunner before every O.run(). Unlike yade_execute_task, this tool is fire-and-return: the response contains the full output. It is NOT tracked by yade_list_tasks and cannot be interrupted or polled. Timeout behaviour: on timeout the bridge attempts to abort the running code. The response is an error envelope (``ok=false``) whose ``error.code`` is one of: - ``interrupted`` — the code was running a simulation cycle (``O.run``) and was paused cleanly at an iteration boundary. For long simulations or solving to equilibrium, switch to yade_execute_task — it tracks progress and stops cleanly via yade_interrupt_task. - ``terminated`` — a non-cycle abort succeeded (async exception injection); the pump thread is free, but YADE state may be partially modified by the code that ran before the abort fired. Inspect state before retrying. - ``timeout`` — abort failed (code stuck in a C extension, or nested inside a running task's PyRunner tick); the bridge may still be blocked. Restart if unresponsive. WARNING: For anything expected to take more th

Parameterscoderequiredtimeout

Version history

2
  1. v0.11.2LatestOct 22, 2026
  2. v0.1.5Sep 16, 2026

Score

90% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts
  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listedRequired15 pts
  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts