Skip to content

Commit 211adfc

Browse files
longzhang83claude
andcommitted
refactor: 优化MCP工具描述和代码结构
- 简化MCP工具描述,移除冗余说明 - 为字典生成工具添加Name/Description/InputSchema方法 - 优化gva_analyze目录清理逻辑 - 重构gva_execute执行计划处理逻辑 - 更新pathInfo.json添加新页面路径 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b71cc44 commit 211adfc

File tree

8 files changed

+177
-171
lines changed

8 files changed

+177
-171
lines changed

server/mcp/api_lister.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,9 @@ type ApiLister struct{}
4242
// New 创建API列表工具
4343
func (a *ApiLister) New() mcp.Tool {
4444
return mcp.NewTool("list_all_apis",
45-
mcp.WithDescription(`获取系统中所有的API接口,分为两组:
45+
mcp.WithDescription(`获取系统所有API接口。返回databaseApis(数据库API)和ginApis(gin路由)两组数据。
4646
47-
**功能说明:**
48-
- 返回数据库中已注册的API列表
49-
- 返回gin框架中实际注册的路由API列表
50-
- 帮助前端判断是使用现有API还是需要创建新的API,如果api在前端未使用且需要前端调用的时候,请到api文件夹下对应模块的js中添加方法并暴露给当前业务调用
51-
52-
**返回数据结构:**
53-
- databaseApis: 数据库中的API记录(包含ID、描述、分组等完整信息)
54-
- ginApis: gin路由中的API(仅包含路径和方法),需要AI根据路径自行揣摩路径的业务含义,例如:/api/user/:id 表示根据用户ID获取用户信息`),
47+
**详细说明**: /gva-helper/lister`),
5548
mcp.WithString("_placeholder",
5649
mcp.Description("占位符,防止json schema校验失败"),
5750
),

server/mcp/dictionary_generator.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,93 @@ func (d *DictionaryOptionsGenerator) New() mcp.Tool {
7070
)
7171
}
7272

73+
// Name 返回工具名称
74+
func (d *DictionaryOptionsGenerator) Name() string {
75+
return "generate_dictionary_options"
76+
}
77+
78+
// Description 返回工具描述
79+
func (d *DictionaryOptionsGenerator) Description() string {
80+
return `字典选项生成工具 - 让AI生成并创建字典选项
81+
82+
此工具允许AI根据字典类型和字段描述生成合适的字典选项,并自动创建字典和字典详情。
83+
84+
参数说明:
85+
- dictType: 字典类型(必填)
86+
- fieldDesc: 字段描述(必填)
87+
- options: AI生成的字典选项数组(必填)
88+
- label: 选项标签
89+
- value: 选项值
90+
- sort: 排序号
91+
- dictName: 字典名称(可选,默认根据fieldDesc生成)
92+
- description: 字典描述(可选)
93+
94+
使用场景:
95+
1. 在创建模块时,如果字段需要字典类型,AI可以根据字段描述智能生成合适的选项
96+
2. 支持各种业务场景的字典选项生成,如状态、类型、等级等
97+
3. 自动创建字典和字典详情,无需手动配置
98+
99+
示例调用:
100+
{
101+
"dictType": "user_status",
102+
"fieldDesc": "用户状态",
103+
"options": [
104+
{"label": "正常", "value": "1", "sort": 1},
105+
{"label": "禁用", "value": "0", "sort": 2}
106+
],
107+
"dictName": "用户状态字典",
108+
"description": "用于管理用户账户状态的字典"
109+
}`
110+
}
111+
112+
// InputSchema 返回输入参数的JSON Schema
113+
func (d *DictionaryOptionsGenerator) InputSchema() map[string]interface{} {
114+
return map[string]interface{}{
115+
"type": "object",
116+
"properties": map[string]interface{}{
117+
"dictType": map[string]interface{}{
118+
"type": "string",
119+
"description": "字典类型,用于标识字典的唯一性",
120+
},
121+
"fieldDesc": map[string]interface{}{
122+
"type": "string",
123+
"description": "字段描述,用于生成字典名称和理解字典用途",
124+
},
125+
"options": map[string]interface{}{
126+
"type": "array",
127+
"description": "AI生成的字典选项数组",
128+
"items": map[string]interface{}{
129+
"type": "object",
130+
"properties": map[string]interface{}{
131+
"label": map[string]interface{}{
132+
"type": "string",
133+
"description": "选项标签,显示给用户的文本",
134+
},
135+
"value": map[string]interface{}{
136+
"type": "string",
137+
"description": "选项值,存储在数据库中的值",
138+
},
139+
"sort": map[string]interface{}{
140+
"type": "integer",
141+
"description": "排序号,用于控制选项显示顺序",
142+
},
143+
},
144+
"required": []string{"label", "value", "sort"},
145+
},
146+
},
147+
"dictName": map[string]interface{}{
148+
"type": "string",
149+
"description": "字典名称,必填,默认根据fieldDesc生成",
150+
},
151+
"description": map[string]interface{}{
152+
"type": "string",
153+
"description": "字典描述,必填",
154+
},
155+
},
156+
"required": []string{"dictType", "fieldDesc", "options"},
157+
}
158+
}
159+
73160
// Handle 处理工具调用
74161
func (d *DictionaryOptionsGenerator) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
75162
// 解析请求参数

server/mcp/gva_analyze.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,7 @@ func (g *GVAAnalyzer) removeDirectoryIfExists(dirPath string) error {
349349
return err // 其他错误
350350
}
351351

352-
// 检查目录中是否包含go文件
353-
noGoFiles, err := g.hasGoFilesRecursive(dirPath)
354-
if err != nil {
355-
return err
356-
}
357-
// hasGoFilesRecursive 返回 false 表示发现了 go 文件
358-
if noGoFiles {
359-
return os.RemoveAll(dirPath)
360-
}
361-
return nil
352+
return os.RemoveAll(dirPath)
362353
}
363354

364355
// cleanupRelatedApiAndMenus 清理相关的API和菜单记录

server/mcp/gva_execute.go

Lines changed: 74 additions & 78 deletions
Large diffs are not rendered by default.

server/mcp/gva_review.go

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,9 @@ type ReviewResponse struct {
3535
// New 创建GVA代码审查工具
3636
func (g *GVAReviewer) New() mcp.Tool {
3737
return mcp.NewTool("gva_review",
38-
mcp.WithDescription(`**GVA代码审查工具 - 在gva_execute调用后使用**
39-
40-
**核心功能:**
41-
- 接收经过requirement_analyze处理的用户需求和gva_execute生成的文件列表
42-
- 分析生成的代码是否满足用户的原始需求
43-
- 检查是否涉及到关联、交互等复杂功能
44-
- 如果代码不满足需求,提供调整建议和新的prompt
45-
46-
**使用场景:**
47-
- 在gva_execute成功执行后调用
48-
- 用于验证生成的代码是否完整满足用户需求
49-
- 检查模块间的关联关系是否正确实现
50-
- 发现缺失的交互功能或业务逻辑
51-
52-
**工作流程:**
53-
1. 接收用户原始需求和生成的文件列表
54-
2. 分析需求中的关键功能点
55-
3. 检查生成的文件是否覆盖所有功能
56-
4. 识别缺失的关联关系、交互功能等
57-
5. 生成调整建议和新的开发prompt
58-
59-
**输出内容:**
60-
- 审查结果和是否需要调整
61-
- 详细的缺失功能分析
62-
- 针对性的代码调整建议
63-
- 可直接使用的开发prompt
64-
65-
**重要提示:**
66-
- 本工具专门用于代码质量审查,不执行实际的代码修改
67-
- 重点关注模块间关联、用户交互、业务流程完整性
68-
- 提供的调整建议应该具体可执行`),
38+
mcp.WithDescription(`代码审查工具,在gva_execute后验证生成代码是否满足需求。检查关联关系、交互功能,提供调整建议。
39+
40+
**详细说明**: /gva-helper/gva-review`),
6941
mcp.WithString("userRequirement",
7042
mcp.Description("经过requirement_analyze处理后的用户需求描述,包含详细的功能要求和字段信息"),
7143
mcp.Required(),

server/mcp/menu_lister.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,9 @@ type MenuLister struct{}
3232
// New 创建菜单列表工具
3333
func (m *MenuLister) New() mcp.Tool {
3434
return mcp.NewTool("list_all_menus",
35-
mcp.WithDescription(`获取系统中所有菜单信息,包括菜单树结构、路由信息、组件路径等,用于前端编写vue-router时正确跳转
35+
mcp.WithDescription(`获取系统所有菜单信息,包括菜单树结构、路由信息、组件路径,用于前端vue-router跳转。
3636
37-
**功能说明:**
38-
- 返回完整的菜单树形结构
39-
- 包含路由配置信息(path、name、component)
40-
- 包含菜单元数据(title、icon、keepAlive等)
41-
- 包含菜单参数和按钮配置
42-
- 支持父子菜单关系展示
43-
44-
**使用场景:**
45-
- 前端路由配置:获取所有菜单信息用于配置vue-router
46-
- 菜单权限管理:了解系统中所有可用的菜单项
47-
- 导航组件开发:构建动态导航菜单
48-
- 系统架构分析:了解系统的菜单结构和页面组织`),
37+
**详细说明**: /gva-helper/lister`),
4938
mcp.WithString("_placeholder",
5039
mcp.Description("占位符,防止json schema校验失败"),
5140
),

server/mcp/requirement_analyzer.go

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,11 @@ type RequirementAnalysisResponse struct {
2828
// New 返回工具注册信息
2929
func (t *RequirementAnalyzer) New() mcp.Tool {
3030
return mcp.NewTool("requirement_analyzer",
31-
mcp.WithDescription(`** 智能需求分析与模块设计工具 - 首选入口工具(最高优先级)**
32-
33-
** 重要提示:这是所有MCP工具的首选入口,请优先使用!**
34-
35-
** 核心能力:**
36-
作为资深系统架构师,智能分析用户需求并自动设计完整的模块架构
37-
38-
** 核心功能:**
39-
1. **智能需求解构**:深度分析用户需求,识别核心业务实体、业务流程、数据关系
40-
2. **自动模块设计**:基于需求分析,智能确定需要多少个模块及各模块功能
41-
3. **字段智能推导**:为每个模块自动设计详细字段,包含数据类型、关联关系、字典需求
42-
4. **架构优化建议**:提供模块拆分、关联设计、扩展性等专业建议
43-
44-
** 输出内容:**
45-
- 模块数量和架构设计
46-
- 每个模块的详细字段清单
47-
- 数据类型和关联关系设计
48-
- 字典需求和类型定义
49-
- 模块间关系图和扩展建议
50-
51-
** 适用场景:**
52-
- 用户需求描述不完整,需要智能补全
53-
- 复杂业务系统的模块架构设计
54-
- 需要专业的数据库设计建议
55-
- 想要快速搭建生产级业务系统
56-
57-
** 推荐工作流:**
58-
requirement_analyzer → gva_analyze → gva_execute → 其他辅助工具
59-
60-
`),
31+
mcp.WithDescription(`智能需求分析器,作为GVA工具链首选入口。分析用户需求,设计模块架构和字段。
32+
33+
**调用流程**: requirement_analyzer → gva_analyze → gva_execute
34+
35+
**详细说明**: /gva-helper/requirement-analyzer`),
6136
mcp.WithString("userRequirement",
6237
mcp.Required(),
6338
mcp.Description("用户的需求描述,支持自然语言,如:'我要做一个猫舍管理系统,用来录入猫的信息,并且记录每只猫每天的活动信息'"),

web/src/pathInfo.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"/src/view/superAdmin/params/sysParams.vue": "SysParams",
6161
"/src/view/superAdmin/user/user.vue": "User",
6262
"/src/view/system/state.vue": "State",
63+
"/src/view/systemTools/apiToken/index.vue": "Index",
6364
"/src/view/systemTools/autoCode/component/fieldDialog.vue": "FieldDialog",
6465
"/src/view/systemTools/autoCode/component/previewCodeDialog.vue": "PreviewCodeDialog",
6566
"/src/view/systemTools/autoCode/index.vue": "AutoCode",
@@ -72,7 +73,9 @@
7273
"/src/view/systemTools/formCreate/index.vue": "FormGenerator",
7374
"/src/view/systemTools/index.vue": "System",
7475
"/src/view/systemTools/installPlugin/index.vue": "Index",
76+
"/src/view/systemTools/loginLog/index.vue": "Index",
7577
"/src/view/systemTools/pubPlug/pubPlug.vue": "PubPlug",
78+
"/src/view/systemTools/skills/index.vue": "Skills",
7679
"/src/view/systemTools/sysError/sysError.vue": "SysError",
7780
"/src/view/systemTools/system/system.vue": "Config",
7881
"/src/view/systemTools/version/version.vue": "SysVersion",

0 commit comments

Comments
 (0)