@mandujs/mcp 0.9.20 → 0.9.22

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 (121) hide show
  1. package/README.md +320 -0
  2. package/package.json +1 -1
  3. package/src/activity-monitor.ts +847 -231
  4. package/src/resources/handlers.ts +244 -0
  5. package/src/resources/skills/guides.ts +1136 -0
  6. package/src/resources/skills/index.ts +12 -0
  7. package/src/resources/skills/loader.ts +218 -0
  8. package/src/resources/skills/mandu-composition/SKILL.md +91 -0
  9. package/src/resources/skills/mandu-composition/metadata.json +13 -0
  10. package/src/resources/skills/mandu-composition/rules/_sections.md +26 -0
  11. package/src/resources/skills/mandu-composition/rules/_template.md +77 -0
  12. package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -0
  13. package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -0
  14. package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -0
  15. package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -0
  16. package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -0
  17. package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -0
  18. package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -0
  19. package/src/resources/skills/mandu-deployment/SKILL.md +92 -0
  20. package/src/resources/skills/mandu-deployment/_sections.md +41 -0
  21. package/src/resources/skills/mandu-deployment/_template.md +38 -0
  22. package/src/resources/skills/mandu-deployment/metadata.json +13 -0
  23. package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -0
  24. package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -0
  25. package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -0
  26. package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -0
  27. package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -0
  28. package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -0
  29. package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -0
  30. package/src/resources/skills/mandu-deployment/rules/deploy-platform-supabase.md +323 -0
  31. package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -0
  32. package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -0
  33. package/src/resources/skills/mandu-fs-routes/metadata.json +12 -0
  34. package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -0
  35. package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -0
  36. package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -0
  37. package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -0
  38. package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -0
  39. package/src/resources/skills/mandu-guard/SKILL.md +129 -0
  40. package/src/resources/skills/mandu-guard/metadata.json +12 -0
  41. package/src/resources/skills/mandu-guard/rules/_sections.md +36 -0
  42. package/src/resources/skills/mandu-guard/rules/_template.md +82 -0
  43. package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -0
  44. package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -0
  45. package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -0
  46. package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -0
  47. package/src/resources/skills/mandu-hydration/SKILL.md +91 -0
  48. package/src/resources/skills/mandu-hydration/metadata.json +12 -0
  49. package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -0
  50. package/src/resources/skills/mandu-hydration/rules/_template.md +72 -0
  51. package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -0
  52. package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -0
  53. package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -0
  54. package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -0
  55. package/src/resources/skills/mandu-performance/SKILL.md +85 -0
  56. package/src/resources/skills/mandu-performance/metadata.json +14 -0
  57. package/src/resources/skills/mandu-performance/rules/_sections.md +31 -0
  58. package/src/resources/skills/mandu-performance/rules/_template.md +64 -0
  59. package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -0
  60. package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -0
  61. package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -0
  62. package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -0
  63. package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -0
  64. package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -0
  65. package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -0
  66. package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -0
  67. package/src/resources/skills/mandu-security/SKILL.md +87 -0
  68. package/src/resources/skills/mandu-security/metadata.json +13 -0
  69. package/src/resources/skills/mandu-security/rules/_sections.md +31 -0
  70. package/src/resources/skills/mandu-security/rules/_template.md +74 -0
  71. package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -0
  72. package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -0
  73. package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -0
  74. package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -0
  75. package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -0
  76. package/src/resources/skills/mandu-slot/SKILL.md +85 -0
  77. package/src/resources/skills/mandu-slot/metadata.json +12 -0
  78. package/src/resources/skills/mandu-slot/rules/_sections.md +36 -0
  79. package/src/resources/skills/mandu-slot/rules/_template.md +63 -0
  80. package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -0
  81. package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -0
  82. package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -0
  83. package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -0
  84. package/src/resources/skills/mandu-styling/SKILL.md +118 -0
  85. package/src/resources/skills/mandu-styling/_sections.md +36 -0
  86. package/src/resources/skills/mandu-styling/_template.md +32 -0
  87. package/src/resources/skills/mandu-styling/metadata.json +13 -0
  88. package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -0
  89. package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -0
  90. package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -0
  91. package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -0
  92. package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -0
  93. package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -0
  94. package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -0
  95. package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -0
  96. package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -0
  97. package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -0
  98. package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +161 -0
  99. package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -0
  100. package/src/resources/skills/mandu-testing/SKILL.md +99 -0
  101. package/src/resources/skills/mandu-testing/metadata.json +13 -0
  102. package/src/resources/skills/mandu-testing/rules/_sections.md +26 -0
  103. package/src/resources/skills/mandu-testing/rules/_template.md +65 -0
  104. package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -0
  105. package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -0
  106. package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -0
  107. package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -0
  108. package/src/resources/skills/mandu-ui/SKILL.md +117 -0
  109. package/src/resources/skills/mandu-ui/_sections.md +23 -0
  110. package/src/resources/skills/mandu-ui/_template.md +32 -0
  111. package/src/resources/skills/mandu-ui/metadata.json +13 -0
  112. package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -0
  113. package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -0
  114. package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -0
  115. package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -0
  116. package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -0
  117. package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -0
  118. package/src/resources/skills/recipes.ts +932 -0
  119. package/src/server.ts +3 -0
  120. package/src/tools/index.ts +1 -0
  121. package/src/tools/seo.ts +417 -0
package/README.md ADDED
@@ -0,0 +1,320 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/konamgil/mandu/main/mandu_only_simbol.png" alt="Mandu" width="200" />
3
+ </p>
4
+
5
+ <h1 align="center">@mandujs/mcp</h1>
6
+
7
+ <p align="center">
8
+ <strong>Mandu MCP Server</strong><br/>
9
+ Model Context Protocol server for AI agent integration
10
+ </p>
11
+
12
+ <p align="center">
13
+ English | <a href="./README.ko.md"><strong>한국어</strong></a>
14
+ </p>
15
+
16
+ ## What is MCP?
17
+
18
+ MCP (Model Context Protocol) enables AI agents to directly interact with the Mandu framework. Instead of generating code blindly, agents can:
19
+
20
+ - Query current project structure
21
+ - Add/modify routes with validation
22
+ - Write business logic with auto-correction
23
+ - Check architecture rules before making changes
24
+ - Receive real-time violation notifications
25
+
26
+ ## Setup
27
+
28
+ ### Claude Code / Claude Desktop
29
+
30
+ Add to your MCP configuration (`.mcp.json` or Claude settings):
31
+
32
+ ```json
33
+ {
34
+ "mcpServers": {
35
+ "mandu": {
36
+ "command": "bunx",
37
+ "args": ["@mandujs/mcp"],
38
+ "cwd": "/path/to/your/project"
39
+ }
40
+ }
41
+ }
42
+ ```
43
+
44
+ ### Direct Execution
45
+
46
+ ```bash
47
+ cd /path/to/project
48
+ bunx @mandujs/mcp
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Tools (25+)
54
+
55
+ ### Spec Management
56
+
57
+ | Tool | Description |
58
+ |------|-------------|
59
+ | `mandu_list_routes` | List all routes with details |
60
+ | `mandu_get_route` | Get specific route by ID |
61
+ | `mandu_add_route` | Add new route to manifest |
62
+ | `mandu_update_route` | Modify existing route |
63
+ | `mandu_delete_route` | Remove route from manifest |
64
+ | `mandu_validate_spec` | Validate manifest schema |
65
+
66
+ ### Code Generation
67
+
68
+ | Tool | Description |
69
+ |------|-------------|
70
+ | `mandu_generate` | Generate code from manifest |
71
+
72
+ ### Transaction Management
73
+
74
+ | Tool | Description |
75
+ |------|-------------|
76
+ | `mandu_begin` | Start transaction with snapshot |
77
+ | `mandu_commit` | Finalize changes |
78
+ | `mandu_rollback` | Restore from snapshot |
79
+ | `mandu_tx_status` | Get transaction state |
80
+
81
+ ### Slot Management
82
+
83
+ | Tool | Description |
84
+ |------|-------------|
85
+ | `mandu_read_slot` | Read slot file content |
86
+ | `mandu_write_slot` | Write slot file (with auto-correction) |
87
+ | `mandu_validate_slot` | Validate slot syntax |
88
+
89
+ ### Guard & Architecture
90
+
91
+ | Tool | Description |
92
+ |------|-------------|
93
+ | `mandu_guard_check` | Run all guard checks |
94
+ | `mandu_check_location` | Validate file location before creating |
95
+ | `mandu_check_import` | Validate imports against architecture rules |
96
+ | `mandu_get_architecture` | Get project architecture rules |
97
+
98
+ ### Brain & Monitoring
99
+
100
+ | Tool | Description |
101
+ |------|-------------|
102
+ | `mandu_doctor` | Analyze failures + suggest patches |
103
+ | `mandu_watch_start` | Start file watcher with notifications |
104
+ | `mandu_watch_status` | Get watcher status |
105
+ | `mandu_watch_stop` | Stop file watcher |
106
+
107
+ ### Hydration & Build
108
+
109
+ | Tool | Description |
110
+ |------|-------------|
111
+ | `mandu_build` | Build client bundles |
112
+ | `mandu_build_status` | Get bundle statistics |
113
+ | `mandu_list_islands` | List routes with hydration |
114
+ | `mandu_set_hydration` | Configure hydration strategy |
115
+ | `mandu_add_client_slot` | Create client slot for route |
116
+
117
+ ### History
118
+
119
+ | Tool | Description |
120
+ |------|-------------|
121
+ | `mandu_list_changes` | View change history |
122
+ | `mandu_prune_history` | Clean old snapshots |
123
+
124
+ ---
125
+
126
+ ## Resources
127
+
128
+ | URI | Description |
129
+ |-----|-------------|
130
+ | `mandu://spec/manifest` | Current routes.manifest.json |
131
+ | `mandu://spec/lock` | Current spec.lock.json with hash |
132
+ | `mandu://generated/map` | Generated files mapping |
133
+ | `mandu://transaction/active` | Active transaction state |
134
+ | `mandu://slots/{routeId}` | Slot file content by route ID |
135
+ | `mandu://watch/warnings` | Recent architecture violation warnings |
136
+ | `mandu://watch/status` | Watcher status (active, uptime, count) |
137
+
138
+ ---
139
+
140
+ ## Real-Time Notifications
141
+
142
+ When `mandu_watch_start` is active, the agent receives real-time push notifications for architecture violations:
143
+
144
+ ```json
145
+ {
146
+ "jsonrpc": "2.0",
147
+ "method": "notifications/message",
148
+ "params": {
149
+ "level": "warning",
150
+ "logger": "mandu-watch",
151
+ "data": {
152
+ "type": "watch_warning",
153
+ "ruleId": "GENERATED_DIRECT_EDIT",
154
+ "file": "apps/server/generated/routes/home.route.ts",
155
+ "message": "Generated file was directly modified",
156
+ "timestamp": "2026-02-02T10:15:00.000Z"
157
+ }
158
+ }
159
+ }
160
+ ```
161
+
162
+ ### Watched Rules
163
+
164
+ | Rule | Description |
165
+ |------|-------------|
166
+ | `GENERATED_DIRECT_EDIT` | Manual edits to generated files |
167
+ | `WRONG_SLOT_LOCATION` | Slot files outside `spec/slots/` |
168
+ | `SLOT_NAMING` | Slot files not ending with `.slot.ts` |
169
+ | `CONTRACT_NAMING` | Contract files not ending with `.contract.ts` |
170
+ | `FORBIDDEN_IMPORT` | Dangerous imports in generated files |
171
+
172
+ ---
173
+
174
+ ## Activity Monitor (JSON Schema)
175
+
176
+ The MCP server writes activity logs to `.mandu/activity.log` (pretty) or `.mandu/activity.jsonl` (JSON).
177
+ JSON lines follow a stable schema with `schemaVersion`:
178
+
179
+ ```json
180
+ {
181
+ "schemaVersion": "1.0",
182
+ "ts": "2026-02-02T12:34:56.789Z",
183
+ "type": "tool.call",
184
+ "severity": "info",
185
+ "source": "tool",
186
+ "message": "",
187
+ "actionRequired": false,
188
+ "fingerprint": "tool:call:mandu_guard_check",
189
+ "count": 1,
190
+ "data": {
191
+ "tool": "mandu_guard_check",
192
+ "tag": "GUARD",
193
+ "args": {}
194
+ }
195
+ }
196
+ ```
197
+
198
+ Common `type` values: `tool.call`, `tool.result`, `tool.error`, `watch.warning`, `guard.summary`, `guard.violation`, `routes.change`, `system.event`, `monitor.summary`.
199
+
200
+ Default config is auto-created at `.mandu/monitor.config.json` on first run.
201
+
202
+ ---
203
+
204
+ ## Agent Workflow Examples
205
+
206
+ ### Adding a New API Route
207
+
208
+ ```
209
+ Agent:
210
+ 1. mandu_begin({ message: "Add users API" })
211
+ → Creates snapshot
212
+
213
+ 2. mandu_check_location({ path: "spec/slots/users.slot.ts" })
214
+ → Validates location is allowed
215
+
216
+ 3. mandu_add_route({
217
+ id: "users-list",
218
+ pattern: "/api/users",
219
+ kind: "api",
220
+ methods: ["GET", "POST"],
221
+ slotModule: "spec/slots/users.slot.ts"
222
+ })
223
+ → Adds route to manifest
224
+
225
+ 4. mandu_generate()
226
+ → Creates route handlers
227
+
228
+ 5. mandu_write_slot({
229
+ routeId: "users-list",
230
+ content: "...",
231
+ autoCorrect: true
232
+ })
233
+ → Writes business logic
234
+
235
+ 6. mandu_guard_check()
236
+ → Validates architecture
237
+
238
+ 7. mandu_commit()
239
+ → Finalizes changes
240
+ ```
241
+
242
+ ### Checking Before Writing
243
+
244
+ ```
245
+ Agent:
246
+ 1. mandu_get_architecture()
247
+ → Gets folder rules, import rules, naming rules
248
+
249
+ 2. mandu_check_location({ path: "src/features/user/api.ts" })
250
+ → Checks if location is valid
251
+
252
+ 3. mandu_check_import({
253
+ sourceFile: "src/features/user/api.ts",
254
+ imports: ["../../entities/product"]
255
+ })
256
+ → Checks if imports are allowed
257
+
258
+ 4. Proceed with writing if all checks pass
259
+ ```
260
+
261
+ ### Monitoring Architecture
262
+
263
+ ```
264
+ Agent:
265
+ 1. mandu_watch_start()
266
+ → Starts watching with notifications
267
+
268
+ 2. (Agent receives real-time warnings)
269
+
270
+ 3. mandu_watch_status()
271
+ → Gets current status and recent warnings
272
+
273
+ 4. mandu_doctor()
274
+ → Analyzes violations and suggests fixes
275
+
276
+ 5. mandu_watch_stop()
277
+ → Stops watching
278
+ ```
279
+
280
+ ---
281
+
282
+ ## Architecture Integration
283
+
284
+ The MCP server integrates with Mandu Guard to enforce architecture rules:
285
+
286
+ ```
287
+ ┌─────────────────────────────────────────────────────────────┐
288
+ │ AI Agent (Claude) │
289
+ ├─────────────────────────────────────────────────────────────┤
290
+ │ │
291
+ │ Before writing code: │
292
+ │ 1. mandu_get_architecture() → Get rules │
293
+ │ 2. mandu_check_location() → Validate placement │
294
+ │ 3. mandu_check_import() → Validate dependencies │
295
+ │ │
296
+ │ While writing: │
297
+ │ - mandu_watch_start() → Real-time notifications │
298
+ │ │
299
+ │ After writing: │
300
+ │ - mandu_guard_check() → Full validation │
301
+ │ - mandu_doctor() → Get fix suggestions │
302
+ │ │
303
+ └─────────────────────────────────────────────────────────────┘
304
+ ```
305
+
306
+ ---
307
+
308
+ ## Requirements
309
+
310
+ - Bun >= 1.0.0
311
+ - @mandujs/core >= 0.9.25
312
+
313
+ ## Related Packages
314
+
315
+ - [@mandujs/core](https://www.npmjs.com/package/@mandujs/core) - Core runtime
316
+ - [@mandujs/cli](https://www.npmjs.com/package/@mandujs/cli) - CLI tool
317
+
318
+ ## License
319
+
320
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandujs/mcp",
3
- "version": "0.9.20",
3
+ "version": "0.9.22",
4
4
  "description": "Mandu MCP Server - Agent-native interface for Mandu framework operations",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",