@visualprd/mcp-server 1.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.
Files changed (58) hide show
  1. package/README.md +396 -0
  2. package/dist/cli.d.ts +9 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +27 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +20 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +243 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/intelligence/context-optimizer.d.ts +93 -0
  11. package/dist/intelligence/context-optimizer.d.ts.map +1 -0
  12. package/dist/intelligence/context-optimizer.js +481 -0
  13. package/dist/intelligence/context-optimizer.js.map +1 -0
  14. package/dist/intelligence/error-analyzer.d.ts +49 -0
  15. package/dist/intelligence/error-analyzer.d.ts.map +1 -0
  16. package/dist/intelligence/error-analyzer.js +765 -0
  17. package/dist/intelligence/error-analyzer.js.map +1 -0
  18. package/dist/intelligence/gap-filler.d.ts +56 -0
  19. package/dist/intelligence/gap-filler.d.ts.map +1 -0
  20. package/dist/intelligence/gap-filler.js +410 -0
  21. package/dist/intelligence/gap-filler.js.map +1 -0
  22. package/dist/intelligence/guidance-generator.d.ts +43 -0
  23. package/dist/intelligence/guidance-generator.d.ts.map +1 -0
  24. package/dist/intelligence/guidance-generator.js +314 -0
  25. package/dist/intelligence/guidance-generator.js.map +1 -0
  26. package/dist/intelligence/index.d.ts +132 -0
  27. package/dist/intelligence/index.d.ts.map +1 -0
  28. package/dist/intelligence/index.js +683 -0
  29. package/dist/intelligence/index.js.map +1 -0
  30. package/dist/server-http.d.ts +9 -0
  31. package/dist/server-http.d.ts.map +1 -0
  32. package/dist/server-http.js +141 -0
  33. package/dist/server-http.js.map +1 -0
  34. package/dist/services/api-key-service.d.ts +68 -0
  35. package/dist/services/api-key-service.d.ts.map +1 -0
  36. package/dist/services/api-key-service.js +298 -0
  37. package/dist/services/api-key-service.js.map +1 -0
  38. package/dist/services/llm-client.d.ts +66 -0
  39. package/dist/services/llm-client.d.ts.map +1 -0
  40. package/dist/services/llm-client.js +141 -0
  41. package/dist/services/llm-client.js.map +1 -0
  42. package/dist/services/model-registry.d.ts +135 -0
  43. package/dist/services/model-registry.d.ts.map +1 -0
  44. package/dist/services/model-registry.js +276 -0
  45. package/dist/services/model-registry.js.map +1 -0
  46. package/dist/services/visualprd-client.d.ts +191 -0
  47. package/dist/services/visualprd-client.d.ts.map +1 -0
  48. package/dist/services/visualprd-client.js +805 -0
  49. package/dist/services/visualprd-client.js.map +1 -0
  50. package/dist/tools/index.d.ts +803 -0
  51. package/dist/tools/index.d.ts.map +1 -0
  52. package/dist/tools/index.js +570 -0
  53. package/dist/tools/index.js.map +1 -0
  54. package/dist/types/index.d.ts +497 -0
  55. package/dist/types/index.d.ts.map +1 -0
  56. package/dist/types/index.js +8 -0
  57. package/dist/types/index.js.map +1 -0
  58. package/package.json +48 -0
package/README.md ADDED
@@ -0,0 +1,396 @@
1
+ # VisualPRD MCP Server
2
+
3
+ **Intelligent Model Context Protocol server for autonomous build orchestration between VisualPRD and AI coding agents.**
4
+
5
+ This MCP server acts as an intelligent middleman between your VisualPRD project and AI coding assistants like Cursor, Claude, and Windsurf. It doesn't just fetch data — it **thinks, orchestrates, adapts, and guides** the entire build process.
6
+
7
+ ## Features
8
+
9
+ ### Autonomous Decision Making
10
+ - Tracks build prompt dependencies automatically
11
+ - Fetches relevant context for each step
12
+ - Validates completion before moving forward
13
+
14
+ ### Intelligent Context Optimization
15
+ - Only fetches entities relevant to the current task
16
+ - Reduces token usage by 60-80% compared to dumping all project data
17
+ - Automatically includes design system for UI tasks
18
+ - Includes schema relationships for database tasks
19
+
20
+ ### Error Detection & Recovery
21
+ - Pattern-based error analysis for common issues
22
+ - Suggests multiple fix approaches with confidence scores
23
+ - Can inject new build steps when migrations are needed
24
+ - Provides code examples for fixes
25
+
26
+ ### Gap Filling Intelligence
27
+ - Detects missing authentication flows (password reset, email verification)
28
+ - Identifies incomplete CRUD operations
29
+ - Suggests schema field additions
30
+ - Warns about missing error handling pages
31
+
32
+ ### Contextual Guidance
33
+ - Technical considerations based on tech stack
34
+ - Potential issues to watch out for
35
+ - Testing criteria for each step
36
+ - Related patterns from completed steps
37
+
38
+ ## Installation
39
+
40
+ ### Option 1: NPM (Recommended)
41
+
42
+ ```bash
43
+ npm install -g @visualprd/mcp-server
44
+ ```
45
+
46
+ ### Option 2: From Source
47
+
48
+ ```bash
49
+ cd mcp-server
50
+ npm install
51
+ npm run build
52
+ npm link
53
+ ```
54
+
55
+ ## Configuration
56
+
57
+ ### For Cursor
58
+
59
+ Add to your Cursor MCP settings (Settings → Extensions → MCP Servers):
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "visualprd": {
65
+ "command": "visualprd-mcp",
66
+ "args": ["--project", "YOUR_PROJECT_ID"],
67
+ "env": {
68
+ "FIREBASE_PROJECT_ID": "visualprd-app",
69
+ "GOOGLE_APPLICATION_CREDENTIALS": "/path/to/service-account.json"
70
+ }
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### For Claude Desktop
77
+
78
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "visualprd": {
84
+ "command": "visualprd-mcp",
85
+ "args": ["--project", "YOUR_PROJECT_ID"],
86
+ "env": {
87
+ "VISUALPRD_PROJECT_ID": "YOUR_PROJECT_ID",
88
+ "FIREBASE_PROJECT_ID": "visualprd-app"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ### Environment Variables
96
+
97
+ | Variable | Description | Required |
98
+ |----------|-------------|----------|
99
+ | `VISUALPRD_PROJECT_ID` | Your VisualPRD project ID | Yes |
100
+ | `VISUALPRD_API_KEY` | API key (if using hosted API) | No |
101
+ | `VISUALPRD_API_URL` | API base URL | No |
102
+ | `FIREBASE_PROJECT_ID` | Firebase project ID | For direct Firestore |
103
+ | `GOOGLE_APPLICATION_CREDENTIALS` | Path to service account JSON | For direct Firestore |
104
+
105
+ ## Available Tools
106
+
107
+ ### `get_next_build_step`
108
+
109
+ Get the next build step with full intelligent context.
110
+
111
+ **Example Response:**
112
+ ```json
113
+ {
114
+ "step": {
115
+ "promptId": "prompt-003",
116
+ "title": "Implement User Authentication Flow",
117
+ "category": "pages",
118
+ "instruction": "Create the LoginPage component...",
119
+ "estimatedMinutes": 45
120
+ },
121
+ "relatedEntities": {
122
+ "pages": [{ "pageName": "LoginPage", "route": "/login", ... }],
123
+ "schemas": [{ "collectionName": "users", "fields": [...] }],
124
+ "endpoints": [{ "name": "authenticateUser", "method": "POST", ... }],
125
+ "designSystem": { "colorPalette": {...}, "typography": {...} }
126
+ },
127
+ "contextualGuidance": {
128
+ "technicalConsiderations": [
129
+ "Use Firebase Auth SDK for authentication",
130
+ "Store auth state in context for app-wide access"
131
+ ],
132
+ "potentialIssues": [
133
+ "Remember to handle auth state persistence",
134
+ "Password reset flow may not be defined"
135
+ ],
136
+ "testingCriteria": [
137
+ "User can log in with valid credentials",
138
+ "Invalid credentials show error message"
139
+ ]
140
+ },
141
+ "buildProgress": {
142
+ "totalSteps": 25,
143
+ "completedSteps": 2,
144
+ "currentStep": 3,
145
+ "percentComplete": 8
146
+ }
147
+ }
148
+ ```
149
+
150
+ ### `mark_step_complete`
151
+
152
+ Mark a step as complete and automatically fetch the next one.
153
+
154
+ **Parameters:**
155
+ - `promptId` (required): ID of the step to mark complete
156
+ - `completionNotes`: Description of what was done
157
+ - `filesCreated`: Array of file paths created
158
+ - `testResults`: Object with `passed` and `failed` counts
159
+
160
+ **Example:**
161
+ ```json
162
+ {
163
+ "promptId": "prompt-003",
164
+ "completionNotes": "LoginPage implemented with Zod validation",
165
+ "filesCreated": ["src/pages/LoginPage.tsx", "src/services/auth.ts"],
166
+ "testResults": { "passed": 8, "failed": 0 }
167
+ }
168
+ ```
169
+
170
+ ### `report_error`
171
+
172
+ Report an error and get intelligent diagnosis with fixes.
173
+
174
+ **Parameters:**
175
+ - `promptId` (required): Where the error occurred
176
+ - `errorType` (required): `compile_error`, `runtime_error`, `test_failure`, `missing_dependency`, `other`
177
+ - `errorMessage` (required): The error message
178
+ - `stackTrace`: Stack trace if available
179
+ - `context`: What you were doing when it occurred
180
+
181
+ **Example Response:**
182
+ ```json
183
+ {
184
+ "diagnosis": {
185
+ "rootCause": "Field 'emailVerified' is defined in schema but not in database",
186
+ "explanation": "The schema definition is ahead of the actual database state",
187
+ "severity": "high"
188
+ },
189
+ "suggestedFixes": [
190
+ {
191
+ "approach": "Database Migration",
192
+ "steps": [
193
+ "Create migration script for users collection",
194
+ "Add default value for emailVerified",
195
+ "Run migration before continuing"
196
+ ],
197
+ "code": {
198
+ "filename": "migrations/add-email-verified.ts",
199
+ "content": "// Migration script..."
200
+ },
201
+ "confidence": 0.9
202
+ }
203
+ ],
204
+ "shouldInjectNewStep": true,
205
+ "newStep": {
206
+ "title": "Database Migration: Add emailVerified to users",
207
+ "category": "database"
208
+ }
209
+ }
210
+ ```
211
+
212
+ ### `get_entity_details`
213
+
214
+ Get detailed information about a specific entity.
215
+
216
+ **Parameters:**
217
+ - `entityType` (required): `page`, `schema`, `endpoint`, `tech`
218
+ - `entityId` (required): ID or name of the entity
219
+ - `includeRelationships`: Include relationship info (for schemas)
220
+ - `includeUsageExamples`: Include code examples
221
+
222
+ ### `get_debug_suggestions`
223
+
224
+ Get AI-powered debugging suggestions when stuck.
225
+
226
+ **Parameters:**
227
+ - `currentTask` (required): What you're trying to do
228
+ - `issue` (required): The problem you're facing
229
+ - `context`: Additional context
230
+ - `attemptedSolutions`: What you've already tried
231
+
232
+ ### `inject_dynamic_step`
233
+
234
+ Add a new build step when you identify missing functionality.
235
+
236
+ **Parameters:**
237
+ - `insertAfter` (required): Prompt ID to insert after
238
+ - `title` (required): Title of the new step
239
+ - `category` (required): Step category
240
+ - `reason` (required): Why this step is needed
241
+ - `instruction` (required): Detailed instructions
242
+
243
+ ### `get_build_progress`
244
+
245
+ Get current build progress statistics.
246
+
247
+ ### `get_design_system`
248
+
249
+ Get the project's design system specifications.
250
+
251
+ **Parameters:**
252
+ - `section`: `all`, `colors`, `typography`, `spacing`, `components`
253
+
254
+ ## How It Works
255
+
256
+ ### Architecture
257
+
258
+ ```
259
+ ┌─────────────────────────────────────────────────────────────┐
260
+ │ AI Agent (Cursor/Claude/Windsurf) │
261
+ │ "Help me build the next feature" │
262
+ └─────────────────────┬───────────────────────────────────────┘
263
+ │ MCP Protocol
264
+
265
+ ┌─────────────────────────────────────────────────────────────┐
266
+ │ VisualPRD MCP Server │
267
+ │ │
268
+ │ ┌─────────────────────────────────────────────────────┐ │
269
+ │ │ Intelligence Layer │ │
270
+ │ │ • Context Optimizer - Fetches relevant data only │ │
271
+ │ │ • Error Analyzer - Diagnoses issues, suggests fixes │ │
272
+ │ │ • Gap Filler - Detects missing flows │ │
273
+ │ │ • Guidance Generator - Provides contextual help │ │
274
+ │ └─────────────────────────────────────────────────────┘ │
275
+ │ │
276
+ │ ┌─────────────────────────────────────────────────────┐ │
277
+ │ │ VisualPRD Client │ │
278
+ │ │ • Firestore connection │ │
279
+ │ │ • Caching layer │ │
280
+ │ │ • Entity resolution │ │
281
+ │ └─────────────────────────────────────────────────────┘ │
282
+ └─────────────────────┬───────────────────────────────────────┘
283
+
284
+
285
+ ┌─────────────────────────────────────────────────────────────┐
286
+ │ Firestore Database │
287
+ │ • projects/{projectId}/ │
288
+ │ • pages/ │
289
+ │ • databaseSchemas/ │
290
+ │ • apiEndpoints/ │
291
+ │ • techStack/ │
292
+ │ • buildPrompts/ │
293
+ └─────────────────────────────────────────────────────────────┘
294
+ ```
295
+
296
+ ### Intelligence Decision Making
297
+
298
+ The server uses a tiered intelligence approach to minimize costs:
299
+
300
+ 1. **Rule-Based (Free)**: Simple lookups, status changes, dependency checks
301
+ 2. **Pattern Matching (Free)**: Known error patterns, common gaps
302
+ 3. **Lightweight AI (Cheap)**: Complex debugging suggestions
303
+ 4. **Full AI (Expensive)**: Only when truly needed
304
+
305
+ ### Context Optimization
306
+
307
+ The server intelligently decides what context to include:
308
+
309
+ | Prompt Type | Included Context |
310
+ |-------------|------------------|
311
+ | UI/Pages | Design system, related components, state specs |
312
+ | Database | Full schema with relationships, indexes |
313
+ | Integration | Endpoints with auth, tech stack configs |
314
+ | Setup | Full tech stack, environment requirements |
315
+
316
+ ## Example Usage Flow
317
+
318
+ ```
319
+ User: "Help me build my VisualPRD project"
320
+
321
+ MCP Server:
322
+ ✓ Loads project abc123
323
+ ✓ Finds next available step (Step 3: User Authentication)
324
+ ✓ Fetches LoginPage spec, user schema, auth endpoint
325
+ ✓ Generates contextual guidance
326
+
327
+ Response: "Ready to work on Step 3 of 25: Implement User Authentication Flow
328
+
329
+ I've fetched:
330
+ - LoginPage spec with component structure
331
+ - User schema with 14 fields
332
+ - authenticateUser endpoint (POST /api/auth/login)
333
+ - Design system for consistent styling
334
+
335
+ Technical considerations:
336
+ - Use Firebase Auth SDK
337
+ - Store session in context
338
+
339
+ Watch out for:
340
+ - Password reset flow isn't defined yet
341
+ - Remember auth state persistence"
342
+
343
+ User: [Implements LoginPage]
344
+ User: "Done, mark it complete"
345
+
346
+ MCP Server:
347
+ ✓ Validates: files created ✓, tests passing ✓
348
+ ✓ Updates Firestore
349
+ ✓ Fetches next step automatically
350
+
351
+ Response: "✅ Step 3 complete!
352
+ Next up: Step 4 - Implement User Dashboard"
353
+ ```
354
+
355
+ ## Troubleshooting
356
+
357
+ ### "Project not found"
358
+ - Verify the project ID is correct
359
+ - Ensure Firebase credentials have access to the project
360
+
361
+ ### "Permission denied"
362
+ - Check Firebase security rules allow read access
363
+ - Verify service account has correct permissions
364
+
365
+ ### "Module not found" errors
366
+ - Run `npm install` in the mcp-server directory
367
+ - Ensure you're using Node.js 18+
368
+
369
+ ### Tools not appearing in Cursor
370
+ - Restart Cursor after adding MCP config
371
+ - Check the MCP server logs for errors
372
+ - Verify the server starts correctly: `visualprd-mcp --help`
373
+
374
+ ## Development
375
+
376
+ ### Building
377
+
378
+ ```bash
379
+ npm run build
380
+ ```
381
+
382
+ ### Running in Dev Mode
383
+
384
+ ```bash
385
+ npm run dev
386
+ ```
387
+
388
+ ### Testing
389
+
390
+ ```bash
391
+ npm test
392
+ ```
393
+
394
+ ## License
395
+
396
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * VisualPRD MCP Server CLI
4
+ *
5
+ * Command-line interface for the MCP server
6
+ */
7
+ export * from './index.js';
8
+ import './index.js';
9
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,YAAY,CAAC"}
package/dist/cli.js ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * VisualPRD MCP Server CLI
5
+ *
6
+ * Command-line interface for the MCP server
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ // Re-export the main entry point
24
+ __exportStar(require("./index.js"), exports);
25
+ // The main logic is in index.ts
26
+ require("./index.js");
27
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AACA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,iCAAiC;AACjC,6CAA2B;AAE3B,gCAAgC;AAChC,sBAAoB"}
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * VisualPRD MCP Server
4
+ *
5
+ * Intelligent Model Context Protocol server for autonomous build orchestration
6
+ * between VisualPRD and AI coding agents (Cursor, Claude, etc.)
7
+ */
8
+ import { ProjectConfig } from './types/index.js';
9
+ declare class VisualPRDMCPServer {
10
+ private server;
11
+ private client;
12
+ private intelligence;
13
+ private toolHandlers;
14
+ private config;
15
+ constructor(config: ProjectConfig);
16
+ private setupHandlers;
17
+ start(): Promise<void>;
18
+ }
19
+ export { VisualPRDMCPServer };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAcH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,cAAM,kBAAkB;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAyBjC,OAAO,CAAC,aAAa;IAyHf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAS7B;AA2FD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}