YADE MCP Server

io.github.yusong652由 GitHub 帳號 yusong652 發布v0.11.2更新於 Oct 30, 2026

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

概覽

AI 產生的概覽

把 AI 助理連接到開源離散元素引擎 YADE:瀏覽其 Python API 文件,並在執行中的 YADE 工作階段裡跑模擬。

可以做什麼
  • 瀏覽並以關鍵字搜尋 YADE Python API 的類別樹與文件,可離線使用、不需橋接服務
  • 在執行中的 YADE 行程裡同步執行 Python 程式碼,呼叫之間狀態會保留
  • 把模擬腳本當成背景任務提交,查看狀態與輸出、列出任務歷史、中斷或取消任務
  • 讀取 YADE 行程的執行期脈絡,包括主控台歷史與模擬狀態
適用情境
適合在建置或除錯 YADE 離散元素模型時使用:讓助理查閱 API 類別、執行建模程式碼、在背景啟動長時間模擬,並在不中斷模擬的情況下查看結果。
執行需求
透過 uvx 在本機執行(需安裝 uv),並需要已安裝 YADE。執行類工具還要把 yade-mcp-bridge 安裝到 YADE 自帶的 Python 解譯器中,並在 YADE 主控台啟動橋接服務,預設監聽 localhost 的 9002 埠;改用其他埠時以 --bridge-url 指定。文件類工具不需橋接服務。
安裝前請注意
執行類工具會在你執行中的 YADE 行程裡執行任意 Python 程式碼,且副作用會持續保留,可能變更或刪除模擬狀態與檔案。橋接服務是 HTTP 服務,為容器情境綁定到所有網路介面會使它暴露在 localhost 之外。任務腳本、輸出與主控台歷史會被留存並傳給助理。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 YADE MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

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.

來源:README.md,提交 613a243

工具

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.

輸入參數path

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

輸入參數limitquery必填

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().

輸入參數description必填script_path必填

yade_check_task_status

Yade Check Task Status

Check status and output for a submitted YADE task.

輸入參數limitfiltertask_id必填skip_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.

輸入參數limitskip_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.

輸入參數task_id必填

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

輸入參數code必填timeout

版本歷史

2
  1. v0.11.2最新Oct 22, 2026
  2. v0.1.5Sep 16, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分