@@ -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 处理工具调用
74161func (d * DictionaryOptionsGenerator ) Handle (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
75162 // 解析请求参数
0 commit comments