@castandcrew/spotlight-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.
- package/README.md +265 -0
- package/data/index.json +1541 -0
- package/dist/data/loader.d.ts +3 -0
- package/dist/data/loader.js +19 -0
- package/dist/data/loader.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +33 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/ask_spotlight.d.ts +2 -0
- package/dist/tools/ask_spotlight.js +122 -0
- package/dist/tools/ask_spotlight.js.map +1 -0
- package/dist/tools/get_component.d.ts +2 -0
- package/dist/tools/get_component.js +19 -0
- package/dist/tools/get_component.js.map +1 -0
- package/dist/tools/get_migration_guide.d.ts +2 -0
- package/dist/tools/get_migration_guide.js +19 -0
- package/dist/tools/get_migration_guide.js.map +1 -0
- package/dist/tools/get_pattern.d.ts +2 -0
- package/dist/tools/get_pattern.js +28 -0
- package/dist/tools/get_pattern.js.map +1 -0
- package/dist/tools/get_recipe.d.ts +2 -0
- package/dist/tools/get_recipe.js +72 -0
- package/dist/tools/get_recipe.js.map +1 -0
- package/dist/tools/get_token.d.ts +2 -0
- package/dist/tools/get_token.js +18 -0
- package/dist/tools/get_token.js.map +1 -0
- package/dist/tools/identify_pattern.d.ts +2 -0
- package/dist/tools/identify_pattern.js +96 -0
- package/dist/tools/identify_pattern.js.map +1 -0
- package/dist/tools/list_deprecated.d.ts +2 -0
- package/dist/tools/list_deprecated.js +10 -0
- package/dist/tools/list_deprecated.js.map +1 -0
- package/dist/tools/search_components.d.ts +2 -0
- package/dist/tools/search_components.js +27 -0
- package/dist/tools/search_components.js.map +1 -0
- package/dist/tools/search_tokens.d.ts +2 -0
- package/dist/tools/search_tokens.js +33 -0
- package/dist/tools/search_tokens.js.map +1 -0
- package/dist/tools/search_utility_classes.d.ts +2 -0
- package/dist/tools/search_utility_classes.js +37 -0
- package/dist/tools/search_utility_classes.js.map +1 -0
- package/dist/tools/validate_usage.d.ts +2 -0
- package/dist/tools/validate_usage.js +42 -0
- package/dist/tools/validate_usage.js.map +1 -0
- package/dist/transports/http.d.ts +1 -0
- package/dist/transports/http.js +71 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/stdio.d.ts +1 -0
- package/dist/transports/stdio.js +9 -0
- package/dist/transports/stdio.js.map +1 -0
- package/dist/types.d.ts +120 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# spotlight-mcp
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that exposes the **Spotlight Design System** (`@castandcrew/platform-ui`) to AI tools like Claude. It allows Claude to look up component props, design tokens, usage guidelines, MUI migration paths, and design rules — without hallucinating APIs that don't exist.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What it does
|
|
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.
|
|
10
|
+
|
|
11
|
+
| Tool | What Claude can ask |
|
|
12
|
+
|------|---------------------|
|
|
13
|
+
| `ask_spotlight` | "How should I label and place buttons?" — one-call answer context |
|
|
14
|
+
| `get_component` | "What props does `AutocompleteInput` have?" |
|
|
15
|
+
| `search_components` | "What components exist for date input?" |
|
|
16
|
+
| `get_token` | "What is the value of `--space-md`?" |
|
|
17
|
+
| `search_tokens` | "What tokens exist for spacing?" |
|
|
18
|
+
| `search_utility_classes` | "What's the CSS class for body text?" |
|
|
19
|
+
| `get_migration_guide` | "How do I migrate from MUI `Button`?" |
|
|
20
|
+
| `get_pattern` | "When should I use Modal vs Drawer?" |
|
|
21
|
+
| `validate_usage` | "Is this JSX correct per Spotlight rules?" |
|
|
22
|
+
| `list_deprecated` | "What components should I avoid?" |
|
|
23
|
+
|
|
24
|
+
All data comes from a static `data/index.json` file — no network calls, no AI inside the
|
|
25
|
+
server. The index has two sources, both merged by the [indexer](#updating-the-index):
|
|
26
|
+
|
|
27
|
+
- **Derived** — components, props, tokens, utility classes, and rules parsed automatically
|
|
28
|
+
from the `@castandcrew/platform-ui` source repo.
|
|
29
|
+
- **Hand-authored** — selection/decision guidance, code recipes, migration guides, icon and
|
|
30
|
+
layout references, and motion docs in [`content/`](./content/README.md). This is the
|
|
31
|
+
canonical home for Spotlight design knowledge being migrated off the `spotlight-knowledge`
|
|
32
|
+
Claude Code plugin (which the MCP is intended to replace).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Getting it running
|
|
37
|
+
|
|
38
|
+
> **Not yet published to npm — run it from source** (takes about a minute).
|
|
39
|
+
> **Prerequisites:** Node 18+ and `pnpm`.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/cast-and-crew/spotlight-mcp.git
|
|
43
|
+
cd spotlight-mcp
|
|
44
|
+
pnpm install # installs deps and builds dist/ via the prepare script
|
|
45
|
+
pnpm build # re-compile src/ → dist/ if needed
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Connect it to Claude Code (recommended)
|
|
49
|
+
|
|
50
|
+
Register the built server at **user scope** (available in every project):
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
claude mcp add spotlight --scope user -- node "$(pwd)/dist/index.js"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Start a new Claude Code session — the **10 tools** appear. They're all read-only lookups, so
|
|
57
|
+
auto-approve them to avoid per-call prompts: run `/permissions` and add `mcp__spotlight`, or
|
|
58
|
+
choose **"don't ask again"** on the first prompt.
|
|
59
|
+
|
|
60
|
+
Then just ask — e.g. *"Using spotlight, when should I use a Modal vs a Drawer?"* or *"what
|
|
61
|
+
color token for a critical background?"*. `ask_spotlight` is the one-call front door; the
|
|
62
|
+
other tools are precise follow-ups.
|
|
63
|
+
|
|
64
|
+
**Verify it's working:**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
./scripts/smoke.sh # boots the server, lists tools, runs a few real calls
|
|
68
|
+
pnpm test # full suite (index integrity, tool calls, content merge)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Other clients
|
|
72
|
+
|
|
73
|
+
- **MCP Inspector** (GUI to poke at tools): `npx @modelcontextprotocol/inspector node dist/index.js`
|
|
74
|
+
- **HTTP** (Claude.ai, custom integrations): `pnpm start:http` (or `PORT=8080 pnpm start:http`)
|
|
75
|
+
- `POST /mcp` — Streamable HTTP (recommended) · `GET /sse` + `POST /messages` — SSE legacy · `GET /health`
|
|
76
|
+
|
|
77
|
+
### Once published to npm
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
claude mcp add spotlight -- npx -y @castandcrew/spotlight-mcp
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
(or the equivalent `mcpServers` entry in settings). Consumers then get updates automatically
|
|
84
|
+
on each `npx` invocation — no cloning.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Development
|
|
89
|
+
|
|
90
|
+
After `pnpm install` (see [Getting it running](#getting-it-running)):
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pnpm dev:stdio # run from source in stdio mode (tsx, no build step)
|
|
94
|
+
pnpm dev:http # run from source in HTTP mode
|
|
95
|
+
pnpm build # compile src/ → dist/
|
|
96
|
+
pnpm start # run the built server (stdio)
|
|
97
|
+
pnpm test # run the vitest suite
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Testing
|
|
103
|
+
|
|
104
|
+
Three layers, fastest first. Build first with `pnpm build`.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# 1. stdio smoke test — boots the server, lists tools, runs a few real calls
|
|
108
|
+
pnpm build && ./scripts/smoke.sh
|
|
109
|
+
|
|
110
|
+
# 2. automated suite (21 checks: index integrity, end-to-end tool calls, manual-merge)
|
|
111
|
+
pnpm test
|
|
112
|
+
|
|
113
|
+
# 3. MCP Inspector — a GUI to invoke any tool with arbitrary arguments
|
|
114
|
+
npx @modelcontextprotocol/inspector node dist/index.js
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Live in Claude Code (the real test).** Register the built server, then ask design questions
|
|
118
|
+
and watch Claude call the tools:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
claude mcp add spotlight -- node "$(pwd)/dist/index.js"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Then ask things like *"should I use a Modal or a Drawer for a confirmation?"*, *"what props
|
|
125
|
+
does Button take?"*, *"how do I migrate a MUI Select?"*. To compare against the old
|
|
126
|
+
`spotlight-knowledge` plugin fairly, disable that plugin first — otherwise you can't tell
|
|
127
|
+
which source answered.
|
|
128
|
+
|
|
129
|
+
See [`docs/TESTING.md`](./docs/TESTING.md) for details.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Updating the index
|
|
134
|
+
|
|
135
|
+
The `data/index.json` file is the source of truth for all MCP tools. The indexer parses the
|
|
136
|
+
`@castandcrew/platform-ui` source repo **and** merges the hand-authored [`content/`](./content/README.md)
|
|
137
|
+
folder into a single index.
|
|
138
|
+
|
|
139
|
+
### Run the indexer
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Pass the repo root — the Nx monorepo layout is auto-detected
|
|
143
|
+
pnpm index /path/to/common-ui-component-library
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The indexer auto-detects the monorepo: it reads component/token source from
|
|
147
|
+
`packages/platform-ui/src` (falling back to `src/` for older checkouts) and docs from the
|
|
148
|
+
repo-root `docs/`. It reads:
|
|
149
|
+
|
|
150
|
+
| Source | What it extracts |
|
|
151
|
+
|--------|-----------------|
|
|
152
|
+
| `packages/platform-ui/src/{category}/{Component}/types.ts` | Props, types, JSDoc, defaults (MUI re-exports annotated `propsSource: "mui"`) |
|
|
153
|
+
| `…/{Component}/index.tsx` (or `index.ts`) | Component description, deprecation status |
|
|
154
|
+
| `…/{Component}/*.stories.tsx` | Story names and Storybook URLs |
|
|
155
|
+
| `…/{Component}/*.module.css` | Which design tokens each component uses |
|
|
156
|
+
| `…/Foundations/token-directory/outputs/token-dictionary.json` | Design tokens |
|
|
157
|
+
| `…/Foundations/token-directory/outputs/class-dictionary.json` | CSS utility classes |
|
|
158
|
+
| `docs/{category}/{Component}.md` | `whenToUse`, `whenNotToUse`, examples, MUI migration notes |
|
|
159
|
+
| `docs/SPOTLIGHT_RULES.md`, `docs/rules/` | Rules (forbidden/allowed components, conventions) |
|
|
160
|
+
| `guides/*.md` | Long-form usage patterns |
|
|
161
|
+
| `content/**` (this repo) | Hand-authored patterns, component overrides, and rules |
|
|
162
|
+
|
|
163
|
+
After running the indexer, commit the refreshed `data/index.json` and restart the MCP server.
|
|
164
|
+
|
|
165
|
+
### Current index coverage (last run: 2026-06-15)
|
|
166
|
+
|
|
167
|
+
| Metric | Count |
|
|
168
|
+
|--------|-------|
|
|
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) |
|
|
174
|
+
| Design tokens | 329 (light theme) |
|
|
175
|
+
| Utility classes | 218 |
|
|
176
|
+
| Rules | 9 |
|
|
177
|
+
| MUI migration entries | 25 |
|
|
178
|
+
| Deprecated entries | 20 |
|
|
179
|
+
|
|
180
|
+
Historical coverage gaps (pre-monorepo) are tracked in [`platform-ui-gaps.md`](./platform-ui-gaps.md).
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## Architecture
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
spotlight-mcp/
|
|
188
|
+
├── src/
|
|
189
|
+
│ ├── index.ts # Entry point — parses --http / --stdio flag
|
|
190
|
+
│ ├── server.ts # Creates McpServer and registers all tools
|
|
191
|
+
│ ├── types.ts # TypeScript types for index.json schema
|
|
192
|
+
│ ├── data/
|
|
193
|
+
│ │ └── loader.ts # Reads and caches data/index.json at runtime
|
|
194
|
+
│ ├── tools/ # One file per MCP tool
|
|
195
|
+
│ │ ├── ask_spotlight.ts # single-call front door (routes across all data)
|
|
196
|
+
│ │ ├── get_component.ts
|
|
197
|
+
│ │ ├── search_components.ts
|
|
198
|
+
│ │ ├── get_token.ts
|
|
199
|
+
│ │ ├── search_tokens.ts
|
|
200
|
+
│ │ ├── search_utility_classes.ts
|
|
201
|
+
│ │ ├── get_migration_guide.ts
|
|
202
|
+
│ │ ├── get_pattern.ts
|
|
203
|
+
│ │ ├── validate_usage.ts
|
|
204
|
+
│ │ └── list_deprecated.ts
|
|
205
|
+
│ └── transports/
|
|
206
|
+
│ ├── stdio.ts # stdio transport (Claude Code, CLI tools)
|
|
207
|
+
│ └── http.ts # Streamable HTTP + SSE legacy
|
|
208
|
+
├── content/ # Hand-authored knowledge merged into the index
|
|
209
|
+
│ ├── patterns/ # selection & decision guides, motion
|
|
210
|
+
│ ├── recipes/ # reusable UI code recipes
|
|
211
|
+
│ ├── reference/ # critical-rules, token usage, conventions
|
|
212
|
+
│ ├── icons/ layout/ migration/ overview/
|
|
213
|
+
│ ├── components/ # per-component usage overrides
|
|
214
|
+
│ └── rules/ # extra rules (frontmatter)
|
|
215
|
+
├── scripts/
|
|
216
|
+
│ ├── indexer.ts # Generates data/index.json (derived + content/)
|
|
217
|
+
│ └── smoke.sh # stdio smoke test
|
|
218
|
+
├── test/ # vitest: index-integrity, tools, manual-merge
|
|
219
|
+
├── docs/
|
|
220
|
+
│ └── TESTING.md # How to test (interactive + automated)
|
|
221
|
+
├── data/
|
|
222
|
+
│ └── index.json # Generated index — this is what the server reads
|
|
223
|
+
└── platform-ui-gaps.md # Historical (pre-monorepo) coverage gaps
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### How it connects to Claude
|
|
227
|
+
|
|
228
|
+
The MCP server does **not** call any AI. Claude calls **it**:
|
|
229
|
+
|
|
230
|
+
```
|
|
231
|
+
User question
|
|
232
|
+
↓
|
|
233
|
+
Claude (Anthropic) — reads tool descriptions, decides which to call
|
|
234
|
+
↓
|
|
235
|
+
spotlight-mcp server — looks up data/index.json
|
|
236
|
+
↓
|
|
237
|
+
Returns structured JSON to Claude
|
|
238
|
+
↓
|
|
239
|
+
Claude answers the user using real Spotlight data
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The tool descriptions (the text in each `server.tool(name, description, ...)` call) are the only "bridge" between natural language and the server. Well-written descriptions = Claude uses the right tool at the right time.
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Publishing
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
# Bump version
|
|
250
|
+
npm version patch # or minor / major
|
|
251
|
+
|
|
252
|
+
# Publish to npm
|
|
253
|
+
pnpm publish
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Users receive updates automatically on the next `npx` invocation.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Environment variables
|
|
261
|
+
|
|
262
|
+
| Variable | Default | Description |
|
|
263
|
+
|----------|---------|-------------|
|
|
264
|
+
| `PORT` | `3000` | HTTP server port (only in `--http` mode) |
|
|
265
|
+
| `SPOTLIGHT_INDEX_PATH` | `data/index.json` (bundled) | Path to a custom index file |
|