wadi-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +100 -0
  2. package/dist/server.mjs +417638 -0
  3. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # wadi-mcp
2
+
3
+ An **MCP server** that exposes the Wadi house pipeline as agent-native tools, so a
4
+ coding agent can author, check, and preview a **Wadi DSL (`.wdl`)** design **without the
5
+ repo checked out and without the desktop app running**. The DSL compiler, the schema +
6
+ wall/roof geometry, the structural-conventions linter, the 2D renderers, and the example
7
+ + reference docs are all bundled in — the only external runtime dependency is the native
8
+ SVG rasteriser (`@resvg/resvg-js`).
9
+
10
+ This is the repo-free way to run the [Wadi architect skill](../wadi-skill/architect/).
11
+ (The `wadi-skill` scripts — `check.sh` / `preview.sh` — do the same thing but need the
12
+ repo; this server replaces them for agents that speak MCP.)
13
+
14
+ ## Tools
15
+
16
+ | Tool | What it does |
17
+ | --- | --- |
18
+ | `wadi_check` | Compile + validate a `.wdl`: parse, resolve formulas/grids, schema + wall/roof geometry, and the structural conventions (C1/C2/C3). Returns pass/fail + errors/warnings. **Run after every edit.** |
19
+ | `wadi_preview` | Render a `.wdl` to **PNG images** you can look at — floor plans, elevations, roof top view. Confirm layout/sizes/openings/roof visually. |
20
+ | `wadi_examples` | List, or fetch the full source of, a validated example `.wdl` (`minimal` / `two_room` / `two_story` / `coastal` / `complete`). Copy from these. |
21
+ | `wadi_reference` | The authoring docs, embedded: `guide`, `dsl`, `conventions`, `coordinate-system`, `parametric-conventions`, `roof-v2-guide`, `data-model`. |
22
+ | `wadi_view_3d` | Load a `.wdl` into the **running Wadi desktop app's** live 3D view (so you + the user see the same model). Needs the app open. |
23
+ | `wadi_capture_3d` | Render a `.wdl` in the running app and return a **real 3D image** (the textured model). Needs the app open. |
24
+
25
+ The last two reach the desktop app over a localhost bridge (`127.0.0.1:8765`, override
26
+ `WADI_APP_PORT`); when the app isn't running they return a "open the Wadi app" message and
27
+ you fall back to `wadi_preview` (headless 2D). The first four never need the app.
28
+
29
+ ## Run it
30
+
31
+ From a checkout (dev):
32
+
33
+ ```bash
34
+ npm install
35
+ npm run dev # stdio MCP server (gen-assets + tsx src/server.ts)
36
+ ```
37
+
38
+ Self-contained bundle (no repo afterwards):
39
+
40
+ ```bash
41
+ npm run build # → dist/server.mjs (everything inlined except @resvg/resvg-js)
42
+ ```
43
+
44
+ `dist/server.mjs` runs anywhere Node ≥20 is available, with only `@resvg/resvg-js`
45
+ installed alongside it.
46
+
47
+ ## Register with an agent
48
+
49
+ **Published to npm — zero install** (nothing to build or clone; `npx` fetches on first run):
50
+
51
+ ```bash
52
+ claude mcp add wadi -- npx -y wadi-mcp # Claude Code
53
+ ```
54
+ ```json
55
+ { "mcpServers": { "wadi": { "command": "npx", "args": ["-y", "wadi-mcp"] } } }
56
+ ```
57
+
58
+ **From a local build** (`npm run build` above) — point at the bundle by path:
59
+
60
+ ```json
61
+ { "mcpServers": { "wadi": { "command": "node", "args": ["/abs/path/to/wadi-mcp/dist/server.mjs"] } } }
62
+ ```
63
+
64
+ **Any MCP client** (Cursor, Windsurf, Claude Desktop, …) — use the same `command` + `args`
65
+ (stdio transport). Then ask the agent to design a house; it calls
66
+ `wadi_reference('guide')` to learn the workflow, `wadi_examples` to copy a starting
67
+ point, and `wadi_check` / `wadi_preview` as it authors the `.wdl`.
68
+
69
+ > The agent still writes a `.wdl` file you both co-edit; for the **live** 3D preview, open
70
+ > that file in the Wadi DSL editor (desktop ⌘⇧D, or <https://wadi.house/dsl>). This server
71
+ > provides the headless check + 2D image previews the agent reads on its own.
72
+
73
+ ## Verify
74
+
75
+ ```bash
76
+ npm run smoke # in-process pipeline (check + render)
77
+ npx tsx scripts/client-test.mjs # end-to-end over the MCP protocol
78
+ # no-repo proof: build, copy dist/server.mjs to a temp dir, `npm i @resvg/resvg-js`, then
79
+ npx tsx scripts/standalone-client.mjs <temp>/server.mjs
80
+ ```
81
+
82
+ ## How it stays in sync
83
+
84
+ The server imports the **real** pipeline from `editor/src` and `wadi-dsl/src` (see
85
+ `src/pipeline.ts`), so `wadi_check`/`wadi_preview` match the app byte-for-byte — there is
86
+ no second implementation to drift. `scripts/gen-assets.mjs` re-embeds the examples and
87
+ reference docs at build time. Rebuild (`npm run build`) after changing the schema, the
88
+ DSL, the conventions, or the docs.
89
+
90
+ ## Publishing
91
+
92
+ `npm publish` (from `wadi-mcp/`). `prepublishOnly` runs `build` + `smoke` first, so the
93
+ published tarball always contains a freshly-bundled, tested `dist/server.mjs` (the only
94
+ files shipped are `dist/` + `package.json` + this README). Bump `version` first.
95
+
96
+ The `wadi_view_3d` / `wadi_capture_3d` tools are backed by a localhost HTTP bridge the
97
+ Tauri desktop app serves (`src-tauri/src/lib.rs` → `/health`, `/load`, `/capture`); the
98
+ main window's viewer answers via a `wadi://bridge-request` listener that drives
99
+ `window.wadi.load` + `window.wadiCapture3D` (`editor/src/viewer/main.ts`). Bound to
100
+ 127.0.0.1 only.