{"record":{"id":"0c8bfa835eff2fd2","repo":"flipped-aurora/gin-vue-admin","slug":"name","errorCode":null,"errorMessage":"name 参数是必需的","messagePattern":"name 参数是必需的","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mcp/menu_creator.go","lineNumber":123,"sourceCode":"\t\tmcp.WithString(\"parameters\",\n\t\t\tmcp.Description(\"路由参数JSON字符串，格式：[{\\\"type\\\":\\\"params\\\",\\\"key\\\":\\\"id\\\",\\\"value\\\":\\\"1\\\"}]\"),\n\t\t),\n\t\tmcp.WithString(\"menuBtn\",\n\t\t\tmcp.Description(\"菜单按钮JSON字符串，格式：[{\\\"name\\\":\\\"add\\\",\\\"desc\\\":\\\"新增\\\"}]\"),\n\t\t),\n\t)\n}\n\nfunc (m *MenuCreator) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {\n\targs := request.GetArguments()\n\n\tpath, ok := args[\"path\"].(string)\n\tif !ok || path == \"\" {\n\t\treturn nil, errors.New(\"path 参数是必需的\")\n\t}\n\tname, ok := args[\"name\"].(string)\n\tif !ok || name == \"\" {\n\t\treturn nil, errors.New(\"name 参数是必需的\")\n\t}\n\tcomponent, ok := args[\"component\"].(string)\n\tif !ok || component == \"\" {\n\t\treturn nil, errors.New(\"component 参数是必需的\")\n\t}\n\ttitle, ok := args[\"title\"].(string)\n\tif !ok || title == \"\" {\n\t\treturn nil, errors.New(\"title 参数是必需的\")\n\t}\n\n\t// 兼容 MCP 客户端把数字发成字符串的情况(parentId 允许 0=根,故用 parseOptionalUint;\n\t// 否则字符串 \"5\" 断言 float64 失败会静默回落 0,把菜单错挂到根)\n\tparentID := parseOptionalUint(args[\"parentId\"], 0)\n\thidden := parseOptionalBool(args[\"hidden\"], false)\n\tsort := int(parseOptionalUint(args[\"sort\"], 1))\n\ticon := \"menu\"\n\tif value, ok := args[\"icon\"].(string); ok && value != \"\" {\n\t\ticon = value","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/mcp/menu_creator.go#L105-L141","documentation":"MenuCreator.Handle requires a 'name' argument — the route name used by Vue Router for the menu entry. If the key is missing, not a string, or an empty string, this error is returned. It is checked immediately after 'path', so fixing error 37 often reveals this one next.","triggerScenarios":"Calling the menu-creation MCP tool with path provided but 'name' absent, non-string, or \"\".","commonSituations":"Caller assumes name can be derived from path; generated tool calls using inconsistent naming (routeName vs name); LLM omitting the field when the requirement text didn't mention it explicitly.","solutions":["Add a non-empty 'name' string (typically PascalCase, e.g. \"User\") to the tool arguments.","Ensure name is unique among existing routes to avoid Vue Router duplicate-name warnings after creation.","Provide all four required fields together: path, name, component, title.","Validate the arguments map client-side before invoking the tool."],"exampleFix":"// before\n{\"path\": \"/system/user\", \"component\": \"view/system/user/user.vue\", \"title\": \"用户管理\"}\n// after\n{\"path\": \"/system/user\", \"name\": \"user\", \"component\": \"view/system/user/user.vue\", \"title\": \"用户管理\"}","handlingStrategy":"validation","validationCode":"name, _ := args[\"name\"].(string)\nif name == \"\" {\n    return errors.New(\"provide a non-empty route name, e.g. user\")\n}","typeGuard":"func nonEmptyString(v any) bool {\n    s, ok := v.(string)\n    return ok && s != \"\"\n}","tryCatchPattern":null,"preventionTips":["Derive name from the path systematically (e.g. last segment) so it is never omitted.","Keep route names unique to avoid downstream Vue Router conflicts.","Use a shared builder function for menu-tool arguments."],"tags":["mcp","validation","go","missing-argument"],"backgroundTag":"missing-required-parameter","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}