Documentation menu
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#

  1. Add the server to Claude Code (once)
    Terminal
    claude 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.

  2. Connect the editor

    Open the DreamHome editor, then DreamCode → 🤖 Connect. The status bar shows 🤖 Claude Code connected.

  3. 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#

ToolArgumentsReturns
dreamcode_reference—Language reference, platform rules and an example. Works without an editor.
check_codecodeLine-numbered errors, or a summary of what would be built. Works without an editor.
read_code—The DreamCode in the open editor.
write_codecodeReplaces the code and builds it (one undo step). Returns build status and errors.
screenshotview: overview · top · currentPNG 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.1 may connect. To use the hosted app, allow its origin.
  • If the server restarts, a connected editor reconnects by itself.

Configuration

VariableDefaultPurpose
DREAMCODE_PORT8766Bridge 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#

SymptomFix
“The DreamCode editor is not connected”Click 🤖 Connect in DreamCode; it doesn't survive a page reload.
Connect says it can't reach the serverStart 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 windowMCP 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.