@nucleux/mcp 0.4.5 → 0.5.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.
package/README.md CHANGED
@@ -1,100 +1,180 @@
1
1
  # @nucleux/mcp
2
2
 
3
- Model Context Protocol server for **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — the agentic UI component library for React. It lets AI coding agents (Claude Code, Claude Desktop, Cursor, Windsurf, …) **discover, search, and correctly use** `@nucleux` components: real descriptions, exports, verbatim TypeScript `Props`, install/import lines, and full example compositions.
3
+ Design-system intelligence for coding agents. `@nucleux/mcp` lets Claude Code,
4
+ Codex, Cursor and other MCP clients build UI with
5
+ **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** the way a
6
+ Nucleux designer would: pick a curated page pattern, read the exact component
7
+ contracts, set the project up correctly, and avoid inventing APIs.
4
8
 
5
- It ships a catalog generated from the packages themselves, so the answers match the published code — no guessing, no hallucinated props.
9
+ It ships three things:
10
+
11
+ - **An MCP server** with curated page patterns, exact component contracts
12
+ (props, types, required/optional, defaults and variant values, generated
13
+ from the TypeScript sources), setup instructions and example screens.
14
+ - **The `nucleux-design` skill**: a design-first workflow (inspect → analyse →
15
+ discover → plan → implement → validate → report) for Claude Code and Codex.
16
+ - **`init`**: one command that installs the skill into your project.
6
17
 
7
18
  ## Quick start
8
19
 
9
- You never install this package by hand — your AI client runs it on demand via `npx`.
20
+ Needs [Node.js](https://nodejs.org) ≥ 18. Nothing to install by hand: the
21
+ client runs the server on demand through `npx`.
10
22
 
11
- **Prerequisites:** [Node.js](https://nodejs.org) ≥ 18 (provides `npx`) and an MCP-capable client (Claude Code, Claude Desktop, Cursor, Windsurf, …).
23
+ ### Claude Code
12
24
 
13
- **Claude Code** (one command):
25
+ Plugin (MCP server + skill in one step):
14
26
 
15
27
  ```bash
16
- claude mcp add nucleux -- npx -y @nucleux/mcp
28
+ claude plugin marketplace add intelligaia-open-labs/nucleux
29
+ claude plugin install nucleux@nucleux-marketplace
17
30
  ```
18
31
 
19
- Then verify: `claude mcp list` → `nucleux ✓ connected`.
20
-
21
- That's it. Now just ask your agent in plain language — it calls the tools for you:
32
+ Or add the pieces yourself:
22
33
 
23
- > "Set up Nucleux in this project."
24
- > "What Nucleux components exist for a chat UI?"
25
- > "Show me the InputBar props and build a composer with a stop button."
26
- > "Give me a full agent-chat screen using Nucleux."
34
+ ```bash
35
+ claude mcp add nucleux -- npx -y @nucleux/mcp
36
+ npx -y @nucleux/mcp init --claude # → .claude/skills/nucleux-design/SKILL.md
37
+ ```
27
38
 
28
- ## Configure other clients
39
+ Check with `claude mcp list` (`nucleux … ✓ Connected`).
29
40
 
30
- **Cursor** — create `.cursor/mcp.json` in your project (or the global config):
41
+ ### Codex
31
42
 
32
- ```json
33
- { "mcpServers": { "nucleux": { "command": "npx", "args": ["-y", "@nucleux/mcp"] } } }
43
+ ```bash
44
+ codex mcp add nucleux -- npx -y @nucleux/mcp
45
+ npx -y @nucleux/mcp init --codex --agents-md # → .agents/skills/nucleux-design/, AGENTS.md section
34
46
  ```
35
47
 
36
- **Claude Desktop** — edit `claude_desktop_config.json`, then restart the app:
48
+ Or in `~/.codex/config.toml` (or a trusted project's `.codex/config.toml`):
37
49
 
38
- - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
39
- - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
50
+ ```toml
51
+ [mcp_servers.nucleux]
52
+ command = "npx"
53
+ args = ["-y", "@nucleux/mcp"]
54
+ ```
55
+
56
+ ### Cursor, Claude Desktop, Windsurf, other MCP clients
40
57
 
41
58
  ```json
42
59
  { "mcpServers": { "nucleux": { "command": "npx", "args": ["-y", "@nucleux/mcp"] } } }
43
60
  ```
44
61
 
45
- **Windsurf / other clients** — use the same `command`/`args` in their MCP settings.
62
+ (`.cursor/mcp.json`; for Claude Desktop, `claude_desktop_config.json`; then restart.)
63
+ These clients do not read skills. The server's own instructions point the agent
64
+ at the same workflow, and the `build_with_nucleux` prompt carries it in full.
46
65
 
47
- > **Windows:** if the client can't find `npx`, use `"command": "npx.cmd"`.
66
+ ## Example prompts
48
67
 
49
- ## Verify it works
68
+ > Build a project management app with a dashboard, project list, task
69
+ > management, team page and settings, responsive on mobile. Use Nucleux
70
+ > components and design patterns.
50
71
 
51
- Run it directly:
72
+ > Add an admin users page to this app with search, a role filter and
73
+ > pagination, using Nucleux.
52
74
 
53
- ```bash
54
- npx -y @nucleux/mcp
55
- ```
75
+ > Set up Nucleux in this project.
56
76
 
57
- It should print `nucleux-mcp ready — 48 components, 6 examples.` to **stderr**, then wait on stdin — that's correct, it speaks MCP (JSON-RPC) over stdio. Press `Ctrl+C` to exit. If you see that line, your client integration will work.
77
+ In Claude Code you can also run the workflow prompt directly:
78
+ `/mcp__nucleux__build_with_nucleux a CRM with contacts, deals and a pipeline view`.
58
79
 
59
- ## Tools
60
-
61
- | Tool | What it does |
62
- | --- | --- |
63
- | `list_components` | List every component with package + one-line description. |
64
- | `search_components` | Keyword search across names, descriptions, and keywords. |
65
- | `get_component` | Full detail for one component — description, install/import, exports, and the verbatim `Props` interface(s). Accepts `Badge`, `badge`, or `@nucleux/badge`. |
66
- | `get_setup` | Install + Tailwind/tokens theming setup. Read before writing code that imports `@nucleux`. |
67
- | `list_examples` | List runnable example compositions (agent chat, dashboards, card variations, settings…). |
68
- | `get_example` | Full TSX source of one example composition. |
80
+ ## New project vs existing project
69
81
 
70
- ## Configure your client
82
+ - **New project:** the agent calls `get_setup` with your package manager and
83
+ config format, then installs `@nucleux/react @nucleux/tokens` and Tailwind
84
+ CSS v3, and writes the preset, content globs, PostCSS config and CSS imports.
85
+ - **Existing project with Nucleux:** setup is skipped. The agent reads your
86
+ routes and components first and adds pages that match them.
87
+ - **Existing project on another component system:** the skill tells the agent
88
+ not to migrate you. It extends what you have unless you ask to switch.
71
89
 
72
- ### Claude Code
73
-
74
- ```bash
75
- claude mcp add nucleux -- npx -y @nucleux/mcp
76
- ```
90
+ ## Tools
77
91
 
78
- ### Claude Desktop / Cursor / Windsurf
92
+ Discovery is concise; details come on request, so no call returns the whole catalog.
79
93
 
80
- Add to the client's MCP config (`claude_desktop_config.json`, `.cursor/mcp.json`, …):
94
+ | Tool | Purpose |
95
+ | --- | --- |
96
+ | `search_patterns` | Find curated page patterns by intent ("admin dashboard to monitor metrics and manage users"). Returns ids, summaries, use cases, required components. |
97
+ | `get_pattern` | Full spec for one pattern: when (not) to use it, components, composition tree, layout, responsive and accessibility rules, tokens, states, anti-patterns, and a typechecked TSX example. |
98
+ | `search_components` | Keyword search across component names, descriptions and keywords. |
99
+ | `get_component` | Exact contract for one component: import line, exports, every prop with type, required, default, allowed values and deprecations, plus the patterns that use it. `framework: "html"` returns static markup instead. |
100
+ | `validate_design` | Check a plan (pattern ids + component tree with props) against the catalog. Returns JSON issues: unknown patterns/components, props a component lacks, invalid variant values, missing required or deprecated props, pattern components left out. |
101
+ | `get_setup` | Requirements and install for `react` (pass `packageManager` and `configModule`) or plain `html`. |
102
+ | `list_components` | Every component with a one-line description. |
103
+ | `list_examples` / `get_example` | Larger reference screens (agent chat, dashboards, login, settings…). |
81
104
 
82
- ```json
83
- {
84
- "mcpServers": {
85
- "nucleux": {
86
- "command": "npx",
87
- "args": ["-y", "@nucleux/mcp"]
88
- }
89
- }
90
- }
91
- ```
105
+ Prompt: `build_with_nucleux` (optional `request`) returns the full workflow.
92
106
 
93
- ## Typical first-run flow
107
+ ### Curated patterns
94
108
 
95
- 1. Add the server (Quick start above).
96
- 2. *"Set up Nucleux in this project"* → the agent runs `get_setup`, installs `@nucleux/react @nucleux/tokens`, and wires the Tailwind preset + CSS import.
97
- 3. *"Build a settings page with Nucleux"* → it searches, pulls the real props/examples, and writes accurate components.
109
+ | id | For |
110
+ | --- | --- |
111
+ | `app-shell` | Persistent left nav, top bar, mobile navigation sheet |
112
+ | `list-page` | Collection page: search + filter toolbar, sortable paginated table |
113
+ | `dashboard-overview` | KPI cards, progress panel, recent activity |
114
+ | `settings-page` | Tabbed settings: profile form + toggle rows |
115
+ | `page-states` | Loading, empty and error states for async data |
116
+ | `detail-page` | One record: breadcrumb, header with status + actions, tabbed facts, delete confirmation |
117
+ | `form-dialog` | Create/edit form in a dialog with validation and a success toast |
118
+ | `multi-step-form` | Wizard/onboarding/checkout: steps with Progress, per-step validation, review |
119
+ | `auth-sign-in` | Sign-in (and sign-up/reset) card with field and form-level errors |
120
+ | `analytics-charts` | Chart cards with ChartContainer (Recharts), token colors, accessible summaries |
121
+ | `task-board` | Kanban columns of task cards with a keyboard-friendly actions menu |
122
+
123
+ Each pattern's example is typechecked against the library and render- and
124
+ axe-tested in CI, so a pattern cannot reference a component or prop that does
125
+ not exist. When nothing matches, the tools say so and tell the agent to report
126
+ the gap instead of presenting something invented as a Nucleux pattern.
127
+
128
+ ## How the knowledge model works
129
+
130
+ | Source (in the repo) | Generated into | By |
131
+ | --- | --- | --- |
132
+ | `packages/*/src/index.tsx` | `src/catalog.json`: exports, structured Props | `scripts/gen-mcp-catalog.mjs` (TypeScript parser) |
133
+ | `knowledge/patterns/<id>/pattern.json` + `example.tsx` | `src/knowledge.json` | `scripts/gen-mcp-knowledge.mjs` (fails on unknown components) |
134
+ | `knowledge/workflow.md` | the skill, the AGENTS.md section, the prompt | `scripts/gen-agent-files.mjs` |
135
+
136
+ All of this runs in `pnpm --filter @nucleux/mcp build`. To add a pattern, see
137
+ [`knowledge/README.md`](../../knowledge/README.md).
138
+
139
+ ## Supported setups
140
+
141
+ - React ≥ 18 (tested with React 19 + Vite 6) and Tailwind CSS v3.4. Tailwind v4 is untested.
142
+ - Plain HTML: Tailwind classes only (`get_component` / `get_setup` with
143
+ `framework: "html"`), no interactive behavior.
144
+ - Not covered: Vue, Svelte, Angular, React Native (see `nucleux-mobile` for native).
145
+
146
+ ## Troubleshooting
147
+
148
+ - **Components render unstyled.** Your Tailwind `content` must include
149
+ `./node_modules/@nucleux/*/dist/**/*.{js,cjs}`: the tokens stylesheet holds
150
+ only the CSS variables and base reset; your build generates the component
151
+ classes. Also import `@nucleux/tokens/styles.css` before your own CSS.
152
+ - **No theme colors with a CommonJS Tailwind config.** Use
153
+ `require("@nucleux/tokens/preset").default`. The bare `require` returns the module object.
154
+ - **`ColumnDef` import fails in a pnpm project.** Type DataTable columns as
155
+ `DataTableProps<Row, unknown>["columns"]`, or add `@tanstack/react-table`.
156
+ - **The agent doesn't call the tools.** Check `claude mcp list` / `codex mcp list`,
157
+ and install the skill (`npx -y @nucleux/mcp init`).
158
+ - **Windows:** if the client can't find `npx`, use `"command": "npx.cmd"`.
159
+ - **Verify the server by hand:** `npx -y @nucleux/mcp` prints
160
+ `nucleux-mcp ready — … components, … patterns, … examples.` to stderr and
161
+ waits on stdin (it speaks JSON-RPC over stdio). Ctrl+C to exit.
162
+
163
+ ## Known limitations
164
+
165
+ - Eleven curated patterns. Not yet covered: e-commerce (product grid, cart),
166
+ calendars/scheduling, chat-first agent layouts as patterns (see
167
+ `get_example agent-chat`). Agents compose these from components and report
168
+ them as gaps.
169
+ - `Popover` (and so the menu-button composition) is not portaled: a menu
170
+ inside an `overflow-*` container is clipped. The `task-board` pattern
171
+ documents the layout that avoids it.
172
+ - Props are read syntactically: inherited DOM props are named by their
173
+ `extends` type, not expanded; types imported from other packages are shown
174
+ by name.
175
+ - `validate_design` checks a structured plan, not source code: it cannot see
176
+ props you pass through spreads or wrappers. The project's typecheck and
177
+ build remain the final check, and the workflow requires both.
98
178
 
99
179
  ## License
100
180