LEGO MCP Server
Lets an AI agent look up a real LEGO part number instead of inventing one.
A monorepo of read-only MCP servers that give AI agents verified data instead of guesses. The first one, LEGO Catalog, exposes the Rebrickable catalog (65,000 parts, 275 colors, 28,000 sets) from a 49 MB SQLite snapshot over Streamable HTTP. It's built so an agent can look up a part ID rather than invent one. A personal, non-commercial project.
Visit LEGO MCP ServerWhy it matters
- Language models are good at LEGO conversation and bad at LEGO part numbers. Ask for "a 2×4 brick in dark bluish gray" and you'll often get a confident, wrong ID.
- This project fixes that by putting the real catalog behind a Model Context Protocol (MCP) server, so the agent looks things up instead of making them up.
What it is
- A monorepo of small, read-only MCP servers.
- Each one is a self-contained package with its own data and tests, and each is served at its own path (/<name>/mcp).
- That makes it cheap to add the next server, and the same code works whether it's deployed as one Vercel project or several.
The first server: LEGO Catalog
- It sits on a slim SQLite snapshot of Rebrickable's public catalog data: about 65,000 parts, 114,000 element records, 28,000 sets and 1.5 million inventory rows.
- After dropping what an agent doesn't need, the whole database is under 50 MB, small enough to ship inside a serverless function.
- search_parts: full-text search, so "brick 2 x 4" returns part 3001
- get_part: name, category, material and the colors a part exists in
- list_colors: the full color table, filterable by name or transparency
- get_set_inventory: a paginated parts list for any set, with spare parts flagged
- lookup_element: resolves a printed element ID to its part and color
- snapshot_info: how fresh the data is, where it came from, and the server's limits
Design decisions
- Read-only by design. Every tool is annotated as read-only and idempotent. There are no write tools and no API keys.
- Honest about data. Every response includes the snapshot date and source. Unknown IDs return a structured not_found instead of a plausible guess.
- Built to resist misuse. Queries are parameterized, free text is sanitized before it reaches the search engine, and result sizes are capped and paginated.
- Clear about identifiers. The tool descriptions spell out the difference between a part number, an element ID and a design ID, the most common source of model mistakes.
Credits
- Data courtesy of Rebrickable (rebrickable.com/downloads).
- LEGO® is a trademark of the LEGO Group, which is not affiliated with this project.
Built with
- TypeScript
- MCP SDK
- SQLite FTS5
- Zod
- Vitest
- pnpm workspaces
- Vercel