Skip to main content
Glama

ldraw-mpd-mcp

CI License: MIT Node.js >=20 MCP Compatible

A zero-native-dependency Model Context Protocol (MCP) server for building, 3D-rendering, visually verifying, and offline-packing LEGO® LDraw (.ldr / .mpd) models step-by-step with AI coding agents.

Everything — the Z-buffered 2×-supersampled isometric 3D rasterizer, PNG encoder/decoder/stitcher, DFS building-step engine, sub-build isolator, offline .mpd bundler, and official LDraw library installer — runs in pure TypeScript/Node.js with no Blender, LDView, OpenGL, Python, or native C++ build dependencies.


How It Works

flowchart LR
    A[Instruction Image] --> B[ldraw_lookup_part & ldraw_inspect_part]
    B --> C[Write Step N in .ldr / .mpd]
    C --> D[ldraw_render_step / ldraw_verify_step]
    D -- FAIL + Side-by-Side PNG --> C
    D -- PASS (Text-Only JSON) --> E{More Steps?}
    E -- Yes --> B
    E -- No --> F[ldraw_pack_mpd -> 100% Offline .mpd]

Related MCP server: dxf-cad-mcp

Features

  • Pure-TS 3D Software Renderer (ldraw_render_step, ldraw_inspect_part) — 2× SSAA Z-buffered rasterizer with edge lines, alpha transparency, optional +X / -Y Up / +Z axis gizmos, step-fade highlighting, and side-by-side reference PNG stitching.

  • Exact Three.js LDrawLoader Step Order + Sub-Build Isolation — DFS global step numbering across 0 FILE <submodel>.ldr blocks with automatic Sub-Build Focus Mode and step_join.dat incorporation markers.

  • 100% Offline Self-Contained MPD Packer (ldraw_pack_mpd) — Recursively inlines LDConfig.ldr 0 !COLOUR headers and every referenced .dat, parts/s/*.dat, p/*.dat, and p/48/*.dat primitive into a single portable .mpd file.

  • Generic LDraw Search + Optional Set Catalog (ldraw_lookup_part) — Works out-of-the-box against your entire local LDraw library (parts.lst / parts/*.dat), and optionally loads a custom JSON BOM catalog (LDRAW_CATALOG_PATH) for set-specific builds.

  • Independent Vision QA Judge (ldraw_verify_step) — Optional step-by-step visual QA using Gemini or any OpenAI-compatible vision API. Returns compact JSON only (zero images) on PASS to keep agent context clean, and returns LDU discrepancies + a side-by-side PNG on FAIL.

  • One-Command Official LDraw Setup (setup) — Automatically downloads and extracts the official LDraw Parts Library (complete.zip) from library.ldraw.org into ~/.ldraw, or auto-detects an existing BrickLink Studio 2.0 / LDraw installation.


Quick Start

1. Get the LDraw Parts Library (.dat files)

This package does not bundle .dat part files. Choose either option:

  • Option A — One-command download from LDraw.org (recommended):

    npx ldraw-mpd-mcp setup
    # Optional: include unofficial LDraw parts too
    npx ldraw-mpd-mcp setup --unofficial

    Downloads the official complete.zip (~75 MB) from library.ldraw.org and extracts it to ~/.ldraw.

  • Option B — Use an existing BrickLink Studio 2.0 / LDraw install: ldraw-mpd-mcp automatically searches LDRAW_DIR, ~/.ldraw, BrickLink Studio 2.0 default directories (C:/Program Files/Studio 2.0/ldraw, /Applications/Studio 2.0/ldraw), and standard system LDraw paths.

Verify detection anytime with:

npx ldraw-mpd-mcp doctor

2. Configure Your MCP Client

Add ldraw-mpd-mcp to your MCP client config (Claude Desktop, Cursor, Claude Code, Antigravity, etc.):

{
  "mcpServers": {
    "ldraw-mpd-mcp": {
      "command": "npx",
      "args": ["-y", "ldraw-mpd-mcp"],
      "env": {
        "LDRAW_DIR": "/path/to/your/ldraw",
        "GEMINI_API_KEY": "optional-for-ldraw_verify_step"
      }
    }
  }
}

Tip: LDRAW_DIR is optional if you ran npx ldraw-mpd-mcp setup (installs to ~/.ldraw) or installed BrickLink Studio 2.0 in its default location. GEMINI_API_KEY is only needed if you use ldraw_verify_step — the other 5 tools work 100% offline with zero API keys.


MCP Tools

Tool

Description

ldraw_library_status

Reports detected LDRAW_DIR, color table source (LDConfig.ldr), catalog mode, and vision verifier status.

ldraw_lookup_part

Searches parts by keyword, colour, or category across a custom set BOM catalog (LDRAW_CATALOG_PATH) or the full local LDraw library.

ldraw_inspect_part

Renders a single .dat part at a given color & 3×3 matrix with +X (Red), -Y Up (Green), and +Z (Blue) axis arrows plus its world bounding box in LDU.

ldraw_render_step

Renders an .ldr / .mpd file up to stepNumber into a 2×-supersampled PNG, optionally stitched side-by-side with a reference instruction PNG.

ldraw_verify_step

Runs an independent Vision LLM QA check comparing a rendered step against a reference instruction image. Returns text-only JSON on PASS or discrepancy diagnostics + side-by-side PNG on FAIL.

ldraw_pack_mpd

Packs an .ldr / .mpd file with 0 !COLOUR definitions and all recursively referenced parts/subparts/primitives into a 100% offline .mpd.


Configuration & Environment Variables

Variable

CLI Flag

Description

LDRAW_DIR

--ldraw-dir

Path to local LDraw library containing parts/, p/, and LDConfig.ldr.

LDRAW_CATALOG_PATH

--catalog

Optional path to a custom JSON BOM catalog (array of part objects with datFile, ldrawDescription, optional colour, ldrawColorCode, bbox, studs, holes).

GEMINI_API_KEY

—

API key for ldraw_verify_step using Google Gemini (default model: gemini-2.5-flash).

OPENAI_API_KEY

—

API key for ldraw_verify_step with OpenAI or any OpenAI-compatible vision endpoint.

LDRAW_VISION_PROVIDER

—

gemini (default) or openai.

LDRAW_VISION_MODEL

—

Override the vision QA model (e.g. gemini-2.5-pro, gpt-4o).

LDRAW_VISION_BASE_URL

—

Custom OpenAI-compatible base URL (e.g. LiteLLM, OpenRouter, Ollama).


Bundled Agent Skill

A ready-to-use agent workflow guide (coordinate conventions, 3×3 rotation matrices, Sub-Build Isolation pattern, and verification loop) is included in skills/ldraw-mpd-maker/SKILL.md.


Development & Publishing

npm install
npm run typecheck
npm test
npm run pack:check
  • CI: Every push and PR runs typechecking, full unit + MCP end-to-end tests, LF shebang verification, tarball inspection across Ubuntu/macOS/Windows on Node 20 & 22, plus npm audit.

  • CD: Pushing a v*.*.* tag triggers .github/workflows/release.yml, which verifies tag/version parity, smoke-tests the packed tarball in a clean install, publishes to npm with --provenance, and creates a GitHub Release. See CONTRIBUTING.md and CHANGELOG.md.


  • Code: MIT License.

  • LDraw Parts Library: Parts downloaded via setup are sourced directly from LDraw.org and are licensed under CC BY 4.0 by the LDraw.org contributors.

  • Disclaimer: LEGO® is a trademark of the LEGO Group of companies, which does not sponsor, authorize, or endorse this project. BrickLink® and Studio are trademarks of BrickLink Limited.

Available Tools

6 tools
ldraw_inspect_partA

Inspect a single LDraw .dat part at a given color and 3x3 rotation matrix. Returns its transformed LDU bounding box and a 2x-supersampled isometric 3D PNG with +X (Red), -Y Up (Green), and +Z (Blue) axis arrows.

Inputs: datFile (required), matrix, yawDeg, pitchDeg, +1 more.

ldraw_library_statusA

Inspect the active LDraw parts library path, color table source, optional set catalog, and vision verifier configuration.

Inputs: no named parameters.

ldraw_lookup_partB

Search LEGO parts in the configured set catalog (if LDRAW_CATALOG_PATH is set) or across the entire local LDraw parts library by keyword, colour, or category.

Inputs: limit, query, colour, source, +1 more.

ldraw_pack_mpdA

Bundle an LDraw .ldr/.mpd file with LDConfig.ldr colours and all recursively referenced .dat parts/subparts/primitives into a single 100% offline-ready .mpd file compatible with Three.js LDrawLoader.

Inputs: inputLdrPath (required), outputMpdPath (required).

ldraw_render_stepA

Render an LDraw .ldr or .mpd model up to a specific stepNumber into a 2x-supersampled 3D isometric PNG with bounding-box diagnostics, optional side-by-side reference stitching, and Sub-Build Isolation (0 FILE <submodel>.ldr).

Inputs: yawDeg, ldrPath, pitchDeg, showAxes, +7 more.

ldraw_verify_stepA

Independently verify an LDraw step against a reference instruction image using a configured Vision LLM (Gemini or OpenAI-compatible). Returns compact JSON on PASS (zero image bloat) or LDU discrepancy diagnosis + side-by-side PNG on FAIL.

Inputs: stepNumber (required), instructionImagePath (required), yawDeg, ldrPath, +5 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool targets a distinct stage of the workflow: config inspection, catalog search, single-part spec inspection, packing, model rendering, and vision-based verification. The only mild overlap is ldraw_inspect_part vs ldraw_render_step, since both emit isometric PNGs, but their scope (single .dat part vs multi-step model) is clearly stated.

    Naming Consistency4/5

    All six tools share the ldraw_ prefix and snake_case, with a clear verb_noun pattern (pack_mpd, lookup_part, inspect_part, render_step, verify_step). ldraw_library_status is a noun-phrase outlier, but it reads naturally as a status query and does not break the scheme.

    Tool Count4/5

    Six tools is a tight, well-scoped set covering the stated purpose of inspecting, packing, rendering, and verifying LDraw files. It is on the lean side—no file-assembly or step-enumeration tool—but nothing feels redundant.

    Completeness4/5

    The surface covers a solid pipeline: library check -> part lookup -> part inspect -> pack -> render -> verify. Minor gaps exist, such as listing/extracting the individual steps or sub-builds of an MPD, or writing/editing an MPD, which agents would have to work around externally.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI assistants to render 3D models by providing tools to execute OpenSCAD code and generate single or multi-perspective views. It returns high-quality PNG renderings directly to LLM applications for visual feedback and 3D model visualization.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to create, inspect, render, and export 2D engineering drawings through DXF files, including entities, dimensions, hatches, splines, blocks, layers, PNG previews, and vector PDFs without needing a CAD GUI.
      11
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents to create, edit, and analyze CAD drawings either live through AutoCAD COM on Windows or headlessly via ezdxf anywhere, drawing mechanical parts, architectural plans, and P&IDs with ISO standard layers, dimensions, fits, and title blocks. It also reads existing drawings back for critique, diffing, scale checks, topology checks, and bill-of-material takeoffs to Excel or CSV.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI coding agents to turn natural-language descriptions and dimensional sketches into validated, watertight 3D-printable STL files by compiling build123d scripts, inspecting meshes, and rendering deterministic multiview previews.
      MIT