flipped-aurora/gin-vue-admin · error

name 参数是必需的

Error message

name 参数是必需的

What it means

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.

Source

Thrown at server/mcp/menu_creator.go:123

		mcp.WithString("parameters",
			mcp.Description("路由参数JSON字符串,格式:[{\"type\":\"params\",\"key\":\"id\",\"value\":\"1\"}]"),
		),
		mcp.WithString("menuBtn",
			mcp.Description("菜单按钮JSON字符串,格式:[{\"name\":\"add\",\"desc\":\"新增\"}]"),
		),
	)
}

func (m *MenuCreator) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
	args := request.GetArguments()

	path, ok := args["path"].(string)
	if !ok || path == "" {
		return nil, errors.New("path 参数是必需的")
	}
	name, ok := args["name"].(string)
	if !ok || name == "" {
		return nil, errors.New("name 参数是必需的")
	}
	component, ok := args["component"].(string)
	if !ok || component == "" {
		return nil, errors.New("component 参数是必需的")
	}
	title, ok := args["title"].(string)
	if !ok || title == "" {
		return nil, errors.New("title 参数是必需的")
	}

	// 兼容 MCP 客户端把数字发成字符串的情况(parentId 允许 0=根,故用 parseOptionalUint;
	// 否则字符串 "5" 断言 float64 失败会静默回落 0,把菜单错挂到根)
	parentID := parseOptionalUint(args["parentId"], 0)
	hidden := parseOptionalBool(args["hidden"], false)
	sort := int(parseOptionalUint(args["sort"], 1))
	icon := "menu"
	if value, ok := args["icon"].(string); ok && value != "" {
		icon = value

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Add a non-empty 'name' string (typically PascalCase, e.g. "User") to the tool arguments.
  2. Ensure name is unique among existing routes to avoid Vue Router duplicate-name warnings after creation.
  3. Provide all four required fields together: path, name, component, title.
  4. Validate the arguments map client-side before invoking the tool.

Example fix

// before
{"path": "/system/user", "component": "view/system/user/user.vue", "title": "用户管理"}
// after
{"path": "/system/user", "name": "user", "component": "view/system/user/user.vue", "title": "用户管理"}
Defensive patterns

Strategy: validation

Validate before calling

name, _ := args["name"].(string)
if name == "" {
    return errors.New("provide a non-empty route name, e.g. user")
}

Type guard

func nonEmptyString(v any) bool {
    s, ok := v.(string)
    return ok && s != ""
}

Prevention

When it happens

Trigger: Calling the menu-creation MCP tool with path provided but 'name' absent, non-string, or "".

Common situations: 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.

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/0c8bfa835eff2fd2. Report an issue: GitHub.