ldraw-mcp

io.github.musharna由 GitHub 帳號 musharna 發布v0.3.1更新於 Oct 24, 2026

Render LDraw/LEGO models to images with real part geometry via headless Blender + ImportLDraw

已驗證STDIO僅桌面開發者工具媒體與設計

概覽

AI 產生的概覽

透過無介面的 Blender 將 LDraw/LEGO 模型檔案算繪成具有真實零件幾何的 PNG 圖片,並提供零件、顏色與物料清單查詢。

可以做什麼
此伺服器透過無介面的 Blender 與 ImportLDraw 外掛,將 LDraw 檔案(.ldr、.mpd、.dat)或內嵌 LDraw 文字算繪成 PNG 圖片,可依設定的方位角、解析度與取樣數產生並排拼接的多視角算繪圖。它也提供唯讀查詢工具:bill_of_materials 傳回零件、顏色與數量列,lookup_color 傳回顏色代碼、名稱、RGB、邊緣與透明度資料,search_parts 依查詢詞尋找資料庫中的零件。check_renderer 用於診斷 Blender、外掛與零件庫的設定。
適用情境
當助理需要檢視真實的 LEGO 模型而非幾何代理時使用,例如找出匯出模型中的旋轉矩陣交錯、懸浮板件或下陷窗戶等問題。也適合對 LDraw 檔案進行零件、顏色與物料清單的快速查詢。
執行需求
以本機 Python 套件執行(pypi ldraw-mcp,使用 uvx 啟動)。需要 PATH 中有 Blender 4.x,或將 LDRAW_MCP_BLENDER 指向其執行檔;需要 ImportLDraw 外掛,以及位於 ~/.ldraw 或 LDRAW_LIBRARY_PATH 的 LDraw 零件庫;ldraw-mcp-setup 會安裝外掛與零件庫,但不安裝 Blender。算繪使用 CPU 上的 Cycles,無需 GPU 或顯示器。三個查詢工具不需要 Blender。
安裝前請注意
算繪會將 Blender 作為本機程序執行,並從磁碟讀取模型檔案與零件庫;查詢工具為唯讀。未宣告身分驗證、API 金鑰或網路存取。安裝過程會從第三方下載 LDraw 零件庫與 ImportLDraw 外掛。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

ldraw-mcp

Give your MCP client eyes for LEGO® models.

Render LDraw files (.ldr / .mpd / .dat) to images with real part geometry — studs, slopes, window glass — using headless Blender and the ImportLDraw addon. The output looks like a BrickLink Stud.io render, with no GUI anywhere in the loop.

[PyPI] [Python] [License] [MCP] [CI] [Glama] [DOI]

[Two rendered views of a red LEGO car — real studs, transparent glass, rubber tires, steering wheel]

A ~90-line .ldr rendered front-left and rear-right — actual bricks, not a geometric proxy.


Point a vision-capable model at a build and it sees the actual bricks: crossed rotation matrices, floating plates, sunken windows — the kinds of export bugs a geometric proxy render will happily hide.

Quickstart

bash
# 1. installpip install ldraw-mcp
# 2. install the LDraw parts library + ImportLDraw addonldraw-mcp-setup
# 3. register with Claude Codeclaude mcp add ldraw -- ldraw-mcp

Then ask things like "render output/build.ldr and tell me what looks wrong" — the model sees the render, not just the text.

Blender is a prerequisite (see Requirements); it is not installed by ldraw-mcp-setup.

Tools

toolwhat it does
render_ldraw_file(path, azimuths="-60,120", resolution=640, samples=24)Render a model file to a PNG (multi-view, stitched side by side)
render_ldraw_text(ldr, azimuths="-60,120", resolution=640, samples=24)Render inline LDraw content without writing a file first
check_renderer()Diagnose the Blender / addon / parts-library setup
bill_of_materials(path="", ldr="")Part × colour × quantity rows for a model file or inline text
lookup_color(query)Colour code ↔ name / RGB / edge / alpha from LDConfig.ldr
search_parts(query, limit=50)Library parts whose description or file name contains query

azimuths is a comma-separated list of view angles in degrees; each is rendered and the views are stitched horizontally. Elevation is fixed at 22°. Higher samples = cleaner but slower.

The three query tools are read-only and need no Blender. bill_of_materials expands MPD sub-models (and sibling .ldr/.mpd files next to the model) with their multiplicity, and resolves colour 16 to the colour of the referencing line; colour 24 (edge) is reported as 24. It counts without a parts library — descriptions and colour names are then null. A colour code LDConfig.ldr does not define is listed under unknown_color_codes, a part the library lacks under parts_not_in_library; neither is dropped. A sub-model reference cycle is an error that names the cycle. lookup_color and search_parts need the library (ldraw-mcp-setup).

Requirements

  • Blender 4.x on PATH, or point LDRAW_MCP_BLENDER at the binary. Install it yourself (package manager, blender.org, or a local build); ldraw-mcp-setup does not install Blender.
  • ImportLDraw addon (io_scene_importldraw) in Blender's addons dir — installed by ldraw-mcp-setup.
  • LDraw parts library at ~/.ldraw (or LDRAW_LIBRARY_PATH) — installed by ldraw-mcp-setup.

Environment variables

varmeaning
LDRAW_MCP_BLENDERPath to the blender binary (overrides PATH lookup)
LDRAW_MCP_DISABLESet to 1 to force is_available() to False
LDRAW_LIBRARY_PATHPath to the LDraw parts library (community convention)

Manual setup

If ldraw-mcp-setup can't detect things automatically:

  • LDraw library: download complete.zip and unzip so that ~/.ldraw/parts/ exists.
  • ImportLDraw addon: download the latest release from TobyLobster/ImportLDraw and install it via Blender > Preferences > Add-ons > Install, or unzip into ~/.config/blender/<version>/scripts/addons/io_scene_importldraw/. (Launch Blender once first so the config directory exists.)

Troubleshooting

  • check_renderer says NOT FOUND: run ldraw-mcp-setup, or set the relevant env var above.
  • No GPU / WSL2 / containers: rendering uses Cycles on CPU, which works headless everywhere — no GPU or display needed. A ~150-part model takes a few seconds at the default 640px / 24 samples.
  • "no mesh objects imported": the addon couldn't resolve parts — usually a wrong or incomplete LDraw library path. Re-run setup or check LDRAW_LIBRARY_PATH.
  • Addon not enabled: the render script enables it automatically per run; if a manual Blender session complains, enable io_scene_importldraw in Preferences > Add-ons.

Provenance

This renderer was extracted from the prompt2brick project, where it started life as the vision critic's "see the actual model" path. prompt2brick keeps its own vendored copy of the render wrapper and Blender script, but this repo is the canonical source going forward — fixes and improvements to the renderer should land here first and be ported back into prompt2brick.

License

MIT — see LICENSE.


LEGO® is a trademark of the LEGO Group, which does not sponsor, authorize, or endorse this project. This tool is not affiliated with the LEGO Group, BrickLink, or the LDraw.org organization.

來源:README.md,提交 1f9b386

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

3
  1. v0.3.1最新Sep 23, 2026
  2. v0.3.0Sep 19, 2026
  3. v0.2.3Sep 16, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分