Architecture overview
DesignJS uses a two-layer communication architecture: a stdio MCP server that the agent talks to, and a WebSocket bridge that relays those calls to the browser where the canvas lives.The stdio MCP server
The MCP server is a standalone Node.js process that uses stdio transport — it reads JSON-RPC messages from standard input and writes responses to standard output. This is the transport mode that Claude Code, Cursor, and VS Code all support natively for MCP servers. Your agent spawns the MCP server process and communicates with it directly. The server handles the MCP handshake, registers all available tools, and routes incoming tool calls to the canvas over the WebSocket bridge. All tools are registered automatically when the server starts. Every tool in the DesignJS tool set is available to your agent without any additional configuration.The WebSocket bridge
The WebSocket bridge runs onws://127.0.0.1:29170/designjs-bridge and is embedded in the Vite dev server process (started by pnpm dev). It acts as a relay between the MCP server and the browser.
Both peers — the MCP server and the browser canvas — connect to the bridge and identify themselves with a hello message:
request message and sends it to the bridge. The bridge routes it to the canvas peer. The canvas executes the tool, wraps the result in a response message, and sends it back through the bridge to the MCP server, which returns it to the agent.
The bridge is bound to
127.0.0.1 (loopback only) and is not accessible from other machines on your network. This is intentional — agent access to the canvas is local only.Available MCP tools
DesignJS ships 20+ tools in v0.1, covering the full read/write surface of the canvas. A representative slice:
The full per-tool reference — input/output schemas, example prompts, failure modes — lives at MCP Tools Overview →.
What this means for you
From your perspective as a user or integrator, the MCP layer is mostly invisible. You connect the agent once (see Connect an AI Agent) and then interact with it naturally. Ask your agent to “add a hero section with a blue background” and it will calladd_components with the appropriate HTML. Ask it to “make the headline text larger” and it will call get_selection or get_tree to find the right component, then call update_styles.
The bidirectional nature of the protocol matters in practice: the agent isn’t just reading a snapshot of your design — it’s operating on the live canvas, the same one you’re looking at. Changes appear immediately in your browser as the agent makes them. You can also select something in the editor and tell the agent “update what I have selected,” and it will call get_selection to find the right component IDs before acting.