@castandcrew/spotlight-mcp 0.1.3 → 0.1.5

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 (53) hide show
  1. package/README.md +139 -24
  2. package/data/index.json +49391 -1197
  3. package/dist/data/health.d.ts +33 -0
  4. package/dist/data/health.js +111 -0
  5. package/dist/data/health.js.map +1 -0
  6. package/dist/data/loader.d.ts +19 -0
  7. package/dist/data/loader.js +61 -4
  8. package/dist/data/loader.js.map +1 -1
  9. package/dist/lib/regex-safety.d.ts +14 -0
  10. package/dist/lib/regex-safety.js +34 -0
  11. package/dist/lib/regex-safety.js.map +1 -0
  12. package/dist/server.js +25 -1
  13. package/dist/server.js.map +1 -1
  14. package/dist/tools/_fuzzy.d.ts +49 -0
  15. package/dist/tools/_fuzzy.js +103 -0
  16. package/dist/tools/_fuzzy.js.map +1 -0
  17. package/dist/tools/_guard.d.ts +31 -0
  18. package/dist/tools/_guard.js +62 -0
  19. package/dist/tools/_guard.js.map +1 -0
  20. package/dist/tools/_synonyms.d.ts +1 -0
  21. package/dist/tools/_synonyms.js +28 -0
  22. package/dist/tools/_synonyms.js.map +1 -0
  23. package/dist/tools/ask_spotlight.js +67 -5
  24. package/dist/tools/ask_spotlight.js.map +1 -1
  25. package/dist/tools/get_component.js +14 -5
  26. package/dist/tools/get_component.js.map +1 -1
  27. package/dist/tools/get_migration_guide.js +4 -2
  28. package/dist/tools/get_migration_guide.js.map +1 -1
  29. package/dist/tools/get_pattern.js +22 -7
  30. package/dist/tools/get_pattern.js.map +1 -1
  31. package/dist/tools/get_recipe.js +4 -2
  32. package/dist/tools/get_recipe.js.map +1 -1
  33. package/dist/tools/get_token.js +7 -4
  34. package/dist/tools/get_token.js.map +1 -1
  35. package/dist/tools/identify_pattern.js +7 -5
  36. package/dist/tools/identify_pattern.js.map +1 -1
  37. package/dist/tools/list_deprecated.js +4 -2
  38. package/dist/tools/list_deprecated.js.map +1 -1
  39. package/dist/tools/search_components.js +9 -3
  40. package/dist/tools/search_components.js.map +1 -1
  41. package/dist/tools/search_tokens.js +41 -10
  42. package/dist/tools/search_tokens.js.map +1 -1
  43. package/dist/tools/search_utility_classes.js +4 -2
  44. package/dist/tools/search_utility_classes.js.map +1 -1
  45. package/dist/tools/validate_usage.js +25 -5
  46. package/dist/tools/validate_usage.js.map +1 -1
  47. package/dist/transports/http.js +21 -1
  48. package/dist/transports/http.js.map +1 -1
  49. package/dist/types.d.ts +19 -2
  50. package/dist/version.d.ts +1 -0
  51. package/dist/version.js +8 -0
  52. package/dist/version.js.map +1 -0
  53. package/package.json +10 -7
package/README.md CHANGED
@@ -6,7 +6,7 @@ An MCP (Model Context Protocol) server that exposes the **Spotlight Design Syste
6
6
 
7
7
  ## What it does
8
8
 
9
- When connected to Claude Code (or any MCP-compatible client), `spotlight-mcp` gives Claude access to 10 tools. **`ask_spotlight` is the front door** — one call routes across components, guidance, tokens, classes, and migration, so the client doesn't have to orchestrate several lookups. The rest are precise follow-ups.
9
+ When connected to Claude Code (or any MCP-compatible client), `spotlight-mcp` gives Claude access to 12 tools. **`ask_spotlight` is the front door** — one call routes across components, guidance, tokens, classes, and migration, so the client doesn't have to orchestrate several lookups. The rest are precise follow-ups.
10
10
 
11
11
  | Tool | What Claude can ask |
12
12
  |------|---------------------|
@@ -35,8 +35,23 @@ server. The index has two sources, both merged by the [indexer](#updating-the-in
35
35
 
36
36
  ## Getting it running
37
37
 
38
- > **Not yet published to npm — run it from source** (takes about a minute).
39
- > **Prerequisites:** Node 18+ and `pnpm`.
38
+ > **Use `@castandcrew/spotlight-mcp` `0.1.4` or later.** Earlier npm versions (`0.1.0`–`0.1.3`)
39
+ > ship an empty index (0 components, 0 tokens, 0 utility classes), so `search_components`,
40
+ > `get_component`, `search_tokens`, `get_token` and `search_utility_classes` return nothing.
41
+ > Do not use them. `0.1.4` is the first release with a populated `data/index.json`:
42
+ > 169 entries (165 unique component names), 329 tokens, 218 utility classes, 111 patterns and
43
+ > 71 rules. See [Via npm](#via-npm) to connect it without cloning anything.
44
+ >
45
+ > **You can also run it from source.** A fresh clone is fine: `data/index.json` is committed
46
+ > with real data, so `pnpm install && pnpm build` is enough to get a working server. Regenerate
47
+ > it only when the upstream library changes — see [Updating the index](#updating-the-index).
48
+ >
49
+ > **If the index is ever empty, the server says so.** It does not answer `[]` as if the design
50
+ > system were empty: each tool returns an explicit error naming the index path, the counts it
51
+ > found and the command to fix it, and a status banner is written to stderr at startup. See
52
+ > [When the index is empty](#when-the-index-is-empty).
53
+ >
54
+ > **Prerequisites (source):** Node 18+ and `pnpm`.
40
55
 
41
56
  ```bash
42
57
  git clone https://github.com/cast-and-crew/spotlight-mcp.git
@@ -53,7 +68,7 @@ Register the built server at **user scope** (available in every project):
53
68
  claude mcp add spotlight --scope user -- node "$(pwd)/dist/index.js"
54
69
  ```
55
70
 
56
- Start a new Claude Code session — the **10 tools** appear. They're all read-only lookups, so
71
+ Start a new Claude Code session — the **12 tools** appear. They're all read-only lookups, so
57
72
  auto-approve them to avoid per-call prompts: run `/permissions` and add `mcp__spotlight`, or
58
73
  choose **"don't ask again"** on the first prompt.
59
74
 
@@ -68,20 +83,89 @@ other tools are precise follow-ups.
68
83
  pnpm test # full suite (index integrity, tool calls, content merge)
69
84
  ```
70
85
 
86
+ ### Connect it to Claude Desktop
87
+
88
+ Claude Desktop doesn't use the `claude mcp add` CLI — it reads local MCP servers from its own
89
+ config file. Point it at the built server:
90
+
91
+ **Via the UI:** Settings → Developer → Local MCP servers → **Edit config**.
92
+
93
+ **Or edit the file directly** (macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`):
94
+
95
+ ```json
96
+ {
97
+ "mcpServers": {
98
+ "spotlight": {
99
+ "command": "node",
100
+ "args": ["/absolute/path/to/spotlight-mcp/dist/index.js"]
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ Restart Claude Desktop. Settings → Developer → Local MCP servers should show `spotlight` as
107
+ **running**.
108
+
109
+ **Verify it's working:**
110
+
111
+ ```bash
112
+ ps aux | grep spotlight-mcp # confirms the process is alive
113
+ tail -f ~/Library/Logs/Claude/mcp-server-spotlight.log # confirms the handshake succeeded
114
+ ```
115
+
116
+ Look for `"Server started and connected successfully"` with no error after it.
117
+
118
+ > **Scope:** this config covers Claude Desktop's **Chat**. The **Code Tab** is
119
+ > Claude Code and reads Claude Code's own config (`~/.claude.json`) — register the server there
120
+ > with `claude mcp add` (section above) or install the `spotlight-cowork` plugin, which bundles it.
121
+ > `mcp-server-spotlight.log` records Chat's server process. (Claude Desktop merged Cowork into
122
+ > Chat — Cowork capabilities live in the same conversation now, there is no separate Cowork
123
+ > option; the `spotlight-cowork` plugin keeps its name.)
124
+ > (An earlier draft of this README claimed the Code Tab could not reach the server; that was a
125
+ > misconfigured path in `~/.claude.json`, not a limitation — verified in SPT-1526 v2, 2026-09-08.)
126
+
71
127
  ### Other clients
72
128
 
73
129
  - **MCP Inspector** (GUI to poke at tools): `npx @modelcontextprotocol/inspector node dist/index.js`
74
130
  - **HTTP** (Claude.ai, custom integrations): `pnpm start:http` (or `PORT=8080 pnpm start:http`)
75
131
  - `POST /mcp` — Streamable HTTP (recommended) · `GET /sse` + `POST /messages` — SSE legacy · `GET /health`
132
+ - The HTTP server has **no authentication** and accepts requests from any origin (CORS is open so browser clients can connect). Run it only on a trusted network; the network boundary is the protection.
133
+
134
+ ### Via npm
76
135
 
77
- ### Once published to npm
136
+ `0.1.4` or later is required. `npx -y @castandcrew/spotlight-mcp` downloads and starts the
137
+ server; it ships the full index, so no clone or build is needed. Pin a version range so a
138
+ future release cannot change your setup unannounced, for example
139
+ `@castandcrew/spotlight-mcp@0.1.4` (exact) or `@castandcrew/spotlight-mcp@~0.1.4` (patch
140
+ updates only).
141
+
142
+ Versions `0.1.0`–`0.1.3` (including the `0.1.3` pipeline smoke test) have an empty index and
143
+ predate the empty-index guard described below. Do not use them.
144
+
145
+ The plugins in `claude-plugins` (`spotlight-cowork`, `spotlight-remediation`,
146
+ `spotlight-advisor`, `spotlight-patterns`, `repo-spec` and `spotlight-design`) start the server
147
+ through `npx -y @castandcrew/spotlight-mcp` in their `.mcp.json`.
148
+
149
+ **Claude Code:**
78
150
 
79
151
  ```bash
80
152
  claude mcp add spotlight -- npx -y @castandcrew/spotlight-mcp
81
153
  ```
82
154
 
83
- (or the equivalent `mcpServers` entry in settings). Consumers then get updates automatically
84
- on each `npx` invocation — no cloning.
155
+ **Claude Desktop** (`~/Library/Application Support/Claude/claude_desktop_config.json`):
156
+
157
+ ```json
158
+ {
159
+ "mcpServers": {
160
+ "spotlight": {
161
+ "command": "npx",
162
+ "args": ["-y", "@castandcrew/spotlight-mcp"]
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ Same config works on any machine — no absolute path, no local checkout required.
85
169
 
86
170
  ---
87
171
 
@@ -162,20 +246,50 @@ repo-root `docs/`. It reads:
162
246
 
163
247
  After running the indexer, commit the refreshed `data/index.json` and restart the MCP server.
164
248
 
165
- ### Current index coverage (last run: 2026-06-15)
249
+ **The indexer refuses to write an index that is missing derived data.** If `components`, `tokens`,
250
+ `utilityClasses`, `patterns` or `rules` would come out empty, it prints what it resolved and why
251
+ each collection is empty, and leaves the existing `data/index.json` untouched. Override with
252
+ `--allow-empty` if you really need the file written — but do not commit the result.
253
+
254
+ This matters because `patterns` and `rules` are mostly merged from this repo's own `content/`,
255
+ so they stay populated even when the source path is wrong. An index generated against a bad path
256
+ looks plausible (`patterns: 95, rules: 63`) while being useless. That is how the empty 0.1.3
257
+ index shipped.
258
+
259
+ ### When the index is empty
260
+
261
+ The server never answers `[]` as if the design system had no such component. Two failure classes:
262
+
263
+ - **Unusable** — the index file is missing, unreadable, not JSON, or not shaped like an index.
264
+ `loadIndex()` throws, so every tool returns an error.
265
+ - **Degraded** — the index parses but some collections are empty. Only the tools that need the
266
+ missing data error; the rest keep working. With the 0.1.3 index, for example, `get_pattern`,
267
+ `get_recipe` and `identify_pattern` still answer correctly from the 103 patterns it did have.
268
+
269
+ Either way a status banner goes to **stderr** at startup (visible in
270
+ `~/Library/Logs/Claude/mcp-server-spotlight.log` for Claude Desktop), `GET /health` reports
271
+ per-collection counts in HTTP mode, and each failing tool returns a JSON error naming the resolved
272
+ index path, the counts found, the `generated` date and the command to fix it. The server does not
273
+ exit — a dead server tells the model nothing.
274
+
275
+ Tools guard only on what they read: `validate_usage`, for instance, requires both `rules` **and**
276
+ `components`, because its deprecated-component check reads `deprecated`, which the indexer derives
277
+ from `components`. With 0 components it would otherwise report `valid: true` for any snippet.
278
+
279
+ ### Current index coverage (`generated: 2026-09-01`)
166
280
 
167
281
  | Metric | Count |
168
282
  |--------|-------|
169
- | Components | 105 (13 categories) |
170
- | Components with props | 53 (+18 annotated as MUI re-exports) |
171
- | Components with `whenToUse` | 41 |
172
- | Components with stories | 85 |
173
- | Patterns | 75 (selection 23, recipe 12, reference 8, migration 8, guide 8, rules 5, layout 5, icon 4, overview 2) |
283
+ | Components | 84 (11 categories) |
284
+ | Components with props | 52 (all parsed locally — no MUI re-exports in the current index) |
285
+ | Components with `usage.whenToUse` | 39 (`whenNotToUse` 42, `examples` 19) |
286
+ | Components with stories | 70 |
287
+ | Patterns | 111 (selection 41, recipe 26, guide 11, reference 9, migration 8, rules 5, layout 5, icon 4, overview 2) |
174
288
  | Design tokens | 329 (light theme) |
175
289
  | Utility classes | 218 |
176
- | Rules | 9 |
177
- | MUI migration entries | 25 |
178
- | Deprecated entries | 20 |
290
+ | Rules | 71 |
291
+ | MUI migration entries | 24 |
292
+ | Deprecated entries | 0 (nothing is deprecated upstream today) |
179
293
 
180
294
  Historical coverage gaps (pre-monorepo) are tracked in [`platform-ui-gaps.md`](./platform-ui-gaps.md).
181
295
 
@@ -217,7 +331,8 @@ spotlight-mcp/
217
331
  │ └── smoke.sh # stdio smoke test
218
332
  ├── test/ # vitest: index-integrity, tools, manual-merge
219
333
  ├── docs/
220
- │ └── TESTING.md # How to test (interactive + automated)
334
+ │ ├── TESTING.md # How to test (interactive + automated)
335
+ │ └── RELEASING.md # Branching, versioning, release runbook
221
336
  ├── data/
222
337
  │ └── index.json # Generated index — this is what the server reads
223
338
  └── platform-ui-gaps.md # Historical (pre-monorepo) coverage gaps
@@ -245,15 +360,15 @@ The tool descriptions (the text in each `server.tool(name, description, ...)` ca
245
360
 
246
361
  ## Publishing
247
362
 
248
- ```bash
249
- # Bump version
250
- npm version patch # or minor / major
363
+ Releases are tagged on `main` and staged on npm by the **Release** GitHub workflow; a maintainer
364
+ approves the staged version in npm. **Do not run `npm publish` / `pnpm publish` from a laptop:** it
365
+ skips the checks that stop an empty index from shipping (that is how `0.1.3` went out).
251
366
 
252
- # Publish to npm
253
- pnpm publish
254
- ```
367
+ Branching, versioning rules, the step-by-step release runbook and rollback are in
368
+ [`docs/RELEASING.md`](./docs/RELEASING.md).
255
369
 
256
- Users receive updates automatically on the next `npx` invocation.
370
+ Clients that run `npx -y @castandcrew/spotlight-mcp` (without a pinned version) get the latest
371
+ release on the next start; pin a range (see [Via npm](#via-npm)) to avoid that.
257
372
 
258
373
  ---
259
374