product-spec-mcp 0.3.19
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 +404 -0
- package/dist/index.cjs +28326 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
# product-spec-mcp
|
|
2
|
+
|
|
3
|
+
> 防止 AI 编程一上来就乱写代码的 MCP 工具。
|
|
4
|
+
|
|
5
|
+
把用户的模糊产品想法变成追问清单、可执行规格、架构建议和验收标准。
|
|
6
|
+
|
|
7
|
+
## 适用场景
|
|
8
|
+
|
|
9
|
+
当你或 AI 编程助手拿到一句话需求("做一个报名系统"、"页面高级一点"、"接口报错了"),不要直接开工。先过一遍需求闸门,减少返工。
|
|
10
|
+
|
|
11
|
+
## 推荐流程
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
1. spec_interrogate → 评估需求完整度,生成追问清单
|
|
15
|
+
2. spec_compile → 编译产品规格和开发 Prompt
|
|
16
|
+
3. architecture_decide → 判断架构方案
|
|
17
|
+
4. acceptance_generate → 生成验收标准
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**不确定用哪个工具?** 先用 `product_spec_assist`,它会自动识别场景并调用合适的工具。
|
|
21
|
+
|
|
22
|
+
## 维护索引
|
|
23
|
+
|
|
24
|
+
- 更新 MCP 本体前,先看 [product-spec-mcp 更新经验索引](docs/product-spec-mcp-update-lessons.md)。
|
|
25
|
+
- WorkBuddy 接入、运行环境和副本同步问题仍记录在 [WorkBuddy 坑点记录](docs/workbuddy-mcp-pitfalls.md)。
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
This MCP Server provides 7 tools for product development workflow:
|
|
30
|
+
|
|
31
|
+
| Tool | Description |
|
|
32
|
+
|------|-------------|
|
|
33
|
+
| `product_spec_assist` | **推荐入口** - 根据用户原话自动识别场景并调用对应能力 |
|
|
34
|
+
| `spec_interrogate` | Analyze requirement completeness and generate clarification questions |
|
|
35
|
+
| `spec_compile` | Compile full product specification and development prompt |
|
|
36
|
+
| `architecture_decide` | Make architecture decisions based on product type and features |
|
|
37
|
+
| `ui_translate` | Translate user UI descriptions into frontend terminology |
|
|
38
|
+
| `debug_guide` | Generate structured debugging checklists |
|
|
39
|
+
| `acceptance_generate` | Generate acceptance criteria for features |
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install
|
|
45
|
+
npm run build
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
### As MCP Server (stdio)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm start
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Development Mode
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm run dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## MCP Client Configuration
|
|
63
|
+
|
|
64
|
+
### Claude Desktop
|
|
65
|
+
|
|
66
|
+
Add to your Claude Desktop configuration (`claude_desktop_config.json`):
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"product-spec": {
|
|
72
|
+
"command": "node",
|
|
73
|
+
"args": ["/path/to/product-spec-mcp/dist/index.cjs"]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Cursor
|
|
80
|
+
|
|
81
|
+
Add to your Cursor MCP configuration (`.cursor/mcp.json`):
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"mcpServers": {
|
|
86
|
+
"product-spec": {
|
|
87
|
+
"command": "node",
|
|
88
|
+
"args": ["/path/to/product-spec-mcp/dist/index.cjs"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### VS Code (Continue)
|
|
95
|
+
|
|
96
|
+
Add to your Continue configuration:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"mcpServers": {
|
|
101
|
+
"product-spec": {
|
|
102
|
+
"command": "node",
|
|
103
|
+
"args": ["/path/to/product-spec-mcp/dist/index.cjs"]
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### opencode
|
|
110
|
+
|
|
111
|
+
Add to `~/.config/opencode/opencode.json`:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"$schema": "https://opencode.ai/config.json",
|
|
116
|
+
"mcp": {
|
|
117
|
+
"product-spec": {
|
|
118
|
+
"type": "local",
|
|
119
|
+
"command": [
|
|
120
|
+
"node",
|
|
121
|
+
"/path/to/product-spec-mcp/dist/index.cjs"
|
|
122
|
+
],
|
|
123
|
+
"cwd": "/path/to/product-spec-mcp",
|
|
124
|
+
"enabled": true,
|
|
125
|
+
"timeout": 30000
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
> Note: opencode uses the `mcp` key. `mcpServers` is a Claude-style config key and will fail schema validation in current opencode versions.
|
|
132
|
+
|
|
133
|
+
## Tools Documentation
|
|
134
|
+
|
|
135
|
+
### product_spec_assist (推荐入口)
|
|
136
|
+
|
|
137
|
+
统一入口:根据用户原话自动判断场景并调用对应能力。
|
|
138
|
+
|
|
139
|
+
**Input:**
|
|
140
|
+
- `message` (required): 用户原话
|
|
141
|
+
- `known_context`: 已有上下文
|
|
142
|
+
- `preferred_platform`: `web` | `mini_program` | `app` | `backend` | `unknown`
|
|
143
|
+
- `strictness`: `light` | `normal` | `grill`
|
|
144
|
+
- `auto_execute`: boolean (default: true)
|
|
145
|
+
|
|
146
|
+
**Example:**
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"message": "我想做一个报名系统,学生可以提交资料,后台老师审核",
|
|
150
|
+
"preferred_platform": "web"
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**路由规则:**
|
|
155
|
+
|
|
156
|
+
| 场景 | 自动调用 |
|
|
157
|
+
|------|----------|
|
|
158
|
+
| 产品开发 | `spec_interrogate` |
|
|
159
|
+
| UI 修改 | `ui_translate` |
|
|
160
|
+
| Debug 排查 | `debug_guide` |
|
|
161
|
+
| 上线部署 | 信息缺口检查 |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### spec_interrogate
|
|
166
|
+
|
|
167
|
+
Analyze requirement completeness and generate clarification questions.
|
|
168
|
+
|
|
169
|
+
**Input:**
|
|
170
|
+
- `raw_idea` (required): User's original idea description
|
|
171
|
+
- `scenario`: `build_product` | `modify_ui` | `debug` | `launch` | `unknown`
|
|
172
|
+
- `target_platform`: `web` | `mini_program` | `app` | `backend` | `unknown`
|
|
173
|
+
- `strictness`: `light` | `normal` | `grill`
|
|
174
|
+
- `known_context`: Object with known context information
|
|
175
|
+
|
|
176
|
+
**Example:**
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"raw_idea": "我想做一个报名系统,用户可以提交资料,后台能看到",
|
|
180
|
+
"scenario": "build_product",
|
|
181
|
+
"target_platform": "web"
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### spec_compile
|
|
186
|
+
|
|
187
|
+
Compile full product specification and development prompt.
|
|
188
|
+
|
|
189
|
+
**Input:**
|
|
190
|
+
- `raw_idea` (required): User's original idea
|
|
191
|
+
- `answers`: Object with answers to clarification questions
|
|
192
|
+
- `allow_assumptions`: boolean (default: true)
|
|
193
|
+
- `min_readiness_score`: number (default: 70)
|
|
194
|
+
|
|
195
|
+
**Example:**
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"raw_idea": "报名系统",
|
|
199
|
+
"answers": {
|
|
200
|
+
"target_user": "学生",
|
|
201
|
+
"platform": "web",
|
|
202
|
+
"data_persistence": true
|
|
203
|
+
},
|
|
204
|
+
"allow_assumptions": true
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### architecture_decide
|
|
209
|
+
|
|
210
|
+
Make architecture decisions based on product type and features.
|
|
211
|
+
|
|
212
|
+
**Input:**
|
|
213
|
+
- `product_type` (required): Product type description
|
|
214
|
+
- `platform` (required): `web` | `mini_program` | `app` | `backend`
|
|
215
|
+
- `features` (required): Array of feature descriptions
|
|
216
|
+
- `commercial_intent`: boolean
|
|
217
|
+
- `expected_users`: `individual` | `small_team` | `enterprise` | `massive`
|
|
218
|
+
|
|
219
|
+
**Example:**
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"product_type": "电商系统",
|
|
223
|
+
"platform": "web",
|
|
224
|
+
"features": ["商品展示", "购物车", "支付", "订单管理"],
|
|
225
|
+
"commercial_intent": true,
|
|
226
|
+
"expected_users": "small_team"
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### ui_translate
|
|
231
|
+
|
|
232
|
+
Translate user UI descriptions into frontend terminology.
|
|
233
|
+
|
|
234
|
+
**Input:**
|
|
235
|
+
- `description` (required): User's UI description
|
|
236
|
+
- `current_page`: Current page name
|
|
237
|
+
- `target_component`: Target component name
|
|
238
|
+
|
|
239
|
+
**Example:**
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"description": "首页看起来太廉价了,高级一点",
|
|
243
|
+
"current_page": "首页"
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### debug_guide
|
|
248
|
+
|
|
249
|
+
Generate structured debugging checklists.
|
|
250
|
+
|
|
251
|
+
**Input:**
|
|
252
|
+
- `platform` (required): `web` | `mini_program` | `app` | `backend` | `build` | `unknown`
|
|
253
|
+
- `error_description` (required): Error description
|
|
254
|
+
- `current_info`: Object with known error information
|
|
255
|
+
|
|
256
|
+
**Example:**
|
|
257
|
+
```json
|
|
258
|
+
{
|
|
259
|
+
"platform": "web",
|
|
260
|
+
"error_description": "点击提交按钮后页面白屏"
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### acceptance_generate
|
|
265
|
+
|
|
266
|
+
Generate acceptance criteria for features.
|
|
267
|
+
|
|
268
|
+
**Input:**
|
|
269
|
+
- `product_type` (required): Product type
|
|
270
|
+
- `features` (required): Array of features
|
|
271
|
+
- `platform` (required): `web` | `mini_program` | `app` | `backend`
|
|
272
|
+
- `has_backend`: boolean
|
|
273
|
+
- `has_payment`: boolean
|
|
274
|
+
- `has_auth`: boolean
|
|
275
|
+
|
|
276
|
+
**Example:**
|
|
277
|
+
```json
|
|
278
|
+
{
|
|
279
|
+
"product_type": "表单工具",
|
|
280
|
+
"features": ["表单提交", "数据查看"],
|
|
281
|
+
"platform": "web",
|
|
282
|
+
"has_backend": true
|
|
283
|
+
}
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Development
|
|
287
|
+
|
|
288
|
+
### Run Tests
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
npm test
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Type Check
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
npm run typecheck
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Build
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
npm run build
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Architecture
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
src/
|
|
310
|
+
├── index.ts # Entry point
|
|
311
|
+
├── server.ts # MCP Server setup and tool registration
|
|
312
|
+
├── tools/ # Tool handlers
|
|
313
|
+
├── core/ # Business logic engines
|
|
314
|
+
├── schemas/ # Zod schemas
|
|
315
|
+
├── rules/ # JSON rule files
|
|
316
|
+
└── utils/ # Utility functions
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## License
|
|
320
|
+
|
|
321
|
+
MIT
|
|
322
|
+
|
|
323
|
+
## Structured Outputs
|
|
324
|
+
|
|
325
|
+
Each tool returns human-readable Markdown in `content` and machine-readable JSON in `structuredContent`.
|
|
326
|
+
|
|
327
|
+
**Example: `spec_interrogate` structured output**
|
|
328
|
+
|
|
329
|
+
```json
|
|
330
|
+
{
|
|
331
|
+
"readiness": {
|
|
332
|
+
"score": 35,
|
|
333
|
+
"status": "Not Ready",
|
|
334
|
+
"fields": { ... }
|
|
335
|
+
},
|
|
336
|
+
"clarification": {
|
|
337
|
+
"missingFields": ["target_user", "data_persistence"],
|
|
338
|
+
"questions": [
|
|
339
|
+
{
|
|
340
|
+
"field": "target_user",
|
|
341
|
+
"question": "目标用户是谁?",
|
|
342
|
+
"whyImportant": "决定 UI 风格、交互复杂度、技术选型",
|
|
343
|
+
"options": ["个人用户", "小团队", "企业用户"],
|
|
344
|
+
"defaultAssumption": "个人用户",
|
|
345
|
+
"priority": "P0"
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
"defaultAssumptions": { ... }
|
|
349
|
+
},
|
|
350
|
+
"recommendation": {
|
|
351
|
+
"canProceed": false,
|
|
352
|
+
"suggestedNextTool": "spec_interrogate",
|
|
353
|
+
"reason": "信息不足,需要先回答追问"
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Key structured fields:**
|
|
359
|
+
|
|
360
|
+
| Tool | Key Fields |
|
|
361
|
+
|------|------------|
|
|
362
|
+
| `spec_interrogate` | `readiness.score`, `clarification.questions`, `recommendation.canProceed` |
|
|
363
|
+
| `spec_compile` | `mode`, `spec.coreFeatures`, `nextAction.type` |
|
|
364
|
+
| `acceptance_generate` | `categories`, `checklist`, `definitionOfDone` |
|
|
365
|
+
| `architecture_decide` | `decision.canBeFrontendOnly`, `riskLevel`, `blockers` |
|
|
366
|
+
| `ui_translate` | `translation.frontendTerms`, `confidence` |
|
|
367
|
+
| `debug_guide` | `guide.checklist`, `missingRequiredInfo`, `canDiagnoseNow` |
|
|
368
|
+
|
|
369
|
+
## 示例
|
|
370
|
+
|
|
371
|
+
### 示例 1:报名系统
|
|
372
|
+
|
|
373
|
+
**输入:**
|
|
374
|
+
```json
|
|
375
|
+
{
|
|
376
|
+
"raw_idea": "我想做一个报名系统,用户可以提交资料,后台能看到所有报名信息并审核",
|
|
377
|
+
"scenario": "build_product",
|
|
378
|
+
"target_platform": "web"
|
|
379
|
+
}
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**推荐流程:**
|
|
383
|
+
|
|
384
|
+
1. 先调用 `spec_interrogate`,会追问:目标用户是谁?是否需要登录?是否需要保存数据?
|
|
385
|
+
2. 补充信息后调用 `spec_compile`,生成产品规格和开发 Prompt
|
|
386
|
+
3. 调用 `architecture_decide`,判断是否需要后端和数据库
|
|
387
|
+
4. 调用 `acceptance_generate`,生成验收清单
|
|
388
|
+
|
|
389
|
+
### 示例 2:展示官网
|
|
390
|
+
|
|
391
|
+
**输入:**
|
|
392
|
+
```json
|
|
393
|
+
{
|
|
394
|
+
"raw_idea": "做一个产品展示官网,只需要静态展示",
|
|
395
|
+
"scenario": "build_product",
|
|
396
|
+
"target_platform": "web"
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**预期行为:**
|
|
401
|
+
|
|
402
|
+
- `architecture_decide` 会推荐纯前端架构,不推荐数据库
|
|
403
|
+
- `spec_compile` 会生成简洁的静态站点规格
|
|
404
|
+
- 不会输出伪 API 设计
|