Skip to main content
Glama

brickbuilder-mcp

Show Claude a photo, get a buildable LEGO model back.

An MCP server that lets Claude design LEGO models brick by brick, usually from a reference picture, check that they actually hold together, and export them as LDraw .ldr files that Mecabricks and BrickLink Studio open directly.

Reference still of Helm's Deep next to the 41,864-part LEGO build

What it looks like

Every build below was made by Claude through this server from the photo on the left. Nothing was placed by hand.

Airliner cabin: reference photo and LEGO build

Bowling alley: reference photo and LEGO build

The models are real, buildable LEGO: standard parts in real colours, bricks laid in staggered courses, and a connectivity check that flags anything floating before export.

Related MCP server: SolidWorks MCP Server

Setup

Needs Python 3.11+, uv, curl and unzip.

git clone https://github.com/ElRashoMacuin24/brickbuilder-mcp.git
cd brickbuilder-mcp
scripts/fetch_ldraw.sh   # downloads the LDraw parts library (~145 MB zip) into data/ldraw
uv sync
claude mcp add brickbuilder -s user -- uv --directory "$PWD" run brickbuilder-mcp

Restart Claude Code, then run /mcp and check that brickbuilder is listed. Other MCP clients work too: run uv --directory /path/to/brickbuilder-mcp run brickbuilder-mcp over stdio.

How to use it

1. Give Claude a picture and a goal

Paste or drag an image into Claude Code (or give a path) and say what you want. The more you say about scale, the better:

Build this scene in LEGO without the people. Make it minifig scale, so the chairs are just big enough for a minifig to sit in.

Build this house in LEGO, about 16 studs wide: ~/Pictures/house.jpg

Make a 48×48 flat mosaic of this logo: ~/Pictures/logo.png

Useful things to specify:

  • Scale: "minifig scale" (doors, seats and stairs sized for minifigures), "microscale", or a size in studs ("about 32 studs wide").

  • What to leave out: people, background, text.

  • Colours: "use only common colours" keeps it cheap to build for real.

2. Let it work, then steer

Claude plans the scale, builds bottom-up, renders previews next to your photo and fixes what doesn't match. Ask for changes in plain language:

The orange is too brown, use a redder shade. Make the tower taller and add windows. The left rack is hidden behind the bench, move it.

3. Export and open it

When you're happy, ask Claude to export. The file lands in exports/<name>.ldr.

  • Mecabricks: Workshop → File → Import → LDraw, then pick the file. You can publish it to the Mecabricks gallery from there.

  • BrickLink Studio: File → Import → Import LDraw. Studio also gives you a parts list and prices to buy the bricks. It handles very large models better than a browser tab.

If Mecabricks shows missing parts, ask Claude to re-export with legacy_ids (older part numbers such as 3023 instead of 3023b).

4. Pick it up later, on any computer

Models autosave to models/<name>.json. Say "open the bowling alley model" in a later session to keep editing. Copy models/ and exports/ to another machine to take your builds with you.

Tools

Tool

Purpose

new_model / open_model / list_models

Models autosave to models/*.json

list_parts, list_colors

Curated catalog, full LDraw library search, colour codes

add_parts, remove_parts, undo

Place parts on the stud grid, with collision checks

fill_layers

Colour layer maps packed automatically into bricks/plates/tiles in running bond

image_to_grid, build_mosaic

Quantize pictures to LEGO colours; build mosaics

describe_model, check_model

Per-level maps, part counts, floating/loose-part detection

render_model

Preview sheet (iso/front/top/etc.), optionally beside the reference picture

export_ldr

LDraw file, one build step per level; legacy_ids for older part numbers

Grid

  • x: studs to the right; z: studs toward the back (z=0 is the front); y: plates up (brick = 3).

  • A part's position is the min corner of its body after rotation.

  • rot 0/90/180/270 (or front/right/back/left). A slope's sloped face points that way. At rot 0 a 2x4 brick is 4 studs long in x.

Notes

  • Any LDraw part can be placed. Parts outside the curated catalog are handled as their bounding box for collisions, connectivity and previews. The exported file always uses the real part.

  • Previews are simplified geometry: round parts and arches show as boxes.

Very large builds

The Hornburg up close

Placing tens of thousands of parts one tool call at a time doesn't scale, so for Helm's Deep (192 × 160 studs, 41,864 parts) Claude wrote a generator instead. scripts/helms_deep/ contains it:

  • gen.py designs the scene as a colour voxel grid (terrain, walls, stairs, towers) and hollows it into a supported shell.

  • slopes.py adds 45° slopes along the rock ledges.

  • pack.py packs everything into staggered bricks and plates, then repairs any floating groups.

uv run python scripts/helms_deep/gen.py
uv run python scripts/helms_deep/slopes.py
uv run python scripts/helms_deep/pack.py

Then ask Claude to open_model helms_deep and export it.

Showcase renders and video

scripts/showcase/ has a GPU renderer (OpenGL via moderngl) for nicer images than the built-in previews, plus the scripts that made the pictures on this page:

uv run --with moderngl python scripts/showcase/glrender.py helms_deep out.png   # one image
uv run --with moderngl python scripts/showcase/compare.py                       # photo vs build
uv run --with moderngl python scripts/showcase/video.py                         # 9:16 build video

compare.py and video.py read reference photos from scripts/showcase/refs/. That folder isn't in the repo, so put your own photos there. video.py needs ffmpeg.

Safety

The server runs locally over stdio and makes no network requests (only scripts/fetch_ldraw.sh downloads, from library.ldraw.org). Tool inputs are treated as untrusted:

  • Part ids must be plain LDraw names; library lookups can't leave data/ldraw.

  • Image tools only open picture files (.png, .jpg, …) and refuse decompression bombs.

  • export_ldr only writes .ldr / .mpd files; models are saved under models/ with sanitised names.

  • Render size, grid size and parts per call are capped so one call can't exhaust memory.

It does read picture paths and write .ldr files wherever the MCP client asks, with your user's permissions, so review tool calls as you would any other file access.

Credits and licence

Code: MIT (see LICENSE). Parts geometry comes from the LDraw parts library, which is downloaded separately and is licensed CC BY 2.0 by its authors; it is not included in this repository.

The reference stills shown next to the builds are from The Phoenician Scheme (2025), The Big Lebowski (1998) and The Lord of the Rings: The Two Towers (2002). They are shown small, for comparison only, and remain the property of their owners.

LEGO® is a trademark of the LEGO Group, which does not sponsor or endorse this project.

Available Tools

15 tools
add_partsA

Place one or more parts. Parts that collide or are invalid are skipped and reported; the rest are placed. Returns the new part ids.

Inputs: parts (required). Returns: result

build_mosaicB

Build a picture directly as a mosaic in the current model. upright: a wall facing the front, 1 stud deep (kind=plate gives fine vertical detail, kind=brick is sturdier). flat: lying on the ground, one plate thick, image top = back.

Inputs: width (required), image_path (required), x, y, +6 more. Returns: result

check_modelA

Check structure: floating groups (not connected to anything touching the ground) and loose groups (standing on the ground but not attached to the main body).

Inputs: no named parameters. Returns: result

describe_modelB

Summarise the model: bounds, part counts, and top-down colour maps of plate levels (first row = back, last = front; uppercase letters = colours in the legend). Maps are shown for levels, or every level when all_levels is set.

Inputs: levels, all_levels, list_all_parts. Returns: result

export_ldrA

Write the model as an LDraw .ldr file (one build step per level). Import it in Mecabricks via Workshop > File > Import. If some parts come in missing, re-export with legacy_ids=True (uses e.g. 3023 instead of 3023b).

Inputs: path, legacy_ids. Returns: result

fill_layersA

Build volume from colour maps, automatically packed into bricks/plates/tiles.

layers: bottom-to-top list of layers; each layer is a list of equal-length rows seen from ABOVE, first row = back, last row = front. Each character is a cell of 1 stud; '.' = empty. legend maps characters to colours, e.g. {"R": "Red", "W": 15}. Each layer is one brick (3 plates) or one plate tall depending on kind; layer i sits at y + i*height. (x, z) is the front-left corner of the map.

upright=True: each layer is instead a front-facing wall picture (first row = top, last row = bottom), one course per row, at depth z + layer index. Handy for mosaics and facades.

Cells already occupied are skipped. Seams are staggered between courses.

Inputs: layers (required), legend (required), x, y, +3 more. Returns: result

image_to_gridB

Downsample a picture into rows of colour letters using LEGO colours, ready for fill_layers. crop = [left, top, right, bottom] fractions (0-1) to focus on the subject. cell sets the cell's aspect ratio when height is omitted: 'stud' for top-down maps, 'brick' or 'plate' for upright walls. Transparent pixels become '.'.

Inputs: width (required), image_path (required), cell, crop, +3 more. Returns: result

list_colorsB

List LDraw colours (code, name, hex). Solid colours only unless include_special.

Inputs: search, include_special. Returns: result

list_modelsB

List saved models.

Inputs: no named parameters. Returns: result

list_partsA

List the curated parts (brick, plate, tile, slope, round, misc) with their size, or search the whole LDraw library by words in the part title (e.g. 'window 1 x 2'). Size is studs along x x studs along z at rot 0, and height in plates.

Inputs: search, category. Returns: result

new_modelB

Start a new empty model (replaces the open one; models autosave).

Inputs: name (required), description. Returns: result

open_modelB

Open a previously saved model by name.

Inputs: name (required). Returns: result

remove_partsB

Remove parts by id and/or every part touching an inclusive grid region.

Inputs: ids, region. Returns: result

render_modelB

Render a preview sheet. views: any of front, back, left, right, top, iso_front_left, iso_front_right, iso_back_left, iso_back_right, or 'azimuth,elevation' in degrees. Default: iso_front_left, iso_back_right, front, top. reference_image adds the source picture as the first panel for side-by-side comparison. Parts are simplified (round parts and non-catalog parts show as boxes).

Inputs: size, views, reference_image.

undoB

Undo the last building action.

Inputs: no named parameters. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 15 tools

    Disambiguation5/5

    Each tool targets a clearly distinct action and resource: model lifecycle (open/list/new), part/color discovery, placement/removal, procedural fills, image conversion, structural checks, description, rendering, and export. The only potential overlap between fill_layers and build_mosaic is resolved by their descriptions, which distinguish volume construction from direct picture mosaics.

    Naming Consistency4/5

    Most names follow a predictable snake_case verb_noun pattern (open_model, list_parts, add_parts, remove_parts, check_model, render_model, export_ldr). Minor deviations include undo (single verb) and image_to_grid (noun-to-noun), but overall the set is readable and consistent.

    Tool Count5/5

    Fifteen tools is well-scoped for a LEGO modeling server, covering discovery, construction, validation, rendering, and export without obvious redundancy. Each tool appears to earn its place in the generation workflow.

    Completeness4/5

    The surface covers model creation, part placement/removal, color lookup, procedural fills, image-to-grid conversion, structural checking, rendering, and LDraw export. Minor gaps exist: no direct move/rotate/edit operation for existing parts, no delete_model, and no redo, but agents can work around these by removing and re-adding parts or starting a new model.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to create 3D-printable CAD models using build123d, with tools for modeling, modification, analysis, and publishing to platforms like Thingiverse and GitHub.
      14
      Creative Commons Attribution Non Commercial No Derivatives 4.0 International
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to create and manipulate SolidWorks CAD models through natural language commands, automating part creation, sketching, and extrusion.
      10
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to create, inspect, and edit LEGO models in BrickLink Studio and LDraw files, with atomic construction steps, validation, rollback, illustrated instructions, and native Studio stability checks.
      3
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to create and modify real Onshape CAD models — sketches, extrudes, fillets, patterns, mates, and parametric variables — with every mutation returning structured status, warnings, and geometric deltas. Includes multi-view PNG rendering, image-reference decomposition, and drawing OCR so the agent can visually verify and iterate on parts and assemblies.
      MIT