@react-spa-scaffold/mcp 0.3.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 +423 -0
- package/dist/features/index.d.ts +5 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +3 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/registry.d.ts +10 -0
- package/dist/features/registry.d.ts.map +1 -0
- package/dist/features/registry.js +508 -0
- package/dist/features/registry.js.map +1 -0
- package/dist/features/types.d.ts +45 -0
- package/dist/features/types.d.ts.map +1 -0
- package/dist/features/types.js +5 -0
- package/dist/features/types.js.map +1 -0
- package/dist/features/versions.d.ts +16 -0
- package/dist/features/versions.d.ts.map +1 -0
- package/dist/features/versions.js +46 -0
- package/dist/features/versions.js.map +1 -0
- package/dist/features/versions.json +5 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/docs.d.ts +29 -0
- package/dist/resources/docs.d.ts.map +1 -0
- package/dist/resources/docs.js +105 -0
- package/dist/resources/docs.js.map +1 -0
- package/dist/resources/index.d.ts +2 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +2 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/server.d.ts +12 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +115 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/get-example.d.ts +51 -0
- package/dist/tools/get-example.d.ts.map +1 -0
- package/dist/tools/get-example.js +90 -0
- package/dist/tools/get-example.js.map +1 -0
- package/dist/tools/get-features.d.ts +30 -0
- package/dist/tools/get-features.d.ts.map +1 -0
- package/dist/tools/get-features.js +46 -0
- package/dist/tools/get-features.js.map +1 -0
- package/dist/tools/get-scaffold.d.ts +77 -0
- package/dist/tools/get-scaffold.d.ts.map +1 -0
- package/dist/tools/get-scaffold.js +153 -0
- package/dist/tools/get-scaffold.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/utils/docs.d.ts +14 -0
- package/dist/utils/docs.d.ts.map +1 -0
- package/dist/utils/docs.js +64 -0
- package/dist/utils/docs.js.map +1 -0
- package/dist/utils/examples.d.ts +27 -0
- package/dist/utils/examples.d.ts.map +1 -0
- package/dist/utils/examples.js +399 -0
- package/dist/utils/examples.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/paths.d.ts +28 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +40 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/scaffold.d.ts +50 -0
- package/dist/utils/scaffold.d.ts.map +1 -0
- package/dist/utils/scaffold.js +500 -0
- package/dist/utils/scaffold.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +19 -0
- package/dist/version.js.map +1 -0
- package/package.json +63 -0
- package/templates/.bundled +0 -0
- package/templates/CLAUDE.md +145 -0
- package/templates/docs/API_REFERENCE.md +58 -0
- package/templates/docs/ARCHITECTURE.md +185 -0
- package/templates/docs/CODING_STANDARDS.md +53 -0
- package/templates/docs/COMPONENT_GUIDELINES.md +301 -0
- package/templates/docs/E2E_TESTING.md +116 -0
- package/templates/docs/INTERNATIONALIZATION.md +67 -0
- package/templates/docs/TESTING.md +259 -0
- package/templates/docs/WORKFLOW.md +170 -0
- package/templates/src/App.tsx +42 -0
- package/templates/src/components/layout/Header.tsx +19 -0
- package/templates/src/components/layout/index.ts +1 -0
- package/templates/src/components/shared/ErrorBoundary/ErrorBoundary.tsx +104 -0
- package/templates/src/components/shared/ErrorBoundary/index.ts +1 -0
- package/templates/src/components/shared/LanguageSwitcher/LanguageSwitcher.tsx +45 -0
- package/templates/src/components/shared/LanguageSwitcher/index.ts +1 -0
- package/templates/src/components/shared/SEO/SEO.tsx +55 -0
- package/templates/src/components/shared/SEO/index.ts +1 -0
- package/templates/src/components/shared/ThemeToggle/ThemeToggle.tsx +41 -0
- package/templates/src/components/shared/ThemeToggle/index.ts +1 -0
- package/templates/src/components/shared/index.ts +4 -0
- package/templates/src/components/ui/button.tsx +48 -0
- package/templates/src/components/ui/dropdown-menu.tsx +228 -0
- package/templates/src/components/ui/form-error.tsx +95 -0
- package/templates/src/components/ui/loading.tsx +58 -0
- package/templates/src/components/ui/skeleton.tsx +52 -0
- package/templates/src/components/ui/sonner.tsx +34 -0
- package/templates/src/components/ui/spinner.tsx +40 -0
- package/templates/src/components/ui/visually-hidden.tsx +51 -0
- package/templates/src/contexts/mobileContext.tsx +66 -0
- package/templates/src/contexts/queryContext.tsx +28 -0
- package/templates/src/hooks/index.ts +7 -0
- package/templates/src/hooks/useContactForm.ts +33 -0
- package/templates/src/hooks/useExampleQuery.ts +20 -0
- package/templates/src/hooks/useLanguage.ts +23 -0
- package/templates/src/hooks/useMediaQuery.ts +53 -0
- package/templates/src/hooks/useThemeEffect.ts +31 -0
- package/templates/src/hooks/useTouchSizes.ts +16 -0
- package/templates/src/i18n/config.ts +11 -0
- package/templates/src/i18n/detectLanguage.ts +57 -0
- package/templates/src/i18n/index.ts +20 -0
- package/templates/src/i18n/loadCatalog.ts +30 -0
- package/templates/src/index.css +98 -0
- package/templates/src/lib/api.ts +142 -0
- package/templates/src/lib/config.ts +15 -0
- package/templates/src/lib/constants.ts +8 -0
- package/templates/src/lib/env.ts +53 -0
- package/templates/src/lib/format.ts +119 -0
- package/templates/src/lib/index.ts +24 -0
- package/templates/src/lib/routes.ts +11 -0
- package/templates/src/lib/storage.ts +91 -0
- package/templates/src/lib/storageKeys.ts +10 -0
- package/templates/src/lib/utils.ts +6 -0
- package/templates/src/lib/validations.ts +39 -0
- package/templates/src/locales/de.po +65 -0
- package/templates/src/locales/en.po +65 -0
- package/templates/src/locales/es.po +65 -0
- package/templates/src/main.tsx +107 -0
- package/templates/src/mocks/fixtures/index.ts +1 -0
- package/templates/src/mocks/fixtures/todos.ts +40 -0
- package/templates/src/mocks/handlers/index.ts +7 -0
- package/templates/src/mocks/handlers/todos.ts +59 -0
- package/templates/src/mocks/index.ts +3 -0
- package/templates/src/mocks/node.ts +9 -0
- package/templates/src/pages/Home.tsx +27 -0
- package/templates/src/pages/NotFound.tsx +28 -0
- package/templates/src/pages/index.ts +2 -0
- package/templates/src/stores/index.ts +2 -0
- package/templates/src/stores/preferencesStore.ts +85 -0
- package/templates/src/test/index.ts +8 -0
- package/templates/src/test/mocks.ts +17 -0
- package/templates/src/test/providers.tsx +54 -0
- package/templates/src/test-setup.ts +54 -0
- package/templates/src/types/api.ts +31 -0
- package/templates/src/types/index.ts +2 -0
- package/templates/src/types/preferences.ts +5 -0
- package/templates/src/vite-env.d.ts +10 -0
- package/templates/tests/unit/components/ErrorBoundary.test.tsx +193 -0
- package/templates/tests/unit/components/Header.test.tsx +33 -0
- package/templates/tests/unit/components/LanguageSwitcher.test.tsx +40 -0
- package/templates/tests/unit/components/Loading.test.tsx +76 -0
- package/templates/tests/unit/components/SEO.test.tsx +80 -0
- package/templates/tests/unit/components/ThemeToggle.test.tsx +62 -0
- package/templates/tests/unit/contexts/mobileContext.test.tsx +54 -0
- package/templates/tests/unit/hooks/useContactForm.test.ts +60 -0
- package/templates/tests/unit/hooks/useExampleQuery.test.tsx +94 -0
- package/templates/tests/unit/hooks/useLanguage.test.tsx +75 -0
- package/templates/tests/unit/hooks/useMediaQuery.test.ts +57 -0
- package/templates/tests/unit/hooks/useThemeEffect.test.ts +42 -0
- package/templates/tests/unit/i18n/detectLanguage.test.ts +40 -0
- package/templates/tests/unit/i18n/loadCatalog.test.ts +70 -0
- package/templates/tests/unit/lib/api.test.ts +142 -0
- package/templates/tests/unit/lib/format.test.ts +100 -0
- package/templates/tests/unit/lib/storage.test.ts +90 -0
- package/templates/tests/unit/lib/utils.test.ts +19 -0
- package/templates/tests/unit/lib/validations.test.ts +56 -0
- package/templates/tests/unit/stores/preferencesStore.test.ts +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# react-spa-scaffold MCP Server
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
> **TL;DR:** An MCP server that provides knowledge and patterns for AI agents to scaffold React projects. The AI asks what you need, this server provides the info, and the AI generates your project.
|
|
8
|
+
|
|
9
|
+
**3 Tools:**
|
|
10
|
+
|
|
11
|
+
- `get_features` — List available feature modules
|
|
12
|
+
- `get_scaffold` — Get dependencies and file structure for selected features
|
|
13
|
+
- `get_example` — Get real code patterns from react-spa-scaffold
|
|
14
|
+
|
|
15
|
+
## Philosophy
|
|
16
|
+
|
|
17
|
+
**MCP provides knowledge, AI provides execution.**
|
|
18
|
+
|
|
19
|
+
| MCP Server Does | AI Agent Does |
|
|
20
|
+
| ------------------------ | ------------------------ |
|
|
21
|
+
| Lists available features | Decides which to include |
|
|
22
|
+
| Reports dependencies | Writes package.json |
|
|
23
|
+
| Provides code patterns | Generates actual files |
|
|
24
|
+
| Documents conventions | Follows the patterns |
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# From monorepo root
|
|
30
|
+
npm install && npm run mcp:build
|
|
31
|
+
|
|
32
|
+
# Test with MCP Inspector
|
|
33
|
+
npm run mcp:inspect
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
Add to your MCP client config:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"mcpServers": {
|
|
43
|
+
"react-spa-scaffold": {
|
|
44
|
+
"command": "npx",
|
|
45
|
+
"args": ["@react-spa-scaffold/mcp"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
| Client | Config Location |
|
|
52
|
+
| -------------- | ----------------------------------------------------------------- |
|
|
53
|
+
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
54
|
+
| VS Code | `.vscode/mcp.json` |
|
|
55
|
+
| Claude Code | `.claude/settings.json` |
|
|
56
|
+
|
|
57
|
+
<details>
|
|
58
|
+
<summary>Local Development Setup</summary>
|
|
59
|
+
|
|
60
|
+
For development without publishing:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
cd packages/mcp
|
|
64
|
+
npm run build
|
|
65
|
+
npm link # Makes react-spa-scaffold-mcp available globally
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Then use in config:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"react-spa-scaffold": {
|
|
74
|
+
"command": "react-spa-scaffold-mcp"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Or point directly to the built file:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"mcpServers": {
|
|
85
|
+
"react-spa-scaffold": {
|
|
86
|
+
"command": "node",
|
|
87
|
+
"args": ["/path/to/packages/mcp/dist/index.js"]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
</details>
|
|
94
|
+
|
|
95
|
+
## Available Features
|
|
96
|
+
|
|
97
|
+
10 feature modules that can be combined:
|
|
98
|
+
|
|
99
|
+
| Feature | Description | Required |
|
|
100
|
+
| ---------- | --------------------------------------------- | -------- |
|
|
101
|
+
| `core` | React 19 + TypeScript + Vite 7 + Tailwind CSS | Always |
|
|
102
|
+
| `routing` | React Router 7 with lazy loading | Optional |
|
|
103
|
+
| `ui` | Shadcn/UI + icons + theming + toasts | Optional |
|
|
104
|
+
| `forms` | React Hook Form + Zod validation | Optional |
|
|
105
|
+
| `state` | Zustand with persistence | Optional |
|
|
106
|
+
| `api` | TanStack Query + API client | Optional |
|
|
107
|
+
| `i18n` | LinguiJS internationalization | Optional |
|
|
108
|
+
| `testing` | Vitest + Playwright + MSW | Optional |
|
|
109
|
+
| `devtools` | ESLint + Prettier + Husky | Optional |
|
|
110
|
+
| `ci` | GitHub Actions + Lighthouse | Optional |
|
|
111
|
+
|
|
112
|
+
## Tools
|
|
113
|
+
|
|
114
|
+
### `get_features`
|
|
115
|
+
|
|
116
|
+
List all available feature modules.
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const result = await client.callTool('get_features', {});
|
|
120
|
+
// Returns: { id, name, description, required, includes }[]
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### `get_scaffold`
|
|
124
|
+
|
|
125
|
+
Get complete scaffold information for selected features.
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const result = await client.callTool('get_scaffold', {
|
|
129
|
+
features: ['routing', 'ui', 'forms', 'testing'],
|
|
130
|
+
projectName: 'my-app',
|
|
131
|
+
includeExamples: false,
|
|
132
|
+
});
|
|
133
|
+
// Returns: { packageJson, fileStructure, configFiles, setupCommands, instructions }
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### `get_example`
|
|
137
|
+
|
|
138
|
+
Get real code from react-spa-scaffold for a specific pattern.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
const result = await client.callTool('get_example', {
|
|
142
|
+
pattern: 'component-shared',
|
|
143
|
+
});
|
|
144
|
+
// Returns: { pattern, description, filePath, keyPoints, code, usage }
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Available Patterns
|
|
148
|
+
|
|
149
|
+
| Category | Patterns |
|
|
150
|
+
| ---------- | ---------------------------------------------------------- |
|
|
151
|
+
| Components | `component-ui`, `component-shared`, `component-layout` |
|
|
152
|
+
| Hooks | `hook-state`, `hook-query`, `hook-form`, `hook-effect` |
|
|
153
|
+
| State | `zustand-store` |
|
|
154
|
+
| Pages | `page-component`, `lazy-page` |
|
|
155
|
+
| Context | `context-provider`, `query-provider` |
|
|
156
|
+
| API | `api-client` |
|
|
157
|
+
| Testing | `test-component`, `test-hook`, `test-store`, `msw-handler` |
|
|
158
|
+
| i18n | `trans-component`, `t-function`, `use-language-hook` |
|
|
159
|
+
| Utilities | `zod-schema`, `storage-utility`, `format-utility` |
|
|
160
|
+
| UI | `theme-toggle`, `seo-component` |
|
|
161
|
+
|
|
162
|
+
<details>
|
|
163
|
+
<summary>Full Pattern Reference</summary>
|
|
164
|
+
|
|
165
|
+
**Components:**
|
|
166
|
+
|
|
167
|
+
- `component-ui` — Shadcn/UI component with CVA variants
|
|
168
|
+
- `component-shared` — Feature component with store integration
|
|
169
|
+
- `component-layout` — Layout component for page structure
|
|
170
|
+
|
|
171
|
+
**Hooks:**
|
|
172
|
+
|
|
173
|
+
- `hook-state` — State hook with browser API
|
|
174
|
+
- `hook-query` — TanStack Query data fetching
|
|
175
|
+
- `hook-form` — React Hook Form + Zod
|
|
176
|
+
- `hook-effect` — Effect-only hook
|
|
177
|
+
- `use-language-hook` — Language/locale management
|
|
178
|
+
|
|
179
|
+
**State:**
|
|
180
|
+
|
|
181
|
+
- `zustand-store` — Store with persistence and devtools
|
|
182
|
+
|
|
183
|
+
**Pages:**
|
|
184
|
+
|
|
185
|
+
- `page-component` — Page with i18n
|
|
186
|
+
- `lazy-page` — Lazy loading pattern
|
|
187
|
+
|
|
188
|
+
**Context:**
|
|
189
|
+
|
|
190
|
+
- `context-provider` — React Context with provider
|
|
191
|
+
- `query-provider` — TanStack Query setup
|
|
192
|
+
|
|
193
|
+
**API:**
|
|
194
|
+
|
|
195
|
+
- `api-client` — Typed API client
|
|
196
|
+
|
|
197
|
+
**Testing:**
|
|
198
|
+
|
|
199
|
+
- `test-component` — Component test
|
|
200
|
+
- `test-hook` — Hook test with renderHook
|
|
201
|
+
- `test-store` — Zustand store test
|
|
202
|
+
- `msw-handler` — MSW request handler
|
|
203
|
+
|
|
204
|
+
**i18n:**
|
|
205
|
+
|
|
206
|
+
- `trans-component` — i18n Trans usage
|
|
207
|
+
- `t-function` — i18n t() usage
|
|
208
|
+
|
|
209
|
+
**Utilities:**
|
|
210
|
+
|
|
211
|
+
- `zod-schema` — Validation schema
|
|
212
|
+
- `storage-utility` — localStorage utilities
|
|
213
|
+
- `format-utility` — Formatting utilities
|
|
214
|
+
|
|
215
|
+
**UI:**
|
|
216
|
+
|
|
217
|
+
- `theme-toggle` — Theme toggle component
|
|
218
|
+
- `seo-component` — SEO meta tags
|
|
219
|
+
|
|
220
|
+
</details>
|
|
221
|
+
|
|
222
|
+
## Resources
|
|
223
|
+
|
|
224
|
+
Documentation resources read from actual files (auto-synced):
|
|
225
|
+
|
|
226
|
+
| URI | Source | Description |
|
|
227
|
+
| --------------------- | ------------------------------------------------- | ------------------------- |
|
|
228
|
+
| `docs://conventions` | `CODING_STANDARDS.md` + `COMPONENT_GUIDELINES.md` | Code patterns and naming |
|
|
229
|
+
| `docs://architecture` | `ARCHITECTURE.md` | Technology stack and flow |
|
|
230
|
+
| `docs://testing` | `TESTING.md` + `E2E_TESTING.md` | Unit and E2E testing |
|
|
231
|
+
| `docs://i18n` | `INTERNATIONALIZATION.md` | LinguiJS setup |
|
|
232
|
+
| `docs://api` | `API_REFERENCE.md` | API client patterns |
|
|
233
|
+
| `docs://claude` | `CLAUDE.md` | AI assistant guidance |
|
|
234
|
+
|
|
235
|
+
## Example Workflow
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
User Request → get_features() → Select → get_scaffold() → Create → get_example() → Generate
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Step 1: Query features**
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
const features = await mcp.callTool('get_features', {});
|
|
245
|
+
// Returns: core, routing, ui, forms, state, api, i18n, testing, devtools, ci
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Step 2: Get scaffold**
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const scaffold = await mcp.callTool('get_scaffold', {
|
|
252
|
+
features: ['routing', 'ui', 'forms'],
|
|
253
|
+
projectName: 'my-app',
|
|
254
|
+
});
|
|
255
|
+
// Returns: dependencies, file structure, setup commands
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Step 3: Get patterns**
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
const example = await mcp.callTool('get_example', { pattern: 'hook-form' });
|
|
262
|
+
// Returns: actual code from react-spa-scaffold
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
**Step 4: AI generates project**
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
mkdir my-app && cd my-app
|
|
269
|
+
→ Write package.json from scaffold.packageJson
|
|
270
|
+
→ Generate files following patterns
|
|
271
|
+
→ npm install && npm run build
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
### Scripts
|
|
277
|
+
|
|
278
|
+
| Command | Description |
|
|
279
|
+
| ------------------- | ------------------------ |
|
|
280
|
+
| `npm run build` | Compile TypeScript |
|
|
281
|
+
| `npm run dev` | Watch mode |
|
|
282
|
+
| `npm start` | Run server |
|
|
283
|
+
| `npm run inspect` | Test with MCP Inspector |
|
|
284
|
+
| `npm run bundle` | Bundle templates for npm |
|
|
285
|
+
| `npm run typecheck` | Type check only |
|
|
286
|
+
|
|
287
|
+
<details>
|
|
288
|
+
<summary>Monorepo Structure</summary>
|
|
289
|
+
|
|
290
|
+
```
|
|
291
|
+
react-spa-scaffold/
|
|
292
|
+
├── package.json # Workspaces config
|
|
293
|
+
├── src/ # Main react-spa-scaffold app
|
|
294
|
+
├── docs/ # Documentation (read by MCP)
|
|
295
|
+
├── tests/ # Test files (read by MCP)
|
|
296
|
+
└── packages/
|
|
297
|
+
└── mcp/
|
|
298
|
+
├── src/
|
|
299
|
+
│ ├── index.ts # Entry point (STDIO transport)
|
|
300
|
+
│ ├── server.ts # MCP server setup
|
|
301
|
+
│ ├── features/ # Feature registry and types
|
|
302
|
+
│ ├── tools/ # Tool implementations
|
|
303
|
+
│ ├── resources/ # MCP resources (docs)
|
|
304
|
+
│ └── utils/ # Helpers
|
|
305
|
+
├── scripts/
|
|
306
|
+
│ └── bundle-templates.js
|
|
307
|
+
└── package.json
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
</details>
|
|
311
|
+
|
|
312
|
+
<details>
|
|
313
|
+
<summary>How Examples Work</summary>
|
|
314
|
+
|
|
315
|
+
The server supports two modes:
|
|
316
|
+
|
|
317
|
+
**Development mode** (monorepo):
|
|
318
|
+
|
|
319
|
+
- Reads files directly from monorepo root
|
|
320
|
+
- Changes reflected immediately
|
|
321
|
+
- No bundling needed
|
|
322
|
+
|
|
323
|
+
**Published mode** (npx):
|
|
324
|
+
|
|
325
|
+
- Reads from bundled `templates/` directory
|
|
326
|
+
- Templates copied at publish time via `npm run bundle`
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
// Automatically detects which mode
|
|
330
|
+
const TEMPLATES_ROOT = existsSync(BUNDLED_TEMPLATES)
|
|
331
|
+
? BUNDLED_TEMPLATES // npx mode
|
|
332
|
+
: MONOREPO_ROOT; // development mode
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
</details>
|
|
336
|
+
|
|
337
|
+
<details>
|
|
338
|
+
<summary>Publishing to npm</summary>
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
# prepublishOnly runs bundle + build automatically
|
|
342
|
+
npm publish
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Or manually:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
npm run bundle # Copy templates
|
|
349
|
+
npm run build # Compile TypeScript
|
|
350
|
+
npm publish
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
</details>
|
|
354
|
+
|
|
355
|
+
<details>
|
|
356
|
+
<summary>Adding a New Feature</summary>
|
|
357
|
+
|
|
358
|
+
1. **Define in** `src/features/registry.ts`:
|
|
359
|
+
|
|
360
|
+
```typescript
|
|
361
|
+
const myFeature: Feature = {
|
|
362
|
+
name: 'My Feature',
|
|
363
|
+
description: 'Description shown to users',
|
|
364
|
+
required: false,
|
|
365
|
+
includes: ['Thing 1', 'Thing 2'],
|
|
366
|
+
dependencies: { 'some-package': '^1.0.0' },
|
|
367
|
+
devDependencies: { 'some-dev-package': '^2.0.0' },
|
|
368
|
+
files: ['src/lib/myFeature.ts'],
|
|
369
|
+
patterns: ['my-feature-pattern'],
|
|
370
|
+
scripts: { 'my-script': 'some-command' },
|
|
371
|
+
configFiles: ['my-feature.config.js'],
|
|
372
|
+
};
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
2. **Add patterns** in `src/utils/examples.ts`:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
'my-feature-pattern': {
|
|
379
|
+
file: 'src/lib/myFeature.ts',
|
|
380
|
+
description: 'My feature implementation',
|
|
381
|
+
keyPoints: ['Key point 1', 'Key point 2'],
|
|
382
|
+
},
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
3. **Create actual files** in react-spa-scaffold's `src/`
|
|
386
|
+
|
|
387
|
+
4. **Rebuild**: `npm run build`
|
|
388
|
+
|
|
389
|
+
</details>
|
|
390
|
+
|
|
391
|
+
<details>
|
|
392
|
+
<summary>Adding a New Resource</summary>
|
|
393
|
+
|
|
394
|
+
1. **Add to** `src/resources/docs.ts`:
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
'docs://my-topic': {
|
|
398
|
+
files: ['docs/MY_TOPIC.md'],
|
|
399
|
+
name: 'My Topic',
|
|
400
|
+
description: 'Description shown to clients',
|
|
401
|
+
},
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
2. **Create** `docs/MY_TOPIC.md`
|
|
405
|
+
|
|
406
|
+
3. **Rebuild**: `npm run build`
|
|
407
|
+
|
|
408
|
+
Resources read files at runtime — content updates without rebuilding.
|
|
409
|
+
|
|
410
|
+
</details>
|
|
411
|
+
|
|
412
|
+
## Troubleshooting
|
|
413
|
+
|
|
414
|
+
| Problem | Solution |
|
|
415
|
+
| ---------------------------- | --------------------------------------------------------- |
|
|
416
|
+
| "File not found" in examples | Run from monorepo: `cd packages/mcp && npm start` |
|
|
417
|
+
| Tools not appearing | Check config path, run `npm run build`, check stderr logs |
|
|
418
|
+
| Type errors after changes | Run `npm run typecheck`, then rebuild |
|
|
419
|
+
| Patterns returning empty | Ensure referenced file exists in `src/` or `tests/` |
|
|
420
|
+
|
|
421
|
+
## License
|
|
422
|
+
|
|
423
|
+
MIT
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FEATURES, FEATURE_IDS } from './registry.js';
|
|
2
|
+
export type { FeatureId } from './registry.js';
|
|
3
|
+
export { CONFIG_VERSIONS } from './versions.js';
|
|
4
|
+
export type { Feature, FeatureRegistry, FeatureOption, ScaffoldOptions, ScaffoldResult } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature Registry - Defines all available features for react-spa-scaffold scaffolding
|
|
3
|
+
*/
|
|
4
|
+
import type { FeatureRegistry } from './types.js';
|
|
5
|
+
export declare const FEATURES: FeatureRegistry;
|
|
6
|
+
/** All valid feature IDs */
|
|
7
|
+
export declare const FEATURE_IDS: (keyof typeof FEATURES)[];
|
|
8
|
+
/** Type representing a valid feature identifier */
|
|
9
|
+
export type FeatureId = (typeof FEATURE_IDS)[number];
|
|
10
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/features/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAW,eAAe,EAAE,MAAM,YAAY,CAAC;AAmgB3D,eAAO,MAAM,QAAQ,EAAE,eAatB,CAAC;AAEF,4BAA4B;AAC5B,eAAO,MAAM,WAAW,EAA4B,CAAC,MAAM,OAAO,QAAQ,CAAC,EAAE,CAAC;AAE9E,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC"}
|