Developers
Claude Code (MCP)
Let Claude Code design houses in your open editor.
The DreamCode MCP server lets Claude Code — or any client that speaks the Model Context Protocol — design houses in the DreamHome editor you have open: read your code, write and build new code, and look at the result through screenshots.
Set up#
- Add the server to Claude Code (once)Terminalclaude mcp add dreamcode -- node /path/to/dreamhome-app/editor/src/dreamcode/mcp.js
It needs Node 18 or newer and has no dependencies. Claude Code starts it automatically from then on.
- Connect the editor
Open the DreamHome editor, then DreamCode → 🤖 Connect. The status bar shows 🤖 Claude Code connected.
- Ask
“Design a three-bedroom, two-storey house with stairs and show me.” Claude reads the reference, writes the code, checks it, builds it in your editor and takes a screenshot to verify.
Tools#
| Tool | Arguments | Returns |
|---|---|---|
dreamcode_reference | — | Language reference, platform rules and an example. Works without an editor. |
check_code | code | Line-numbered errors, or a summary of what would be built. Works without an editor. |
read_code | — | The DreamCode in the open editor. |
write_code | code | Replaces the code and builds it (one undo step). Returns build status and errors. |
screenshot | view: overview · top · current | PNG of the 3D view. overview frames the whole house; top is a plan view. |
scene_summary | — | Number of floors and a count of every component type in the scene. |
How it connects#
architecture
Claude Code ──stdio (MCP, JSON-RPC)──▶ mcp.js ──HTTP on 127.0.0.1:8766──▶ DreamHome editor tab│ ◀── GET /events (Server-Sent Events): tool calls│ ◀── POST /result: answers└── dreamcode_reference / check_code run locally
- Tool calls only come from the MCP client over stdio — a web page can’t send commands to your editor.
- Only pages served from
localhost/127.0.0.1may connect. To use the hosted app, allow its origin. - If the server restarts, a connected editor reconnects by itself.
Configuration
| Variable | Default | Purpose |
|---|---|---|
DREAMCODE_PORT | 8766 | Bridge port (the editor connects to 8766). |
DREAMCODE_ORIGINS | — | Comma-separated extra origins allowed to connect, e.g. your deployed site. |
Terminal
claude mcp add dreamcode -e DREAMCODE_ORIGINS=https://app.example.com -- node /path/to/editor/src/dreamcode/mcp.js
Troubleshooting#
| Symptom | Fix |
|---|---|
| “The DreamCode editor is not connected” | Click 🤖 Connect in DreamCode; it doesn't survive a page reload. |
| Connect says it can't reach the server | Start Claude Code (it launches the server) and check claude mcp list. |
| “bridge on port 8766 unavailable” | Another process uses the port — stop it, or set DREAMCODE_PORT (the editor expects 8766). |
| Changes don't show in a popped-out window | MCP drives the main editor window — dock DreamCode or watch the 3D view. |
Tip
No MCP? Link a .dream file in DreamCode and let any agent edit it — the editor rebuilds on every change. See Work with files.