@adia-ai/mcp 0.8.37

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.
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # @adia-ai/mcp
2
+
3
+ **Two MCP servers, one npm package, one bin.** ADR-0048 §3 ruled two distinct
4
+ servers ("they do different things"); gh#1240 (operator ruling 2026-08-14)
5
+ unified only the *distribution* — before either predecessor name
6
+ (`@adia-ai/gen-ui-mcp`, `@adia-ai/a2ui-protocol-mcp`) ever published a 0.8.x —
7
+ into this one package.
8
+
9
+ | You want to… | Run |
10
+ |---|---|
11
+ | Generate UI from an intent, search the training corpus, run evals, catalog-aware validation + anti-pattern scoring | `adia-mcp gen-ui` |
12
+ | Check that an A2UI document is well-formed, whoever produced it; see which component types/wiring exist with no corpus and no model | `adia-mcp protocol` |
13
+ | See the two-server menu | `adia-mcp` (bare) |
14
+
15
+ **The protocol server's four tool names are distinct from the gen-ui
16
+ server's** (gh#1248 renamed them off their original same-named forms before
17
+ the protocol server ever published) — each still has a narrower,
18
+ protocol-only counterpart on `gen-ui`; see
19
+ [Tool name disambiguation](#tool-name-disambiguation) for the mapping if you
20
+ have both servers installed.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ npm install -g @adia-ai/mcp # global — exposes the `adia-mcp` bin
26
+ # OR
27
+ npm install @adia-ai/mcp # local — invoke via npx
28
+ ```
29
+
30
+ Claude Desktop / Cursor / any MCP host, `mcpServers` block:
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "adia-ui": {
36
+ "command": "npx",
37
+ "args": ["-y", "@adia-ai/mcp", "gen-ui"]
38
+ },
39
+ "a2ui-protocol": {
40
+ "command": "npx",
41
+ "args": ["-y", "@adia-ai/mcp", "protocol"]
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ From a local checkout:
48
+
49
+ ```bash
50
+ node packages/mcp/bin/adia-mcp gen-ui # stdio, local IDE
51
+ node packages/mcp/bin/adia-mcp protocol # stdio, protocol-only
52
+ MCP_HTTP_PORT=3460 node packages/mcp/bin/adia-mcp gen-ui # HTTP transport (gen-ui only)
53
+ ```
54
+
55
+ ## `gen-ui` — the generation server
56
+
57
+ Wraps [`@adia-ai/gen-ui`](../gen-ui/compose). Exposes the generation engine,
58
+ component catalog, pattern library, validator, and training feedback loop as
59
+ **30 MCP tools** for Claude Desktop, Claude Code, Cursor, Windsurf, and any
60
+ deployed MCP-capable host.
61
+
62
+ > Runtime only. Generation logic lives in `@adia-ai/gen-ui`; UI atoms in
63
+ > [`@adia-ai/web-components`](../web-components); the A2UI protocol runtime
64
+ > (renderer, registry, streams, wiring) in [`@adia-ai/a2ui`](../a2ui); corpus
65
+ > in [`@adia-ai/gen-ui/corpus`](../gen-ui/corpus).
66
+
67
+ ### Two transports, one tool surface
68
+
69
+ | Mode | When | LLM source |
70
+ |---|---|---|
71
+ | **stdio** (default) | Local IDE tools — Claude Code, Cursor, Hermes | Host's LLM via MCP sampling (no API key needed) |
72
+ | **HTTP** (`MCP_HTTP_PORT`) | Deployed web service, remote MCP clients | `.env` API key required |
73
+
74
+ **stdio** requests LLM inference from the host via MCP `sampling/createMessage`
75
+ — no separate API key, same model, same token budget the user is already
76
+ paying for. **HTTP** gives each session its own transport **and its own
77
+ `McpServer`** (the SDK binds one transport per server instance); corpus,
78
+ catalog and chunk index stay process-wide and shared.
79
+
80
+ #### Session idle TTL (HTTP only)
81
+
82
+ | Env | Default | Meaning |
83
+ |---|---|---|
84
+ | `MCP_SESSION_TTL_MS` | `1800000` (30 min) | Idle time before a session is evicted. `0` or negative disables eviction entirely. |
85
+
86
+ Every request refreshes a session's last-activity stamp; an idle-evicted
87
+ session's next request gets the same `-32001` an unknown session id gets —
88
+ re-`initialize` to continue. stdio has no sessions and is unaffected.
89
+
90
+ ### Quick start
91
+
92
+ ```bash
93
+ export ANTHROPIC_API_KEY=sk-ant-… # at least one provider key, for generate_ui
94
+ adia-mcp gen-ui # global install, stdio
95
+ npx @adia-ai/mcp gen-ui # via npx
96
+ node packages/mcp/gen-ui/server.js # from local checkout
97
+ MCP_HTTP_PORT=3460 node packages/mcp/gen-ui/server.js # HTTP → 0.0.0.0:3460/mcp
98
+ ```
99
+
100
+ ### Tools
101
+
102
+ **See [`TOOLS.md`](./TOOLS.md) for the full reference** (both servers,
103
+ sectioned) — tool names, descriptions, grouping, argument schemas. Quick map
104
+ for `gen-ui`:
105
+
106
+ | Group | Tools |
107
+ |---|---|
108
+ | **Generation** | `generate_ui`, `refine_ui` |
109
+ | **Discovery** | `get_component_map`, `lookup_component`, `lookup_chunk`, `get_traits`, `get_wiring_catalog`, `list_patterns`, `server_status` |
110
+ | **Retrieval** | `search_chunks`, `get_chunk`, `search_patterns`, `get_composition`, `get_graph`, `resolve_composition`, `zettel_stats` |
111
+ | **Synthesis + state** | `compose_from_chunks`, `refine_composition`, `get_state`, `report_issue` |
112
+ | **Intent + context** | `plan_app_state`, `classify_intent`, `assemble_context` |
113
+ | **Validation + conversion** | `validate_schema`, `check_anti_patterns`, `convert_html` |
114
+ | **Feedback + evaluation** | `submit_feedback`, `get_quality_metrics`, `get_training_gaps`, `run_eval` |
115
+
116
+ ### Layout
117
+
118
+ ```
119
+ gen-ui/
120
+ ├── server.js MCP bootstrap — registers tools inline; the rest live in tools/ modules
121
+ ├── scripts/ Standalone runners (smoke tests, eval diffs, visual validate)
122
+ ├── tools/ tool modules: synthesis · validation · feedback · corpus · zettel · discovery · refine
123
+ └── evals/ held-out eval fixtures
124
+ ```
125
+
126
+ ### Gotchas
127
+
128
+ - **Corpus load is noisy.** The zettel composer prints stats to stderr on
129
+ first invocation. Callers expecting silent MCP should swallow stderr.
130
+ - **API keys must be set before the server starts.** Changing env vars
131
+ mid-session doesn't hot-reload adapters.
132
+ - **Engine selector is internal.** Don't pass `engine: 'mcp'` — the generator
133
+ picks `monolithic` vs `zettel` from intent + mode.
134
+ - **Multi-turn state is per-process, in-memory, ephemeral.** Restarting the
135
+ server drops every multi-turn chain in flight. Checkpoint the canvas to your
136
+ own store between turns and pass `currentCanvas` on resume rather than
137
+ relying on `executionId`/`sessionId` for durability.
138
+
139
+ ## `protocol` — the A2UI protocol server
140
+
141
+ Wraps [`@adia-ai/a2ui`](../a2ui) and nothing else. `@adia-ai/gen-ui` and
142
+ `@adia-ai/llm` are deliberate **non**-dependencies of this surface — see
143
+ [Why a separate server](#why-a-separate-server-not-just-a-shared-one).
144
+
145
+ Four tools, no API key, no `.env`, **stdio only** (no HTTP mode — express and
146
+ session-sweep belong to `gen-ui`): `validate_document` · `get_registry_map` ·
147
+ `get_wiring_registry` · `protocol_status`.
148
+
149
+ ```bash
150
+ node packages/mcp/protocol/server.js # stdio only
151
+ npm run mcp:protocol:smoke # boot + exercise all 4 tools + isolation proof
152
+ ```
153
+
154
+ ### Tool name disambiguation
155
+
156
+ **Until gh#1248, all four of these tool names were shared with `gen-ui`, each
157
+ returning a different shape depending on which server answered — a host with
158
+ both installed saw each name twice.** The protocol server had never
159
+ published, so gh#1248 (adversarial-review finding F7, 2026-08-14) renamed all
160
+ four off their original same-named forms while the cost was still zero. Each
161
+ renamed tool keeps its narrower, protocol-only counterpart on `gen-ui`:
162
+
163
+ | Tool (`protocol`) | Counterpart (`gen-ui`) | `protocol` shape | `gen-ui` shape |
164
+ |---|---|---|---|
165
+ | `validate_document` | `validate_schema` | protocol verdict only | same verdict **plus** a `catalog` key (AJV against the v0.9 catalog) and anti-pattern scoring |
166
+ | `get_registry_map` | `get_component_map` | `{ totalTypes, totalTags, entries: [{ type, tag, aliases }] }` | newline-delimited `Type -> <tag>: description` text from the catalog |
167
+ | `get_wiring_registry` | `get_wiring_catalog` | `{ controllers, handlers, uriSchemes }` — **names only**, read live from the runtime registry | the full authoring knowledge base: UI event payloads, refresh strategies, value sources, association types, per-controller config/commands/bind |
168
+ | `protocol_status` | `server_status` | transport + protocol-registry stats | transport, sampling capability, corpus stats |
169
+
170
+ That asymmetry is the point — `protocol` answers questions about the standard
171
+ itself (any producer's document), `gen-ui` answers questions about this
172
+ producer's catalog. The rename only changed how a client asks; it changed
173
+ neither shape.
174
+
175
+ ### Why a separate server (not just a shared one)
176
+
177
+ ADR-0048 Decision §3 and `.claude/docs/specs/a2ui-gen-ui-split.md` ## Interfaces
178
+ ▸ MCP partition: the MCP SDK and zod would otherwise become dependencies of
179
+ every embedding host that only needs to render a canvas and validate
180
+ documents against the standard, with no need for the generation engine or a
181
+ model client. Two servers keep that boundary at the process level, not just
182
+ the package level; gh#1240 only moved where the two servers' code and npm
183
+ manifest live, not that boundary.
184
+
185
+ ## Package exports
186
+
187
+ `package.json`'s `exports` map declares exactly two subpaths — `./gen-ui/server.js`
188
+ and `./protocol/server.js` — the two entry points the `packages/shims/a2ui-mcp`
189
+ bin forwarder and the packed-boot probe reach by deep import
190
+ (`@adia-ai/mcp/gen-ui/server.js`). This is an explicit **invariant**, not an
191
+ accident of omission: without a declared `exports` map every file in `files`
192
+ is deep-importable by default, which is what let that resolution work before
193
+ this map existed. Adding ANY future subpath key here is fine; removing or
194
+ renarrowing either of the two above breaks the shim silently for anyone still
195
+ on the retired `@adia-ai/a2ui-mcp` name. Re-run `npm run probe:packed-boot`
196
+ and `node scripts/verify/check-shim-bridges.mjs` after touching this map.
197
+
198
+ ## Local development
199
+
200
+ ```bash
201
+ npm run build:mcp-server # gen-ui: server.ts + tools/*.ts -> .js (esbuild)
202
+ npm run build:protocol-mcp-server # protocol: server.ts + tools/*.ts -> .js (esbuild)
203
+ npm run mcp:smoke # gen-ui: boot over stdio, exercise all 30 tools
204
+ npm run mcp:protocol:smoke # protocol: boot over stdio, exercise all 4 tools + isolation proof
205
+ npm run build:mcp-tools-md # regenerate TOOLS.md (both servers, sectioned) from the live tool lists
206
+ ```
207
+
208
+ ## License
209
+
210
+ MIT