MCP Hub
Back to servers

brick-mcp-app

๐Ÿงฑ MCP App for making my brick dreams a reality

GitHub
Stars
10
Forks
4
Updated
Mar 16, 2026
Validated
Apr 5, 2026

Brick Builder MCP App

A Three.js MCP App for designing 3D brick constructions inside MCP-enabled hosts like Claude Desktop and Visual Studio Code. Build interactively or let the AI build structures for you through natural language.

Quick Start ยท Connecting ยท Tools ยท Extensibility

CI License: MIT GitHub stars

Brick Builder in action โ€” AI building a structure in real time
Brick Builder running in Claude, building a structure through natural language

Quick Start

git clone https://github.com/<owner>/brick-mcp-app.git
cd brick-mcp-app
npm install
npm run build
npm run serve

The server starts at http://localhost:3001/mcp.

Prerequisites

  • Node.js 20+
  • npm 10+

Commands

CommandDescription
npm installInstall dependencies
npm run buildBuild client (Vite) + server (esbuild)
npm run serveStart server in dev mode (tsx, auto-reload)
npm run devWatch client + serve concurrently
npm startBuild then serve (one command)

Architecture

The server is the single source of truth for all scene state. Both the AI (LLM) and the interactive UI mutate state exclusively through MCP tools. The server validates every operation โ€” collision detection, bounds checking, support verification โ€” and returns authoritative results.

Key Design Decisions

  • Shared module-level state: The host creates separate MCP sessions for the LLM and the app iframe. Scene state lives at module level so both sessions read/write the same scene.
  • Polling for cross-session sync: The UI polls brick_get_scene every second to pick up LLM-initiated changes. User-initiated changes (via callServerTool) are reflected instantly.
  • Single-brick placement: The LLM places one brick per brick_place call and receives the placed brick's footprint in the response, enabling precise positioning of subsequent bricks.

Connecting to Hosts

[!TIP] You can use Cloudflare Tunnels to expose your locally-hosted server to the internet. This lets you connect from claude.ai or any remote MCP host without port forwarding or VPNs:

cloudflared tunnel --url http://localhost:3001

Then use the generated *.trycloudflare.com URL in place of http://localhost:3001 in the configurations below.

Claude Desktop

Claude Desktop does not natively support streamable HTTP servers through config. You need to add the server as a custom connector (available on paid plans):

  1. Open Claude Desktop settings
  2. Navigate to Connectors and add a new custom connector
  3. Set the URL to the hosted URL of your MCP server (if you are using Cloudflare Tunnels, append /mcp)

Visual Studio Code

Visual Studio Code supports Streamable HTTP MCP servers natively. Create .vscode/mcp.json in your workspace:

{
  "servers": {
    "brick-builder": {
      "type": "http",
      "url": "http://localhost:3001/mcp"
    }
  }
}

Or use the Command Palette: MCP: Add Server > HTTP > http://localhost:3001/mcp

MCP Tools

The following tools are accessible from whatever client you're using to interact with the app.

ToolDescription
brick_read_meReturns the building guide, coordinate system, and examples
brick_get_availableReturns all brick types with IDs, dimensions, and categories
brick_render_sceneOpens the 3D viewer iframe (must call before placing bricks)
brick_placePlace a single brick. Returns placed brick with footprint for precise adjacent positioning
brick_get_sceneRead the current scene state with all bricks and their footprints
brick_remove_brickRemove a single brick by ID. Cascades to remove unsupported bricks above it
brick_clear_sceneRemove all bricks from the scene
brick_export_sceneExport as JSON or a human-readable summary

Interactive UI

Brick Builder 3D editor interface

The 3D viewport supports seven interaction modes, switchable via the toolbar or keyboard shortcuts:

#ModeShortcutAction
1Look1Orbit, pan, and zoom the camera. No brick interaction.
2Place2Click the grid to place bricks. Ghost preview shows valid (green) or invalid (red) positions.
3Select3Click a brick to select it (highlighted).
4Move4Drag a brick to a new position.
5Rotate5Click a brick to rotate it 90 degrees.
6Delete6Click a brick to remove it.
7Paint7Click a brick to change its color.

Additional shortcuts:

KeyAction
RCycle rotation (0 / 90 / 180 / 270) in place mode
DeleteRemove the selected brick
EscapeDeselect / cancel drag

Brick Types

[!NOTE] This list is not final โ€” more brick types will be added over time. See Adding New Brick Types for how to contribute new types.

20 brick types across three categories:

CategoryTypes
Bricks (standard height, 3 plate units)1x1, 1x2, 1x3, 1x4, 1x6, 1x8, 2x2, 2x3, 2x4, 2x6, 2x8
Plates (1/3 height, 1 plate unit)1x1, 1x2, 1x4, 2x2, 2x4, 2x6, 4x4
Slopes (angled top)1x2, 2x2, 2x3

Coordinate System

[!NOTE] I might expand this further (or get rid of the baseplate altogether) in the future. The current setup is very much experimental.

  • Baseplate: 48 x 48 studs (X and Z axes)
  • Y axis: Height in plate units (1 standard brick = 3 Y units)
  • Rotation: 0, 90, 180, or 270 degrees (swaps X/Z dimensions)
  • All positions are integers snapped to the stud grid

Adding New Brick Types

Adding a new brick requires just two files. The catalog, server validation, geometry rendering, and UI selector all pick it up automatically.

Step 1: Create the definition

Create a file in src/bricks/definitions/. The BrickDefinition interface:

interface BrickDefinition {
  id: string;                  // Unique ID used in tool calls (e.g. 'brick_3x2')
  name: string;                // Display name (e.g. '3ร—2 Brick')
  category: 'brick' | 'plate' | 'slope' | 'technic' | 'corner';
  studsX: number;              // Width in studs (X axis)
  studsZ: number;              // Depth in studs (Z axis)
  heightUnits: number;         // Height in plate units (standard brick = 3, plate = 1)
  blockout?: BlockoutZone[];   // Optional zones where bricks can't sit on top (slopes)
}

Example โ€” src/bricks/definitions/brick_3x2.ts:

import type { BrickDefinition } from '../types.js';

const brick_3x2: BrickDefinition = {
  id: 'brick_3x2',
  name: '3ร—2 Brick',
  category: 'brick',
  studsX: 3,
  studsZ: 2,
  heightUnits: 3,
};

export default brick_3x2;

Example with blockout (slope) โ€” the angled face blocks stud connections:

const slope_2x3: BrickDefinition = {
  id: 'slope_2x3',
  name: '2ร—3 Slope 45ยฐ',
  category: 'slope',
  studsX: 2,
  studsZ: 3,
  heightUnits: 3,
  blockout: [{ minX: 0, maxX: 2, minZ: 1, maxZ: 3, height: 3 }],
};

Step 2: Export from the index

Add one line to src/bricks/definitions/index.ts:

export { default as brick_3x2 } from './brick_3x2.js';

Checklist

The brick is now:

  • In BRICK_CATALOG (auto-populated from exports)
  • Available to the LLM via brick_get_available and brick_place
  • Shown in the UI brick selector panel
  • Validated by server-side collision, bounds, and support checks
  • Rendered with auto-generated geometry based on category

No changes to server.ts, BrickBuilder.tsx, or any other file are needed to make things happen.

How categories map to geometry

The category field determines which geometry builder creates the 3D model:

CategoryHeight conventionGeometry
brickheightUnits: 3 (standard)Rectangular with studs on top, hollow underneath
plateheightUnits: 1 (thin)Same as brick, 1/3 height
slopeheightUnits: 3Angled top face, studs only on flat portion
technicheightUnits: 3Pin holes in walls for axle connections
cornerheightUnits: 1L-shaped body with partial stud grid

Adding a new category

To add an entirely new geometry style:

  1. Create a geometry builder in src/bricks/geometry/ (e.g. cylinder.ts)
  2. Add a case to the switch in src/bricks/geometry/index.ts:
    case 'cylinder': geometry = createCylinderGeometry(bt); break;
    
  3. Add the category to the BrickDefinition type union in src/bricks/types.ts
  4. Geometries must be corner-origin โ€” spanning [0, w] x [0, h] x [0, d] in local space

Unit reference

UnitWorld sizeReal-world
1 stud (X/Z)1.08 mm
1 plate unit (Y)0.43.2 mm
1 standard brick (Y)1.2 (3 plates)9.6 mm

Local Testing

Test harness

The project includes a built-in visual test harness for testing MCP tools without a host. Start the server and navigate to:

http://localhost:3001/test

The harness connects directly to the MCP server and provides a sidebar with buttons for every tool โ€” render the scene, place bricks, clear, export, etc. The 3D viewport is embedded alongside so you can see results immediately.

basic-host

You can also test using the MCP Apps SDK basic-host, which simulates the full host environment (iframe, postMessage, callServerTool):

# Terminal 1: start the server
npm run build && npm run serve

# Terminal 2: run basic-host
git clone --depth 1 https://github.com/modelcontextprotocol/ext-apps.git /tmp/mcp-ext-apps
cd /tmp/mcp-ext-apps/examples/basic-host
npm install
SERVERS='["http://localhost:3001/mcp"]' npm run start
# Open http://localhost:8080

License

MIT โ€” see LICENSE.

Reviews

No reviews yet

Sign in to write a review