@szc-ft/mcp-szcd-client 0.11.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/agents/szcd-component-expert.md +147 -0
- package/agents/szcd-component-expert.trae.md +145 -0
- package/commands/szcd-mcp-url.md +25 -0
- package/mcp-proxy.js +543 -0
- package/package.json +56 -0
- package/scripts/lib/claude-code.js +342 -0
- package/scripts/lib/common.js +161 -0
- package/scripts/lib/opencode.js +37 -0
- package/scripts/lib/qoder.js +426 -0
- package/scripts/lib/qwen-code.js +408 -0
- package/scripts/lib/trae-cli.js +337 -0
- package/scripts/lib/trae-ide.js +198 -0
- package/scripts/lib/trae.js +65 -0
- package/scripts/postinstall.js +203 -0
- package/scripts/update-mcp-url.js +146 -0
- package/skill/SKILL.md +897 -0
- package/standard-skill/SKILL.md +1509 -0
|
@@ -0,0 +1,1509 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: szcd-component-helper
|
|
3
|
+
description: 帮助用户查询和了解 szcd 项目中的组件信息,包括 Cover 层组件、Wrapper 层组件、Ant Design 组件、ProComponents、ProPackages 以及复合组件。支持组件搜索、详情查询、使用示例搜索和文件读取。当用户需要了解 szcd 项目的组件结构、查看组件实现、寻找组件使用示例时,应使用此技能。它是一个前端组件库,全名"@szc-ft/szcd"。这是一个客户端 skill,通过 MCP 协议(SSE 或 HTTP)连接到远程 MCP 服务器。
|
|
4
|
+
compatibility:
|
|
5
|
+
tools:
|
|
6
|
+
- web_search
|
|
7
|
+
- web_fetch
|
|
8
|
+
- run_command
|
|
9
|
+
- read
|
|
10
|
+
- write
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# szcd 组件助手技能(客户端)
|
|
15
|
+
|
|
16
|
+
## 概述
|
|
17
|
+
|
|
18
|
+
此技能提供对 szcd 项目组件的查询和分析能力,帮助用户快速了解项目中的组件结构、实现细节和使用示例。
|
|
19
|
+
|
|
20
|
+
**重要说明**:这是一个客户端 skill,通过 MCP 协议(SSE 或 HTTP)连接到远程 MCP 服务器。服务器由管理员维护,包含源码和数据。
|
|
21
|
+
|
|
22
|
+
**版本**:v0.8.0 - 统一版本发布,包含 0.6.x 和 0.7.x 全部功能;新增设计稿图片分析工具(视觉代理/兜底方案),支持 OCR 降级和优先级控制;新增 .traecli agents 目录兼容
|
|
23
|
+
|
|
24
|
+
## 架构说明
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
28
|
+
│ 连接方式(三选一) │
|
|
29
|
+
├─────────────────────────────────────────────────────────────┤
|
|
30
|
+
│ │
|
|
31
|
+
│ 方式1: 本地直连 (stdio) — 推荐 │
|
|
32
|
+
│ ┌─────────────┐ stdio ┌─────────────────────────┐│
|
|
33
|
+
│ │ IDE/AI │ ◄─────────────►│ szcd-mcp-server ││
|
|
34
|
+
│ │ Client │ │ (本地运行) ││
|
|
35
|
+
│ └─────────────┘ └─────────────────────────┘│
|
|
36
|
+
│ │
|
|
37
|
+
│ 方式2: SSE 远程连接 — 推荐 │
|
|
38
|
+
│ ┌─────────────┐ SSE ┌─────────────────────────┐│
|
|
39
|
+
│ │ IDE/AI │ ◄────────────►│ MCP Server (SSE 模式) ││
|
|
40
|
+
│ │ Client │ GET /sse │ 管理员机器 ││
|
|
41
|
+
│ │ │ POST /message│ (源码 + 数据) ││
|
|
42
|
+
│ └─────────────┘ └─────────────────────────┘│
|
|
43
|
+
│ │
|
|
44
|
+
│ 方式2b: Streamable HTTP 远程连接(Trae CLI 兼容) │
|
|
45
|
+
│ ┌─────────────┐ HTTP ┌─────────────────────────┐ │
|
|
46
|
+
│ │ IDE/AI │ ◄───────────►│ MCP Server (HTTP 模式) │ │
|
|
47
|
+
│ │ Client │ POST /mcp │ 管理员机器 │ │
|
|
48
|
+
│ │ │ │ (源码 + 数据) │ │
|
|
49
|
+
│ └─────────────┘ └─────────────────────────┘ │
|
|
50
|
+
│ │
|
|
51
|
+
│ 方式3: 代理桥接 (向后兼容) │
|
|
52
|
+
│ ┌─────────────┐ stdio ┌───────────┐ SSE/HTTP ┌─────┐│
|
|
53
|
+
│ │ IDE/AI │◄───────►│mcp-proxy │◄──────────►│Server││
|
|
54
|
+
│ │ Client │ │(桥接代理) │ │ ││
|
|
55
|
+
│ └─────────────┘ └───────────┘ └─────┘│
|
|
56
|
+
└─────────────────────────────────────────────────────────────┘
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 可用工具
|
|
60
|
+
|
|
61
|
+
### 复合组件工具 (Other Components)
|
|
62
|
+
|
|
63
|
+
#### 1. list_other_components
|
|
64
|
+
**功能**:列出 `src/other/components/index.js` 中导出的复合组件与工具
|
|
65
|
+
**参数**:无
|
|
66
|
+
**返回**:复合组件列表
|
|
67
|
+
|
|
68
|
+
##### MCP协议调用示例(底层)
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"jsonrpc": "2.0",
|
|
72
|
+
"id": 1,
|
|
73
|
+
"method": "tools/call",
|
|
74
|
+
"params": {
|
|
75
|
+
"name": "list_other_components",
|
|
76
|
+
"arguments": {}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
##### Trae CLI 调用示例
|
|
82
|
+
|
|
83
|
+
**自然语言触发**:
|
|
84
|
+
```
|
|
85
|
+
请列出项目中的复合组件。
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
89
|
+
```json
|
|
90
|
+
mcp__szcd-component-helper__list_other_components()
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**返回值示例**:
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"exports": [
|
|
97
|
+
"LeftTree", "Query", "TitleAndBack", "TableOrList",
|
|
98
|
+
"FormItemOrDetailItem", "IconfontWapper", "TemplateMode",
|
|
99
|
+
"ModelOrDrawer", "ModeAvatar", "listToTree", "generateUniqueId",
|
|
100
|
+
"getBelongCate", "getparentDataById", "getAllIds",
|
|
101
|
+
"HTML5Backend", "DndProvider", "DragPreviewImage",
|
|
102
|
+
"useDrag", "useDrop", "useDragDropManager", "useDragLayer"
|
|
103
|
+
],
|
|
104
|
+
"exportIndex": "src/other/components/index.js"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
##### Claude Code 调用示例
|
|
109
|
+
```
|
|
110
|
+
请列出项目中的复合组件。
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
##### Qwen Code 调用示例
|
|
114
|
+
```
|
|
115
|
+
请列出项目中的复合组件。
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### 2. get_other_component
|
|
119
|
+
**功能**:根据组件名获取实现路径、types、docs、透传目标与 props 列表
|
|
120
|
+
**参数**:
|
|
121
|
+
- `name` (string, required): 组件名称
|
|
122
|
+
|
|
123
|
+
##### MCP协议调用示例(底层)
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"jsonrpc": "2.0",
|
|
127
|
+
"id": 2,
|
|
128
|
+
"method": "tools/call",
|
|
129
|
+
"params": {
|
|
130
|
+
"name": "get_other_component",
|
|
131
|
+
"arguments": {
|
|
132
|
+
"name": "Query"
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
##### Trae CLI 调用示例
|
|
139
|
+
|
|
140
|
+
**自然语言触发**:
|
|
141
|
+
```
|
|
142
|
+
请获取Query组件的详细信息。
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
146
|
+
```json
|
|
147
|
+
mcp__szcd-component-helper__get_other_component({ "name": "Query" })
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**返回值示例**:
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"name": "Query",
|
|
154
|
+
"found": true,
|
|
155
|
+
"exportIndex": "src/other/components/index.js",
|
|
156
|
+
"folder": "src/other/components/Query",
|
|
157
|
+
"implementation": "src/other/components/Query/index.tsx",
|
|
158
|
+
"types": null,
|
|
159
|
+
"docs": [],
|
|
160
|
+
"props": null,
|
|
161
|
+
"passthroughTargets": [
|
|
162
|
+
{ "component": "Select", "spread": "..restProps}" },
|
|
163
|
+
{ "component": "DatePicker", "spread": "..restProps}" },
|
|
164
|
+
{ "component": "Input", "spread": "..restProps} /" },
|
|
165
|
+
{ "component": "ProFormText", "spread": "..others} labelAlign='left' style={{ width: \"100%\" }} /" }
|
|
166
|
+
],
|
|
167
|
+
"examples": [
|
|
168
|
+
{ "file": "mode-packages/query/demo/base.jsx", "type": "demo" }
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
##### Claude Code 调用示例
|
|
174
|
+
```
|
|
175
|
+
请获取Query组件的详细信息。
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
##### Qwen Code 调用示例
|
|
179
|
+
```
|
|
180
|
+
请获取Query组件的详细信息。
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### 3. search_component_examples
|
|
184
|
+
**功能**:在仓库内搜索组件名的用法片段(md/js/ts/tsx)
|
|
185
|
+
**参数**:
|
|
186
|
+
- `name` (string, required): 组件名称
|
|
187
|
+
- `maxResults` (number, optional, default: 20): 最大结果数,范围1-50
|
|
188
|
+
|
|
189
|
+
##### MCP协议调用示例(底层)
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"jsonrpc": "2.0",
|
|
193
|
+
"id": 3,
|
|
194
|
+
"method": "tools/call",
|
|
195
|
+
"params": {
|
|
196
|
+
"name": "search_component_examples",
|
|
197
|
+
"arguments": {
|
|
198
|
+
"name": "TableOrList",
|
|
199
|
+
"maxResults": 10
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
##### Trae CLI 调用示例
|
|
206
|
+
|
|
207
|
+
**自然语言触发**:
|
|
208
|
+
```
|
|
209
|
+
请搜索TableOrList组件的使用示例,最多返回5个。
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
213
|
+
```json
|
|
214
|
+
mcp__szcd-component-helper__search_component_examples({ "name": "TableOrList", "maxResults": 5 })
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**返回值示例**:
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"name": "TableOrList",
|
|
221
|
+
"hits": [
|
|
222
|
+
{
|
|
223
|
+
"file": "mode-packages/table-or-list/demo/base.jsx",
|
|
224
|
+
"type": "demo",
|
|
225
|
+
"content": "import React, { useState, useRef } from 'react';\nimport { TableOrList } from '@szc-ft/szcd'..."
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"file": "mode-packages/table-or-list/demo/base1.jsx",
|
|
229
|
+
"type": "demo",
|
|
230
|
+
"content": "import React, { useState, useRef } from 'react';\nimport { TableOrList } from '@szc-ft/szcd'..."
|
|
231
|
+
}
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
##### Claude Code 调用示例
|
|
237
|
+
```
|
|
238
|
+
请搜索TableOrList组件的使用示例,最多返回10个。
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
##### Qwen Code 调用示例
|
|
242
|
+
```
|
|
243
|
+
请搜索TableOrList组件的使用示例,最多返回10个。
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Cover层组件工具
|
|
247
|
+
|
|
248
|
+
#### 4. list_cover_components
|
|
249
|
+
**功能**:列出 src/components/cover/ 目录下的 Cover 层封装组件
|
|
250
|
+
**参数**:无
|
|
251
|
+
|
|
252
|
+
##### MCP协议调用示例(底层)
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"jsonrpc": "2.0",
|
|
256
|
+
"id": 4,
|
|
257
|
+
"method": "tools/call",
|
|
258
|
+
"params": {
|
|
259
|
+
"name": "list_cover_components",
|
|
260
|
+
"arguments": {}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
##### Trae CLI 调用示例
|
|
266
|
+
|
|
267
|
+
**自然语言触发**:
|
|
268
|
+
```
|
|
269
|
+
请列出Cover层的封装组件。
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
273
|
+
```json
|
|
274
|
+
mcp__szcd-component-helper__list_cover_components()
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
##### Claude Code 调用示例
|
|
278
|
+
```
|
|
279
|
+
请列出Cover层的封装组件。
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
##### Qwen Code 调用示例
|
|
283
|
+
```
|
|
284
|
+
请列出Cover层的封装组件。
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
#### 5. get_cover_component
|
|
288
|
+
**功能**:获取 Cover 层组件的详细信息,包括实现路径、Props 定义、透传目标等
|
|
289
|
+
**参数**:
|
|
290
|
+
- `name` (string, required): 组件名称
|
|
291
|
+
|
|
292
|
+
##### MCP协议调用示例(底层)
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"jsonrpc": "2.0",
|
|
296
|
+
"id": 5,
|
|
297
|
+
"method": "tools/call",
|
|
298
|
+
"params": {
|
|
299
|
+
"name": "get_cover_component",
|
|
300
|
+
"arguments": {
|
|
301
|
+
"name": "Button"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
##### Trae CLI 调用示例
|
|
308
|
+
|
|
309
|
+
**自然语言触发**:
|
|
310
|
+
```
|
|
311
|
+
请获取Cover层Button组件的详细信息。
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
315
|
+
```json
|
|
316
|
+
mcp__szcd-component-helper__get_cover_component({ "name": "Button" })
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
##### Claude Code 调用示例
|
|
320
|
+
```
|
|
321
|
+
请获取Cover层Button组件的详细信息。
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
##### Qwen Code 调用示例
|
|
325
|
+
```
|
|
326
|
+
请获取Cover层Button组件的详细信息。
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Wrapper层组件工具
|
|
330
|
+
|
|
331
|
+
#### 6. list_wrapper_components
|
|
332
|
+
**功能**:列出 src/components/wrappers/ 目录下的 Wrapper 层业务组件
|
|
333
|
+
**参数**:无
|
|
334
|
+
|
|
335
|
+
##### MCP协议调用示例(底层)
|
|
336
|
+
```json
|
|
337
|
+
{
|
|
338
|
+
"jsonrpc": "2.0",
|
|
339
|
+
"id": 6,
|
|
340
|
+
"method": "tools/call",
|
|
341
|
+
"params": {
|
|
342
|
+
"name": "list_wrapper_components",
|
|
343
|
+
"arguments": {}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
##### Trae CLI 调用示例
|
|
349
|
+
|
|
350
|
+
**自然语言触发**:
|
|
351
|
+
```
|
|
352
|
+
请列出Wrapper层的业务组件。
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
356
|
+
```json
|
|
357
|
+
mcp__szcd-component-helper__list_wrapper_components()
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
##### Claude Code 调用示例
|
|
361
|
+
```
|
|
362
|
+
请列出Wrapper层的业务组件。
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
##### Qwen Code 调用示例
|
|
366
|
+
```
|
|
367
|
+
请列出Wrapper层的业务组件。
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### ProPackages组件工具
|
|
371
|
+
|
|
372
|
+
#### 7. list_pro_package_components
|
|
373
|
+
**功能**:列出 pro-packages/ 目录下的 ProPackages 组件封装
|
|
374
|
+
**参数**:无
|
|
375
|
+
|
|
376
|
+
##### MCP协议调用示例(底层)
|
|
377
|
+
```json
|
|
378
|
+
{
|
|
379
|
+
"jsonrpc": "2.0",
|
|
380
|
+
"id": 7,
|
|
381
|
+
"method": "tools/call",
|
|
382
|
+
"params": {
|
|
383
|
+
"name": "list_pro_package_components",
|
|
384
|
+
"arguments": {}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
##### Trae CLI 调用示例
|
|
390
|
+
|
|
391
|
+
**自然语言触发**:
|
|
392
|
+
```
|
|
393
|
+
请列出ProPackages的组件封装。
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
397
|
+
```json
|
|
398
|
+
mcp__szcd-component-helper__list_pro_package_components()
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
##### Claude Code 调用示例
|
|
402
|
+
```
|
|
403
|
+
请列出ProPackages的组件封装。
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
##### Qwen Code 调用示例
|
|
407
|
+
```
|
|
408
|
+
请列出ProPackages的组件封装。
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Ant Design组件工具
|
|
412
|
+
|
|
413
|
+
#### 8. list_antd_components
|
|
414
|
+
**功能**:列出 Ant Design 组件的分类概览和各分类下的组件数量
|
|
415
|
+
**参数**:无
|
|
416
|
+
|
|
417
|
+
##### MCP协议调用示例(底层)
|
|
418
|
+
```json
|
|
419
|
+
{
|
|
420
|
+
"jsonrpc": "2.0",
|
|
421
|
+
"id": 8,
|
|
422
|
+
"method": "tools/call",
|
|
423
|
+
"params": {
|
|
424
|
+
"name": "list_antd_components",
|
|
425
|
+
"arguments": {}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
##### Trae CLI 调用示例
|
|
431
|
+
|
|
432
|
+
**自然语言触发**:
|
|
433
|
+
```
|
|
434
|
+
请列出Ant Design组件的分类概览。
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
438
|
+
```json
|
|
439
|
+
mcp__szcd-component-helper__list_antd_components()
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
##### Claude Code 调用示例
|
|
443
|
+
```
|
|
444
|
+
请列出Ant Design组件的分类概览。
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
##### Qwen Code 调用示例
|
|
448
|
+
```
|
|
449
|
+
请列出Ant Design组件的分类概览。
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### 9. list_antd_components_by_category
|
|
453
|
+
**功能**:按分类列出 Ant Design 组件
|
|
454
|
+
**参数**:
|
|
455
|
+
- `category` (enum, optional, default: "通用"): 组件分类,可选值:通用、布局、导航、数据录入、数据展示、反馈、其他
|
|
456
|
+
|
|
457
|
+
##### MCP协议调用示例(底层)
|
|
458
|
+
```json
|
|
459
|
+
{
|
|
460
|
+
"jsonrpc": "2.0",
|
|
461
|
+
"id": 9,
|
|
462
|
+
"method": "tools/call",
|
|
463
|
+
"params": {
|
|
464
|
+
"name": "list_antd_components_by_category",
|
|
465
|
+
"arguments": {
|
|
466
|
+
"category": "数据录入"
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
##### Trae CLI 调用示例
|
|
473
|
+
|
|
474
|
+
**自然语言触发**:
|
|
475
|
+
```
|
|
476
|
+
请按分类列出Ant Design的数据录入组件。
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
480
|
+
```json
|
|
481
|
+
mcp__szcd-component-helper__list_antd_components_by_category({ "category": "数据录入" })
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
##### Claude Code 调用示例
|
|
485
|
+
```
|
|
486
|
+
请按分类列出Ant Design的数据录入组件。
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
##### Qwen Code 调用示例
|
|
490
|
+
```
|
|
491
|
+
请按分类列出Ant Design的数据录入组件。
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
#### 10. get_antd_component
|
|
495
|
+
**功能**:获取 Ant Design 组件的详细信息
|
|
496
|
+
**参数**:
|
|
497
|
+
- `name` (string, required): 组件名称
|
|
498
|
+
|
|
499
|
+
##### MCP协议调用示例(底层)
|
|
500
|
+
```json
|
|
501
|
+
{
|
|
502
|
+
"jsonrpc": "2.0",
|
|
503
|
+
"id": 10,
|
|
504
|
+
"method": "tools/call",
|
|
505
|
+
"params": {
|
|
506
|
+
"name": "get_antd_component",
|
|
507
|
+
"arguments": {
|
|
508
|
+
"name": "Input"
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
##### Trae CLI 调用示例
|
|
515
|
+
|
|
516
|
+
**自然语言触发**:
|
|
517
|
+
```
|
|
518
|
+
请获取Ant Design Input组件的详细信息。
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
522
|
+
```json
|
|
523
|
+
mcp__szcd-component-helper__get_antd_component({ "name": "Input" })
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
##### Claude Code 调用示例
|
|
527
|
+
```
|
|
528
|
+
请获取Ant Design Input组件的详细信息。
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
##### Qwen Code 调用示例
|
|
532
|
+
```
|
|
533
|
+
请获取Ant Design Input组件的详细信息。
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
### ProComponents组件工具
|
|
537
|
+
|
|
538
|
+
#### 11. list_pro_components
|
|
539
|
+
**功能**:列出 ProComponents 组件的分类概览
|
|
540
|
+
**参数**:无
|
|
541
|
+
|
|
542
|
+
##### MCP协议调用示例(底层)
|
|
543
|
+
```json
|
|
544
|
+
{
|
|
545
|
+
"jsonrpc": "2.0",
|
|
546
|
+
"id": 11,
|
|
547
|
+
"method": "tools/call",
|
|
548
|
+
"params": {
|
|
549
|
+
"name": "list_pro_components",
|
|
550
|
+
"arguments": {}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
##### Trae CLI 调用示例
|
|
556
|
+
|
|
557
|
+
**自然语言触发**:
|
|
558
|
+
```
|
|
559
|
+
请列出ProComponents的分类概览。
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
563
|
+
```json
|
|
564
|
+
mcp__szcd-component-helper__list_pro_components()
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
##### Claude Code 调用示例
|
|
568
|
+
```
|
|
569
|
+
请列出ProComponents的分类概览。
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
##### Qwen Code 调用示例
|
|
573
|
+
```
|
|
574
|
+
请列出ProComponents的分类概览。
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
#### 12. list_pro_components_by_category
|
|
578
|
+
**功能**:按分类列出 ProComponents 组件
|
|
579
|
+
**参数**:
|
|
580
|
+
- `category` (enum, optional, default: "数据录入"): 组件分类,可选值:数据录入、数据展示、布局、反馈
|
|
581
|
+
|
|
582
|
+
##### MCP协议调用示例(底层)
|
|
583
|
+
```json
|
|
584
|
+
{
|
|
585
|
+
"jsonrpc": "2.0",
|
|
586
|
+
"id": 12,
|
|
587
|
+
"method": "tools/call",
|
|
588
|
+
"params": {
|
|
589
|
+
"name": "list_pro_components_by_category",
|
|
590
|
+
"arguments": {
|
|
591
|
+
"category": "数据展示"
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
##### Trae CLI 调用示例
|
|
598
|
+
|
|
599
|
+
**自然语言触发**:
|
|
600
|
+
```
|
|
601
|
+
请按分类列出ProComponents的数据展示组件。
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
605
|
+
```json
|
|
606
|
+
mcp__szcd-component-helper__list_pro_components_by_category({ "category": "数据展示" })
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
##### Claude Code 调用示例
|
|
610
|
+
```
|
|
611
|
+
请按分类列出ProComponents的数据展示组件。
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
##### Qwen Code 调用示例
|
|
615
|
+
```
|
|
616
|
+
请按分类列出ProComponents的数据展示组件。
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
#### 13. get_pro_component
|
|
620
|
+
**功能**:获取 ProComponents 组件的详细信息
|
|
621
|
+
**参数**:
|
|
622
|
+
- `name` (string, required): 组件名称
|
|
623
|
+
|
|
624
|
+
##### MCP协议调用示例(底层)
|
|
625
|
+
```json
|
|
626
|
+
{
|
|
627
|
+
"jsonrpc": "2.0",
|
|
628
|
+
"id": 13,
|
|
629
|
+
"method": "tools/call",
|
|
630
|
+
"params": {
|
|
631
|
+
"name": "get_pro_component",
|
|
632
|
+
"arguments": {
|
|
633
|
+
"name": "ProTable"
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
##### Trae CLI 调用示例
|
|
640
|
+
|
|
641
|
+
**自然语言触发**:
|
|
642
|
+
```
|
|
643
|
+
请获取ProTable组件的详细信息。
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
647
|
+
```json
|
|
648
|
+
mcp__szcd-component-helper__get_pro_component({ "name": "ProTable" })
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
##### Claude Code 调用示例
|
|
652
|
+
```
|
|
653
|
+
请获取ProTable组件的详细信息。
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
##### Qwen Code 调用示例
|
|
657
|
+
```
|
|
658
|
+
请获取ProTable组件的详细信息。
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### 全局功能工具
|
|
662
|
+
|
|
663
|
+
#### 14. search_all_components
|
|
664
|
+
**功能**:全局搜索所有层级的组件
|
|
665
|
+
**参数**:
|
|
666
|
+
- `keyword` (string, required): 搜索关键词
|
|
667
|
+
- `type` (enum, optional): 按类型筛选,可选值:cover、wrapper、pro-package、antd、pro-components、other
|
|
668
|
+
|
|
669
|
+
##### MCP协议调用示例(底层)
|
|
670
|
+
```json
|
|
671
|
+
{
|
|
672
|
+
"jsonrpc": "2.0",
|
|
673
|
+
"id": 14,
|
|
674
|
+
"method": "tools/call",
|
|
675
|
+
"params": {
|
|
676
|
+
"name": "search_all_components",
|
|
677
|
+
"arguments": {
|
|
678
|
+
"keyword": "form",
|
|
679
|
+
"type": "pro-components"
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
##### Trae CLI 调用示例
|
|
686
|
+
|
|
687
|
+
**自然语言触发**:
|
|
688
|
+
```
|
|
689
|
+
请搜索包含"form"的ProComponents组件。
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
693
|
+
```json
|
|
694
|
+
mcp__szcd-component-helper__search_all_components({ "keyword": "form", "type": "pro-components" })
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
##### Claude Code 调用示例
|
|
698
|
+
```
|
|
699
|
+
请搜索包含"form"的ProComponents组件。
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
##### Qwen Code 调用示例
|
|
703
|
+
```
|
|
704
|
+
请搜索包含"form"的ProComponents组件。
|
|
705
|
+
```
|
|
706
|
+
|
|
707
|
+
#### 15. get_component_library_overview
|
|
708
|
+
**功能**:获取组件库的完整概览
|
|
709
|
+
**参数**:无
|
|
710
|
+
|
|
711
|
+
##### MCP协议调用示例(底层)
|
|
712
|
+
```json
|
|
713
|
+
{
|
|
714
|
+
"jsonrpc": "2.0",
|
|
715
|
+
"id": 15,
|
|
716
|
+
"method": "tools/call",
|
|
717
|
+
"params": {
|
|
718
|
+
"name": "get_component_library_overview",
|
|
719
|
+
"arguments": {}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
```
|
|
723
|
+
|
|
724
|
+
##### Trae CLI 调用示例
|
|
725
|
+
|
|
726
|
+
**自然语言触发**:
|
|
727
|
+
```
|
|
728
|
+
请提供组件库的完整概览。
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
732
|
+
```json
|
|
733
|
+
mcp__szcd-component-helper__get_component_library_overview()
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
**返回值示例**:
|
|
737
|
+
```json
|
|
738
|
+
{
|
|
739
|
+
"summary": {
|
|
740
|
+
"antDesign": { "count": 0, "description": "Ant Design 官方组件" },
|
|
741
|
+
"proComponents": { "count": 0, "description": "ProComponents 高级组件" },
|
|
742
|
+
"coverLayer": { "count": 36, "description": "Cover 层封装组件", "path": "src/components/cover" },
|
|
743
|
+
"wrapperLayer": { "count": 7, "description": "Wrapper 层业务组件", "path": "src/components/wrappers" },
|
|
744
|
+
"proPackages": { "count": 8, "description": "ProPackages 封装", "path": "pro-packages" },
|
|
745
|
+
"compositeComponents": { "count": 21, "description": "复合业务组件", "path": "src/other/components" }
|
|
746
|
+
},
|
|
747
|
+
"totalCustomComponents": 72
|
|
748
|
+
}
|
|
749
|
+
```
|
|
750
|
+
|
|
751
|
+
##### Claude Code 调用示例
|
|
752
|
+
```
|
|
753
|
+
请提供组件库的完整概览。
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
##### Qwen Code 调用示例
|
|
757
|
+
```
|
|
758
|
+
请提供组件库的完整概览。
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
### 文件操作工具
|
|
762
|
+
|
|
763
|
+
#### 16. read_file
|
|
764
|
+
**功能**:读取仓库内文件(相对路径)
|
|
765
|
+
**参数**:
|
|
766
|
+
- `path` (string, required): 文件相对路径
|
|
767
|
+
- `maxChars` (number, optional, default: 20000): 最大字符数,范围200-200000
|
|
768
|
+
|
|
769
|
+
##### MCP协议调用示例(底层)
|
|
770
|
+
```json
|
|
771
|
+
{
|
|
772
|
+
"jsonrpc": "2.0",
|
|
773
|
+
"id": 16,
|
|
774
|
+
"method": "tools/call",
|
|
775
|
+
"params": {
|
|
776
|
+
"name": "read_file",
|
|
777
|
+
"arguments": {
|
|
778
|
+
"path": "src/other/components/Query/index.tsx",
|
|
779
|
+
"maxChars": 5000
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
##### Trae CLI 调用示例
|
|
786
|
+
|
|
787
|
+
**自然语言触发**:
|
|
788
|
+
```
|
|
789
|
+
请读取src/other/components/Query/index.tsx文件内容,最多5000个字符。
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
793
|
+
```json
|
|
794
|
+
mcp__szcd-component-helper__read_file({ "path": "src/other/components/Query/index.tsx", "maxChars": 5000 })
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
##### Claude Code 调用示例
|
|
798
|
+
```
|
|
799
|
+
请读取src/other/components/Query/index.tsx文件内容,最多5000个字符。
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
##### Qwen Code 调用示例
|
|
803
|
+
```
|
|
804
|
+
请读取src/other/components/Query/index.tsx文件内容,最多5000个字符。
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
#### 17. get_accurate_component_doc
|
|
808
|
+
**功能**:获取复合组件的准确Props文档,包含透传机制的详细说明
|
|
809
|
+
**参数**:
|
|
810
|
+
- `name` (string, required): 组件名称
|
|
811
|
+
|
|
812
|
+
##### MCP协议调用示例(底层)
|
|
813
|
+
```json
|
|
814
|
+
{
|
|
815
|
+
"jsonrpc": "2.0",
|
|
816
|
+
"id": 17,
|
|
817
|
+
"method": "tools/call",
|
|
818
|
+
"params": {
|
|
819
|
+
"name": "get_accurate_component_doc",
|
|
820
|
+
"arguments": {
|
|
821
|
+
"name": "Query"
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
```
|
|
826
|
+
|
|
827
|
+
##### Trae CLI 调用示例
|
|
828
|
+
|
|
829
|
+
**自然语言触发**:
|
|
830
|
+
```
|
|
831
|
+
请获取Query组件的准确文档,包含透传机制说明。
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
835
|
+
```json
|
|
836
|
+
mcp__szcd-component-helper__get_accurate_component_doc({ "name": "Query" })
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
##### Claude Code 调用示例
|
|
840
|
+
```
|
|
841
|
+
请获取Query组件的准确文档,包含透传机制说明。
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
##### Qwen Code 调用示例
|
|
845
|
+
```
|
|
846
|
+
请获取Query组件的准确文档,包含透传机制说明。
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
### 缓存管理工具
|
|
850
|
+
|
|
851
|
+
#### 18. refresh_component_docs
|
|
852
|
+
**功能**:刷新 Ant Design / ProComponents 组件文档缓存
|
|
853
|
+
**参数**:
|
|
854
|
+
- `source` (enum, optional, default: "all"): 刷新来源,可选值:antd、pro-components、all
|
|
855
|
+
|
|
856
|
+
##### MCP协议调用示例(底层)
|
|
857
|
+
```json
|
|
858
|
+
{
|
|
859
|
+
"jsonrpc": "2.0",
|
|
860
|
+
"id": 18,
|
|
861
|
+
"method": "tools/call",
|
|
862
|
+
"params": {
|
|
863
|
+
"name": "refresh_component_docs",
|
|
864
|
+
"arguments": {
|
|
865
|
+
"source": "all"
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
##### Trae CLI 调用示例
|
|
872
|
+
|
|
873
|
+
**自然语言触发**:
|
|
874
|
+
```
|
|
875
|
+
请刷新所有组件文档缓存。
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
879
|
+
```json
|
|
880
|
+
mcp__szcd-component-helper__refresh_component_docs({ "source": "all" })
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
##### Claude Code 调用示例
|
|
884
|
+
```
|
|
885
|
+
请刷新所有组件文档缓存。
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
##### Qwen Code 调用示例
|
|
889
|
+
```
|
|
890
|
+
请刷新所有组件文档缓存。
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
### 设计稿图片分析工具(兜底/代理)
|
|
894
|
+
|
|
895
|
+
> **核心定位**:此工具是**兜底机制**,专门解决"用户使用的 LLM 不支持图片理解"的问题。
|
|
896
|
+
>
|
|
897
|
+
> 当用户的 IDE/AI 是纯文本模型(无法直接看设计稿截图)时,由 MCP 服务器调用多模态模型代为"看图",将图片内容转化为结构化文本返回给用户 LLM,让用户 LLM 基于文字描述生成代码。如果用户的 LLM 本身支持图片输入(如 Claude 4、GPT-4o),则**不需要**使用此工具。
|
|
898
|
+
|
|
899
|
+
#### 19. analyze_design_image
|
|
900
|
+
**功能**:分析UI设计稿图片,将视觉设计转化为结构化文本描述。支持三通道提取,追求设计稿样式的高度还原:
|
|
901
|
+
|
|
902
|
+
- **通道1: ConfigProvider Token** — 对齐 tokenConfig.json 结构,精确提取全局 Token 和组件级 Token,自动对比 szcd 默认值生成 themeDiff,输出可直接使用的 `<ConfigProvider theme={...}>` 配置代码
|
|
903
|
+
- **通道2: CSS 覆盖层** — 提取 ConfigProvider Token 无法覆盖的样式属性(布局、伪元素、间距、边框、动画、字体族等),生成组件级 CSS 覆盖代码
|
|
904
|
+
- **通道3: 视觉细节** — 提取渐变色、滚动条、遮罩层、状态变体(hover/focus/active/disabled)等更细粒度的视觉信息,生成全局 CSS 覆盖代码
|
|
905
|
+
|
|
906
|
+
**参数**:
|
|
907
|
+
- `imageSource` (string, required): 图片数据:base64编码字符串、HTTP/HTTPS URL、或相对于项目根目录的文件路径
|
|
908
|
+
- `sourceType` (enum, optional, default: "file_path"): 图片来源类型:base64、url、file_path
|
|
909
|
+
- `analysisType` (enum, optional, default: "full"): 分析类型:layout(布局)、components(组件)、tokens(通道1)、full(通道1+2)、pixel_perfect(全部三通道+8K输出)
|
|
910
|
+
- `pageContext` (string, optional): 页面业务上下文描述
|
|
911
|
+
- `targetLibrary` (enum, optional, default: "auto"): 期望匹配的组件库:szcd、antd、pro-components、auto
|
|
912
|
+
- `outputFormat` (enum, optional, default: "markdown"): 输出格式:markdown、json、structured_text、restoration_code(一键输出完整还原代码)
|
|
913
|
+
|
|
914
|
+
**返回值**(full/pixel_perfect 模式):
|
|
915
|
+
- designTokens: 全局 Token(对齐 tokenConfig.json)
|
|
916
|
+
- componentStyleTokens: 组件级 Token
|
|
917
|
+
- themeDiff: 与默认值差异 + ConfigProvider 代码
|
|
918
|
+
- cssOverrides: 组件级 CSS 覆盖代码
|
|
919
|
+
- visualDetails: 视觉细节(仅 pixel_perfect)
|
|
920
|
+
- fidelityScore: 还原度评分(0-100)
|
|
921
|
+
|
|
922
|
+
### 样式注入指南工具
|
|
923
|
+
|
|
924
|
+
#### 20. get_style_injection_guide
|
|
925
|
+
**功能**:查询 szcd 复合组件的样式注入方法。返回指定组件的可用样式 props、注入方式(ModeStyle/TreeBoxStyle/btnStyle/inline style等)、代码示例,以及组件嵌套时的 CSS 穿透路径和智能分配策略。
|
|
926
|
+
|
|
927
|
+
**适用场景**:
|
|
928
|
+
- 已有设计稿分析结果但需要知道如何将 CSS 注入到组件中
|
|
929
|
+
- 使用 Sketch/Figma MCP 获取了设计规范后需了解 szcd 组件的样式定制方式
|
|
930
|
+
- 开发时需要快速查询某个组件支持哪些样式 props
|
|
931
|
+
|
|
932
|
+
**参数**:
|
|
933
|
+
- `componentNames` (string[], optional): 要查询的组件名列表,如 ['Query', 'TableOrList', 'LeftTree']。不传则返回所有复合组件的完整指南
|
|
934
|
+
- `includeNesting` (boolean, optional, default: true): 是否包含嵌套注入指南(TemplateMode/ModelOrDrawer 容器场景的 CSS 穿透路径和分配策略)
|
|
935
|
+
- `includeSmartDistribute` (boolean, optional, default: false): 是否包含智能 CSS 分配建议(需要传入 cssOverrides 参数)
|
|
936
|
+
- `cssOverrides` (array, optional): CSS 覆盖列表(用于智能分配),格式与 analyze_design_image 返回的 cssOverrides.perComponent 一致
|
|
937
|
+
- `outputFormat` (enum, optional, default: "markdown"): 输出格式:markdown、json、text
|
|
938
|
+
|
|
939
|
+
**4种注入方式**:
|
|
940
|
+
- `modeStyle`: ModeStyle prop → styled-components 注入(Query, TableOrList, LeftTree, TitleAndBack, TemplateMode, ModeAvatar)
|
|
941
|
+
- `modeStyleTag`: ModeStyle prop → 动态 `<style>` 标签注入(ModelOrDrawer 专属)
|
|
942
|
+
- `inlineOnly`: 仅 inline style / 全局 CSS(FormItemOrDetailItem, CustomOption, TreeNode)
|
|
943
|
+
- `passthrough`: className/style prop 透传(IconfontWapper)
|
|
944
|
+
|
|
945
|
+
**嵌套场景**:
|
|
946
|
+
- TemplateMode 的 ModeStyle 可穿透到子组件(通过 `.leftContentBox` / `.rightContentBox_top` / `.rightContentBox_bottom` 定位)
|
|
947
|
+
- ModelOrDrawer DOM 挂载在 document.body,父级穿不透
|
|
948
|
+
|
|
949
|
+
##### MCP协议调用示例(底层)
|
|
950
|
+
```json
|
|
951
|
+
{
|
|
952
|
+
"jsonrpc": "2.0",
|
|
953
|
+
"id": 20,
|
|
954
|
+
"method": "tools/call",
|
|
955
|
+
"params": {
|
|
956
|
+
"name": "get_style_injection_guide",
|
|
957
|
+
"arguments": {
|
|
958
|
+
"componentNames": ["Query"],
|
|
959
|
+
"includeNesting": true
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
##### Trae CLI 调用示例
|
|
966
|
+
|
|
967
|
+
**自然语言触发**:
|
|
968
|
+
```
|
|
969
|
+
请查询 Query 组件的样式注入方法。
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
**实际 MCP 工具调用**(Trae CLI 自动生成):
|
|
973
|
+
```json
|
|
974
|
+
mcp__szcd-component-helper__get_style_injection_guide({ "componentNames": ["Query"], "includeNesting": true })
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
**返回值示例**:
|
|
978
|
+
```json
|
|
979
|
+
{
|
|
980
|
+
"component": "Query",
|
|
981
|
+
"injectionType": "modeStyle",
|
|
982
|
+
"description": "ModeStyle prop → styled-components 注入",
|
|
983
|
+
"styleProps": ["ModeStyle"],
|
|
984
|
+
"codeExample": "<Query ModeStyle={{ padding: '16px', background: '#fff' }} />",
|
|
985
|
+
"nestingGuide": null
|
|
986
|
+
}
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
##### Claude Code 调用示例
|
|
990
|
+
```
|
|
991
|
+
请查询 Query 组件的样式注入方法。
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
##### Qwen Code 调用示例
|
|
995
|
+
```
|
|
996
|
+
请查询 TemplateMode 和 Query 组件的样式注入指南,包括嵌套场景。
|
|
997
|
+
```
|
|
998
|
+
|
|
999
|
+
## 安装方式
|
|
1000
|
+
|
|
1001
|
+
### 通过 npm 安装
|
|
1002
|
+
|
|
1003
|
+
```bash
|
|
1004
|
+
npm install @szc-ft/mcp-szcd-component-helper
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
安装后会自动:
|
|
1008
|
+
- 安装 MCP 代理脚本
|
|
1009
|
+
- 自动配置 skill 到 `~/.trae-cn/skills/szcd-component-helper/`
|
|
1010
|
+
- 创建配置文件模板 `~/.szcd-mcp-config.json`
|
|
1011
|
+
|
|
1012
|
+
## 配置步骤
|
|
1013
|
+
|
|
1014
|
+
### 步骤1:安装客户端包
|
|
1015
|
+
|
|
1016
|
+
```bash
|
|
1017
|
+
npm install @szc-ft/mcp-szcd-component-helper
|
|
1018
|
+
```
|
|
1019
|
+
|
|
1020
|
+
### 步骤2:配置服务器地址
|
|
1021
|
+
|
|
1022
|
+
#### 方式1:使用配置文件(推荐)
|
|
1023
|
+
|
|
1024
|
+
编辑配置文件 `~/.szcd-mcp-config.json`:
|
|
1025
|
+
|
|
1026
|
+
```json
|
|
1027
|
+
{
|
|
1028
|
+
"MCP_SERVER_URL": "http://localhost:3456",
|
|
1029
|
+
"MCP_TIMEOUT": 30000,
|
|
1030
|
+
"MCP_API_KEY": ""
|
|
1031
|
+
}
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
#### 方式2:使用环境变量
|
|
1035
|
+
|
|
1036
|
+
```bash
|
|
1037
|
+
# Linux/macOS
|
|
1038
|
+
export MCP_SERVER_URL="http://localhost:3456"
|
|
1039
|
+
export MCP_TIMEOUT="30000"
|
|
1040
|
+
export MCP_API_KEY="your-api-key"
|
|
1041
|
+
|
|
1042
|
+
# Windows (PowerShell)
|
|
1043
|
+
$env:MCP_SERVER_URL="http://localhost:3456"
|
|
1044
|
+
$env:MCP_TIMEOUT="30000"
|
|
1045
|
+
$env:MCP_API_KEY="your-api-key"
|
|
1046
|
+
|
|
1047
|
+
# Windows (CMD)
|
|
1048
|
+
set MCP_SERVER_URL=http://localhost:3456
|
|
1049
|
+
set MCP_TIMEOUT=30000
|
|
1050
|
+
set MCP_API_KEY=your-api-key
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
#### 方式3:在 IDE 配置中设置
|
|
1054
|
+
|
|
1055
|
+
**方式3a:使用代理桥接(向后兼容)**
|
|
1056
|
+
|
|
1057
|
+
编辑您的 IDE 配置文件(如 `.trae/config.json` 或 Claude Code 配置):
|
|
1058
|
+
|
|
1059
|
+
```json
|
|
1060
|
+
{
|
|
1061
|
+
"mcpServers": {
|
|
1062
|
+
"szcd-component-helper": {
|
|
1063
|
+
"command": "npx",
|
|
1064
|
+
"args": ["szcd-mcp-proxy"],
|
|
1065
|
+
"env": {
|
|
1066
|
+
"MCP_SERVER_URL": "http://localhost:3456",
|
|
1067
|
+
"MCP_TIMEOUT": "30000",
|
|
1068
|
+
"MCP_API_KEY": ""
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
**方式3b:Trae CLI Streamable HTTP 直连(推荐)**
|
|
1076
|
+
|
|
1077
|
+
在 `~/.trae/trae_cli.yaml` 中配置:
|
|
1078
|
+
|
|
1079
|
+
```yaml
|
|
1080
|
+
mcp_servers:
|
|
1081
|
+
- name: szcd-component-helper
|
|
1082
|
+
url: http://localhost:3456/mcp
|
|
1083
|
+
type: http
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
**方式3c:本地直连 stdio(推荐,无需远程服务器)**
|
|
1087
|
+
|
|
1088
|
+
```json
|
|
1089
|
+
{
|
|
1090
|
+
"mcpServers": {
|
|
1091
|
+
"szcd-component-helper": {
|
|
1092
|
+
"command": "npx",
|
|
1093
|
+
"args": ["szcd-mcp-server", "--stdio"]
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
```
|
|
1098
|
+
|
|
1099
|
+
**方式3d:Qwen Code Streamable HTTP 直连(推荐)**
|
|
1100
|
+
|
|
1101
|
+
在 `~/.qwen/settings.json` 中配置:
|
|
1102
|
+
|
|
1103
|
+
```json
|
|
1104
|
+
{
|
|
1105
|
+
"mcpServers": {
|
|
1106
|
+
"szcd-component-helper": {
|
|
1107
|
+
"httpUrl": "http://localhost:3456/mcp",
|
|
1108
|
+
"timeout": 30000
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
```
|
|
1113
|
+
|
|
1114
|
+
**方式3e:Qwen Code 本地直连 stdio(推荐,无需远程服务器)**
|
|
1115
|
+
|
|
1116
|
+
```json
|
|
1117
|
+
{
|
|
1118
|
+
"mcpServers": {
|
|
1119
|
+
"szcd-component-helper": {
|
|
1120
|
+
"command": "npx",
|
|
1121
|
+
"args": ["szcd-mcp-server", "--stdio"]
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
```
|
|
1126
|
+
|
|
1127
|
+
### 步骤3:验证配置
|
|
1128
|
+
|
|
1129
|
+
运行以下命令验证配置是否正确:
|
|
1130
|
+
|
|
1131
|
+
```bash
|
|
1132
|
+
# 测试服务器连接
|
|
1133
|
+
curl http://localhost:3456/health
|
|
1134
|
+
|
|
1135
|
+
# 或使用代理脚本测试
|
|
1136
|
+
npx szcd-mcp-proxy --test
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
## 配置优先级
|
|
1140
|
+
|
|
1141
|
+
地址获取的优先级顺序:
|
|
1142
|
+
|
|
1143
|
+
1. **环境变量**(最高优先级)
|
|
1144
|
+
- `MCP_SERVER_URL`
|
|
1145
|
+
- `MCP_TIMEOUT`
|
|
1146
|
+
- `MCP_API_KEY`
|
|
1147
|
+
|
|
1148
|
+
2. **配置文件**(中等优先级)
|
|
1149
|
+
- `~/.szcd-mcp-config.json`
|
|
1150
|
+
|
|
1151
|
+
3. **默认值**(最低优先级)
|
|
1152
|
+
- `MCP_SERVER_URL`: `http://localhost:3456`
|
|
1153
|
+
- `MCP_TIMEOUT`: `30000`
|
|
1154
|
+
- `MCP_API_KEY`: ``
|
|
1155
|
+
|
|
1156
|
+
## 环境变量说明
|
|
1157
|
+
|
|
1158
|
+
### MCP 连接配置
|
|
1159
|
+
|
|
1160
|
+
| 变量 | 说明 | 默认值 | 示例 |
|
|
1161
|
+
|------|------|--------|------|
|
|
1162
|
+
| `MCP_SERVER_URL` | MCP 服务器地址 | `http://localhost:3456` | `http://192.168.1.100:3456` |
|
|
1163
|
+
| `MCP_TIMEOUT` | 请求超时时间(毫秒) | `30000` | `60000` |
|
|
1164
|
+
| `MCP_API_KEY` | MCP API 密钥(可选) | `` | `your-secret-key` |
|
|
1165
|
+
|
|
1166
|
+
### 视觉模型配置(设计稿分析功能必需)
|
|
1167
|
+
|
|
1168
|
+
| 变量 | 说明 | 默认值 | 示例 |
|
|
1169
|
+
|------|------|--------|------|
|
|
1170
|
+
| `VISION_API_KEY` | 视觉模型 API 密钥 | 读取 `ANTHROPIC_API_KEY` 或 `OPENAI_API_KEY` | `sk-ant-...` |
|
|
1171
|
+
| `ANTHROPIC_API_KEY` | Claude API 密钥(当使用 Anthropic 时) | `` | `sk-ant-...` |
|
|
1172
|
+
| `OPENAI_API_KEY` | OpenAI API 密钥(当使用 OpenAI 时) | `` | `sk-...` |
|
|
1173
|
+
| `VISION_PROVIDER` | 视觉模型提供商 | `anthropic` | `anthropic` / `openai` |
|
|
1174
|
+
| `VISION_MODEL` | 视觉模型名称 | `claude-sonnet-4-6` | `gpt-4o` |
|
|
1175
|
+
| `VISION_API_URL` | 自定义视觉模型 API 地址 | 官方地址 | `https://api.anthropic.com/v1/messages` |
|
|
1176
|
+
| `DESIGN_ANALYSIS_ORDER` | 分析优先级:`vision_first` / `ocr_first` / `vision_only` / `ocr_only` | `vision_first` | `ocr_first` |
|
|
1177
|
+
| `OCR_SCRIPT_PATH` | 本地 OCR 脚本路径(降级用) | `/usr/local/bin/ocr-image` | `/usr/local/bin/ocr-image` |
|
|
1178
|
+
|
|
1179
|
+
### 分析优先级说明
|
|
1180
|
+
|
|
1181
|
+
| 值 | 行为 |
|
|
1182
|
+
|------|------|
|
|
1183
|
+
| `vision_first`(默认) | 先调用多模态模型,失败后降级到本地 OCR |
|
|
1184
|
+
| `ocr_first` | 先调用本地 OCR,识别不到文字再尝试多模态模型 |
|
|
1185
|
+
| `vision_only` | 只用多模态模型,失败直接报错 |
|
|
1186
|
+
| `ocr_only` | 只用本地 OCR,不调用多模态模型,返回原始文字 |
|
|
1187
|
+
|
|
1188
|
+
## 使用流程
|
|
1189
|
+
|
|
1190
|
+
1. **确定用户需求**:了解用户想要查询的组件信息或文件
|
|
1191
|
+
2. **Claude Code自动选择合适的MCP工具**:Claude Code会根据需求自动识别并调用对应的MCP工具
|
|
1192
|
+
3. **Claude Code自动连接MCP服务器**:Claude Code通过MCP协议连接到运行在MCP_SERVER_URL的服务器
|
|
1193
|
+
4. **MCP服务器执行查询**:服务器接收工具调用请求,执行相应的业务逻辑
|
|
1194
|
+
5. **返回结构化结果**:服务器返回JSON格式的结果,AI助手处理并呈现给用户
|
|
1195
|
+
|
|
1196
|
+
## 注意事项
|
|
1197
|
+
|
|
1198
|
+
- 所有路径都是相对于项目根目录的相对路径
|
|
1199
|
+
- 搜索示例时,结果可能会有重复或不相关的内容,需要用户自行筛选
|
|
1200
|
+
- 读取文件时,大文件可能会被截断,用户可以通过设置 maxChars 参数来调整
|
|
1201
|
+
- **需要确保 MCP 服务器正在运行,否则无法查询数据**
|
|
1202
|
+
- **服务器地址从环境变量或配置文件动态获取,无需硬编码**
|
|
1203
|
+
- **Claude Code会自动处理MCP协议通信,用户无需手动调用API**
|
|
1204
|
+
- **Qwen Code会自动处理MCP协议通信,用户无需手动调用API**
|
|
1205
|
+
- **设计稿分析功能需要配置视觉模型 API Key**,未配置时 analyze_design_image 工具会返回错误
|
|
1206
|
+
- **设计稿分析会调用外部多模态模型 API**,会产生额外费用(单张约 $0.03~0.05)
|
|
1207
|
+
- **设计稿分析结果会自动缓存 24 小时**,同一图片重复查询不会重复计费
|
|
1208
|
+
|
|
1209
|
+
## 故障排除
|
|
1210
|
+
|
|
1211
|
+
### 连接失败
|
|
1212
|
+
|
|
1213
|
+
1. 检查服务器是否运行:`curl ${MCP_SERVER_URL}/health`
|
|
1214
|
+
2. 检查防火墙设置
|
|
1215
|
+
3. 检查网络连接
|
|
1216
|
+
4. 确认 `MCP_SERVER_URL` 配置正确
|
|
1217
|
+
5. 检查环境变量是否正确设置
|
|
1218
|
+
6. 检查配置文件 `~/.szcd-mcp-config.json` 是否存在
|
|
1219
|
+
|
|
1220
|
+
### 配置文件问题
|
|
1221
|
+
|
|
1222
|
+
1. 检查配置文件路径:`~/.szcd-mcp-config.json`
|
|
1223
|
+
2. 检查 JSON 格式是否正确
|
|
1224
|
+
3. 检查文件权限
|
|
1225
|
+
|
|
1226
|
+
## 示例对话
|
|
1227
|
+
|
|
1228
|
+
### 示例 1:获取组件库概览
|
|
1229
|
+
|
|
1230
|
+
**用户**:szcd 组件库有哪些组件?
|
|
1231
|
+
**助手**:让我为您查询 szcd 组件库的完整概览。
|
|
1232
|
+
|
|
1233
|
+
[助手自动触发MCP工具调用:get_component_library_overview()]
|
|
1234
|
+
|
|
1235
|
+
**助手**:以下是 szcd 组件库的概览:
|
|
1236
|
+
- Cover 层封装组件:36 个 (路径: src/components/cover)
|
|
1237
|
+
- Wrapper 层业务组件:7 个 (路径: src/components/wrappers)
|
|
1238
|
+
- ProPackages 封装:8 个 (路径: pro-packages)
|
|
1239
|
+
- 复合业务组件:21 个 (路径: src/other/components)
|
|
1240
|
+
- Ant Design 官方组件:0 个 (需刷新缓存获取)
|
|
1241
|
+
- ProComponents 高级组件:0 个 (需刷新缓存获取)
|
|
1242
|
+
|
|
1243
|
+
### 示例 2:搜索组件
|
|
1244
|
+
|
|
1245
|
+
**用户**:搜索包含 "table" 的组件
|
|
1246
|
+
**助手**:让我在整个组件库中搜索包含 "table" 的组件。
|
|
1247
|
+
|
|
1248
|
+
[助手自动触发MCP工具调用:search_all_components({"keyword": "table"})]
|
|
1249
|
+
|
|
1250
|
+
**助手**:搜索到以下包含 "table" 的组件:
|
|
1251
|
+
- TableOrList(复合组件)
|
|
1252
|
+
- ProTable(ProComponents)
|
|
1253
|
+
- Table(Ant Design)
|
|
1254
|
+
|
|
1255
|
+
### 示例 3:列出 Cover 层组件
|
|
1256
|
+
|
|
1257
|
+
**用户**:Cover 层有哪些组件?
|
|
1258
|
+
**助手**:让我查询 Cover 层的组件列表。
|
|
1259
|
+
|
|
1260
|
+
[助手自动触发MCP工具调用:list_cover_components()]
|
|
1261
|
+
|
|
1262
|
+
**助手**:Cover 层有以下组件:
|
|
1263
|
+
- Button
|
|
1264
|
+
- Input
|
|
1265
|
+
- Select
|
|
1266
|
+
- DatePicker
|
|
1267
|
+
...
|
|
1268
|
+
|
|
1269
|
+
### 示例 4:获取 Ant Design 组件信息
|
|
1270
|
+
|
|
1271
|
+
**用户**:Ant Design 的 Table 组件有哪些 Props?
|
|
1272
|
+
**助手**:让我查询 Ant Design Table 组件的详细信息。
|
|
1273
|
+
|
|
1274
|
+
[助手自动触发MCP工具调用:get_antd_component({"name": "Table"})]
|
|
1275
|
+
|
|
1276
|
+
**助手**:Ant Design Table 组件的详细信息如下:
|
|
1277
|
+
- 中文名:表格
|
|
1278
|
+
- 描述:展示行列数据
|
|
1279
|
+
- 主要 Props:dataSource、columns、pagination、loading...
|
|
1280
|
+
|
|
1281
|
+
### 示例 5:列出复合组件
|
|
1282
|
+
|
|
1283
|
+
**用户**:列出项目中的复合组件
|
|
1284
|
+
**助手**:让我使用 list_other_components 工具来查询项目中的复合组件。
|
|
1285
|
+
|
|
1286
|
+
[助手自动触发MCP工具调用:list_other_components()]
|
|
1287
|
+
|
|
1288
|
+
**助手**:以下是 szcd 项目中的复合组件列表:
|
|
1289
|
+
- Query
|
|
1290
|
+
- TableOrList
|
|
1291
|
+
- TitleAndBack
|
|
1292
|
+
- LeftTree
|
|
1293
|
+
|
|
1294
|
+
这些组件都在 src/other/components/index.js 中导出。
|
|
1295
|
+
|
|
1296
|
+
### 示例 6:获取组件详情
|
|
1297
|
+
|
|
1298
|
+
**用户**:获取 Query 组件的详情
|
|
1299
|
+
**助手**:让我使用 get_other_component 工具来获取 Query 组件的详细信息。
|
|
1300
|
+
|
|
1301
|
+
[助手自动触发MCP工具调用:get_other_component({"name": "Query"})]
|
|
1302
|
+
|
|
1303
|
+
**助手**:Query 组件的详细信息如下:
|
|
1304
|
+
- 实现文件:src/other/components/Query/index.tsx
|
|
1305
|
+
- 文档文件:src/other/components/Query/Query.md
|
|
1306
|
+
- 导出位置:src/other/components/index.js
|
|
1307
|
+
|
|
1308
|
+
### 示例 7:搜索组件示例
|
|
1309
|
+
|
|
1310
|
+
**用户**:搜索 TableOrList 组件的使用示例
|
|
1311
|
+
**助手**:让我使用 search_component_examples 工具来搜索 TableOrList 组件的使用示例。
|
|
1312
|
+
|
|
1313
|
+
[助手自动触发MCP工具调用:search_component_examples({"name": "TableOrList", "maxResults": 10})]
|
|
1314
|
+
|
|
1315
|
+
**助手**:以下是 TableOrList 组件的使用示例:
|
|
1316
|
+
1. 文件:src/anyMd/TableOrList.json - 包含组件配置信息
|
|
1317
|
+
2. 文件:src/anyMd/TableOrList.txt - 包含组件描述信息
|
|
1318
|
+
|
|
1319
|
+
### 示例 8:读取文件内容
|
|
1320
|
+
|
|
1321
|
+
**用户**:查看 Query 组件的实现代码
|
|
1322
|
+
**助手**:让我使用 read_file 工具来读取 Query 组件的实现文件。
|
|
1323
|
+
|
|
1324
|
+
[助手自动触发MCP工具调用:read_file({"path": "src/other/components/Query/index.tsx"})]
|
|
1325
|
+
|
|
1326
|
+
**助手**:Query 组件的实现代码如下:
|
|
1327
|
+
```tsx
|
|
1328
|
+
// 这里显示 src/other/components/Query/index.tsx 的内容
|
|
1329
|
+
```
|
|
1330
|
+
|
|
1331
|
+
### 示例 9:分析设计稿图片
|
|
1332
|
+
|
|
1333
|
+
**用户**:我有一张设计稿截图,路径是 `docs/designs/user-list.png`,请帮我分析页面结构并生成 szcd 代码。
|
|
1334
|
+
|
|
1335
|
+
**助手**:让我使用 analyze_design_image 工具来分析这张设计稿。
|
|
1336
|
+
|
|
1337
|
+
[助手自动触发MCP工具调用:analyze_design_image({
|
|
1338
|
+
"imageSource": "docs/designs/user-list.png",
|
|
1339
|
+
"sourceType": "file_path",
|
|
1340
|
+
"analysisType": "full",
|
|
1341
|
+
"pageContext": "用户管理列表页",
|
|
1342
|
+
"targetLibrary": "szcd",
|
|
1343
|
+
"outputFormat": "markdown"
|
|
1344
|
+
})]
|
|
1345
|
+
|
|
1346
|
+
**助手**:设计稿分析结果如下:
|
|
1347
|
+
|
|
1348
|
+
**页面类型**:列表页(带左侧树形导航)
|
|
1349
|
+
|
|
1350
|
+
**布局结构**:
|
|
1351
|
+
- 顶部查询区(Query 组件):用户名 Input、状态 Select、创建时间 RangePicker、查询/重置按钮
|
|
1352
|
+
- 左侧树区(LeftTree 组件):组织机构树
|
|
1353
|
+
- 右侧表格区(TableOrList 组件):用户编号、用户名、角色、状态列,含编辑/删除/查看操作
|
|
1354
|
+
|
|
1355
|
+
**推荐代码结构**:
|
|
1356
|
+
```tsx
|
|
1357
|
+
import { Query, LeftTree, TableOrList } from '@szc-ft/szcd';
|
|
1358
|
+
|
|
1359
|
+
// 使用 mode-packages/table-or-list 模板
|
|
1360
|
+
```
|
|
1361
|
+
|
|
1362
|
+
## AI助手与MCP服务交互详解
|
|
1363
|
+
|
|
1364
|
+
### 调用机制
|
|
1365
|
+
|
|
1366
|
+
AI助手 通过 MCP 协议(Streamable HTTP 或 stdio)连接到 MCP 服务器。AI助手 会根据用户自然语言请求自动识别并调用适当的MCP工具。
|
|
1367
|
+
|
|
1368
|
+
### HTTP头部信息(AI助手连接时必需)
|
|
1369
|
+
|
|
1370
|
+
当AI助手连接到MCP服务器时,会使用以下HTTP头部:
|
|
1371
|
+
|
|
1372
|
+
| 头部字段 | 值 | 说明 |
|
|
1373
|
+
|----------|----|-----|
|
|
1374
|
+
| `Content-Type` | `application/json` | 指定请求体为JSON格式 |
|
|
1375
|
+
| `Accept` | `application/json` | 指定期望响应为JSON格式 |
|
|
1376
|
+
| `Connection` | `keep-alive` | 保持长连接以提高性能 |
|
|
1377
|
+
|
|
1378
|
+
### 调用流程
|
|
1379
|
+
|
|
1380
|
+
当用户提出需求时,AI助手会:
|
|
1381
|
+
|
|
1382
|
+
1. **理解用户意图**:分析用户想要获取的信息类型
|
|
1383
|
+
2. **选择适当工具**:从 MCP 服务器提供的工具中选择最合适的
|
|
1384
|
+
3. **构建参数**:根据用户输入构建工具调用所需的参数
|
|
1385
|
+
4. **发起 MCP 调用**:通过 MCP 协议发送工具调用请求到服务器
|
|
1386
|
+
5. **处理响应**:接收服务器返回的 JSON 格式结果
|
|
1387
|
+
6. **格式化输出**:将结果以易读的方式呈现给用户
|
|
1388
|
+
|
|
1389
|
+
### 对比:MCP 协议底层 vs AI助手 实际调用
|
|
1390
|
+
|
|
1391
|
+
| 维度 | MCP 协议底层调用 | AI助手 实际调用 |
|
|
1392
|
+
|------|-----------------|-------------------|
|
|
1393
|
+
| **调用格式** | `{"jsonrpc":"2.0","method":"tools/call","params":{...}}` | 自然语言触发,AI助手自动转换 |
|
|
1394
|
+
| **传输协议** | JSON-RPC over HTTP/SSE/stdio | 由 AI助手 框架自动处理 |
|
|
1395
|
+
| **参数传递** | 嵌套在 `params.arguments` 中 | 从自然语言解析后构建参数 |
|
|
1396
|
+
| **响应格式** | `{"jsonrpc":"2.0","result":{...}}` | 直接处理并格式化为自然语言响应 |
|
|
1397
|
+
| **触发方式** | 手动构造 HTTP 请求 | 自然语言对话自动触发 |
|
|
1398
|
+
|
|
1399
|
+
### 实际调用示例
|
|
1400
|
+
|
|
1401
|
+
**用户输入**:
|
|
1402
|
+
```
|
|
1403
|
+
szcd 组件库有哪些组件?
|
|
1404
|
+
```
|
|
1405
|
+
|
|
1406
|
+
**AI助手 自动执行**:
|
|
1407
|
+
```json
|
|
1408
|
+
{
|
|
1409
|
+
"jsonrpc": "2.0",
|
|
1410
|
+
"id": 1,
|
|
1411
|
+
"method": "tools/call",
|
|
1412
|
+
"params": {
|
|
1413
|
+
"name": "get_component_library_overview",
|
|
1414
|
+
"arguments": {}
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
```
|
|
1418
|
+
|
|
1419
|
+
**返回结果**(AI助手 接收到的原始 JSON):
|
|
1420
|
+
```json
|
|
1421
|
+
{
|
|
1422
|
+
"summary": {
|
|
1423
|
+
"coverLayer": { "count": 36, "path": "src/components/cover" },
|
|
1424
|
+
"wrapperLayer": { "count": 7, "path": "src/components/wrappers" },
|
|
1425
|
+
"proPackages": { "count": 8, "path": "pro-packages" },
|
|
1426
|
+
"compositeComponents": { "count": 21, "path": "src/other/components" }
|
|
1427
|
+
},
|
|
1428
|
+
"totalCustomComponents": 72
|
|
1429
|
+
}
|
|
1430
|
+
```
|
|
1431
|
+
|
|
1432
|
+
**AI助手 呈现给用户**:
|
|
1433
|
+
```
|
|
1434
|
+
szcd 组件库共有 72 个自定义组件:
|
|
1435
|
+
- Cover 层封装组件:36 个
|
|
1436
|
+
- Wrapper 层业务组件:7 个
|
|
1437
|
+
- ProPackages 封装:8 个
|
|
1438
|
+
- 复合业务组件:21 个
|
|
1439
|
+
```
|
|
1440
|
+
|
|
1441
|
+
## Trae CLI 与 MCP 服务交互详解
|
|
1442
|
+
|
|
1443
|
+
### 调用机制
|
|
1444
|
+
|
|
1445
|
+
Trae CLI 通过 MCP 协议(Streamable HTTP 或 stdio)连接到 MCP 服务器,工具调用格式为:
|
|
1446
|
+
|
|
1447
|
+
```
|
|
1448
|
+
mcp__szcd-component-helper__<tool_name>(<params>)
|
|
1449
|
+
```
|
|
1450
|
+
|
|
1451
|
+
其中:
|
|
1452
|
+
- `szcd-component-helper` 是 MCP 服务器名称(在 `~/.trae/trae_cli.yaml` 中配置)
|
|
1453
|
+
- `<tool_name>` 是工具名称(如 `list_other_components`、`get_other_component` 等)
|
|
1454
|
+
- `<params>` 是 JSON 格式的参数对象
|
|
1455
|
+
|
|
1456
|
+
### 调用流程
|
|
1457
|
+
|
|
1458
|
+
当用户提出需求时,Trae CLI 会:
|
|
1459
|
+
|
|
1460
|
+
1. **理解用户意图**:分析用户想要获取的信息类型
|
|
1461
|
+
2. **选择适当工具**:从 MCP 服务器提供的工具中选择最合适的
|
|
1462
|
+
3. **构建参数**:根据用户输入构建工具调用所需的参数
|
|
1463
|
+
4. **发起 MCP 调用**:通过 MCP 协议发送工具调用请求到服务器
|
|
1464
|
+
5. **处理响应**:接收服务器返回的 JSON 格式结果
|
|
1465
|
+
6. **格式化输出**:将结果以易读的方式呈现给用户
|
|
1466
|
+
|
|
1467
|
+
### 对比:MCP 协议底层 vs Trae CLI 实际调用
|
|
1468
|
+
|
|
1469
|
+
| 维度 | MCP 协议底层调用 | Trae CLI 实际调用 |
|
|
1470
|
+
|------|-----------------|-------------------|
|
|
1471
|
+
| **调用格式** | `{"jsonrpc":"2.0","method":"tools/call","params":{...}}` | `mcp__szcd-component-helper__<tool>(params)` |
|
|
1472
|
+
| **传输协议** | JSON-RPC over HTTP/SSE/stdio | 由 Trae CLI 框架自动处理 |
|
|
1473
|
+
| **参数传递** | 嵌套在 `params.arguments` 中 | 直接作为函数参数传入 |
|
|
1474
|
+
| **响应格式** | `{"jsonrpc":"2.0","result":{...}}` | 直接返回 result 内容 |
|
|
1475
|
+
| **触发方式** | 手动构造 HTTP 请求 | 自然语言对话自动触发 |
|
|
1476
|
+
|
|
1477
|
+
### 实际调用示例
|
|
1478
|
+
|
|
1479
|
+
**用户输入**:
|
|
1480
|
+
```
|
|
1481
|
+
szcd 组件库有哪些组件?
|
|
1482
|
+
```
|
|
1483
|
+
|
|
1484
|
+
**Trae CLI 自动执行**:
|
|
1485
|
+
```
|
|
1486
|
+
mcp__szcd-component-helper__get_component_library_overview()
|
|
1487
|
+
```
|
|
1488
|
+
|
|
1489
|
+
**返回结果**(Trae CLI 接收到的原始 JSON):
|
|
1490
|
+
```json
|
|
1491
|
+
{
|
|
1492
|
+
"summary": {
|
|
1493
|
+
"coverLayer": { "count": 36, "path": "src/components/cover" },
|
|
1494
|
+
"wrapperLayer": { "count": 7, "path": "src/components/wrappers" },
|
|
1495
|
+
"proPackages": { "count": 8, "path": "pro-packages" },
|
|
1496
|
+
"compositeComponents": { "count": 21, "path": "src/other/components" }
|
|
1497
|
+
},
|
|
1498
|
+
"totalCustomComponents": 72
|
|
1499
|
+
}
|
|
1500
|
+
```
|
|
1501
|
+
|
|
1502
|
+
**Trae CLI 呈现给用户**:
|
|
1503
|
+
```
|
|
1504
|
+
szcd 组件库共有 72 个自定义组件:
|
|
1505
|
+
- Cover 层封装组件:36 个
|
|
1506
|
+
- Wrapper 层业务组件:7 个
|
|
1507
|
+
- ProPackages 封装:8 个
|
|
1508
|
+
- 复合业务组件:21 个
|
|
1509
|
+
```
|