flipped-aurora/gin-vue-admin · error
dictType 参数是必需的
Error message
dictType 参数是必需的
What it means
Thrown by DictionaryOptionsGenerator's Handle when the "dictType" argument is missing, empty, or not a string. dictType identifies the dictionary type whose option values will be generated and is required to build the DictionaryGenerateRequest.
Source
Thrown at server/mcp/dictionary_generator.go:71
mcp.WithString("options",
mcp.Required(),
mcp.Description("字典选项JSON字符串,格式:[{\"label\":\"显示名\",\"value\":\"值\",\"sort\":1}]"),
),
mcp.WithString("dictName",
mcp.Description("字典名称,如果不提供将自动生成"),
),
mcp.WithString("description",
mcp.Description("字典描述"),
),
)
}
func (d *DictionaryOptionsGenerator) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
args := request.GetArguments()
dictType, ok := args["dictType"].(string)
if !ok || dictType == "" {
return nil, errors.New("dictType 参数是必需的")
}
fieldDesc, ok := args["fieldDesc"].(string)
if !ok || fieldDesc == "" {
return nil, errors.New("fieldDesc 参数是必需的")
}
optionsStr, ok := args["options"].(string)
if !ok || optionsStr == "" {
return nil, errors.New("options 参数是必需的")
}
var options []DictionaryOption
if err := json.Unmarshal([]byte(optionsStr), &options); err != nil {
return nil, fmt.Errorf("options 参数格式错误: %v", err)
}
if len(options) == 0 {
return nil, errors.New("options 不能为空")
}
View on GitHub (pinned to 3136500ef3)
Solutions
- Pass a non-empty "dictType" string (e.g. "sys_user_status") in the tool arguments.
- Use an existing dictionary type name defined in the system dictionary management.
- Fix the caller that builds the arguments map so dictType is always included.
Example fix
// before
{"arguments": {"fieldDesc": "用户状态", "options": "[]"}}
// after
{"arguments": {"dictType": "sys_user_status", "fieldDesc": "用户状态", "options": "[{\"label\":\"启用\",\"value\":1}]"}} Defensive patterns
Strategy: validation
Validate before calling
const dictType = args["dictType"]
if (typeof dictType !== "string" || dictType === "") {
throw new Error("dictType must be a non-empty string before calling dictionary_generator")
} Type guard
function hasDictType(args) {
return typeof args.dictType === "string" && args.dictType.length > 0
} Try / catch
try {
await callTool("dictionary_generator", { dictType, fieldDesc, options })
} catch (e) {
if (e.message.includes("dictType 参数是必需的")) {
// supply dictType and retry
}
} Prevention
- Reuse existing dictionary type names from system dictionary management.
- Validate dictType is a non-empty string before the call.
- Include dictType in the tool's required-argument schema shown to agents.
When it happens
Trigger: Invoking the dictionary_generator MCP tool without "dictType", with an empty string, or with a non-string value.
Common situations: Agents omitting dictType in generated tool calls; clients assuming the field is optional; empty dictType produced by upstream form/template logic.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/123759c4216b704b.
Report an issue: GitHub.