flipped-aurora/gin-vue-admin · error

path 参数是必需的

Error message

path 参数是必需的

What it means

MenuCreator's Handle requires a 'path' argument (the frontend route path of the menu to create). It asserts args["path"].(string) and additionally rejects the empty string; a missing key, a non-string value, or "" all produce this error before any menu creation happens.

Source

Thrown at server/mcp/menu_creator.go:119

		),
		mcp.WithString("activeName",
			mcp.Description("高亮菜单名称"),
		),
		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)

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Provide a non-empty 'path' string, e.g. {"path": "/system/user"}.
  2. Ensure the route path starts with '/' following Vue Router conventions if that is your project's convention.
  3. Check the tool argument names against the schema: path, name, component, title are all required.
  4. If path is derived programmatically, validate it is non-empty before invoking the tool.

Example fix

// before
{"name": "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

path, _ := args["path"].(string)
if path == "" {
    return errors.New("provide a non-empty route path, e.g. /system/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 without 'path', with path as a non-string, or with path: "".

Common situations: LLM-driven tool call omitting a parameter the model considered optional; argument map built with wrong key casing ('Path'); upstream flow that derives path from another field which was empty.

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/82e737127db5ac0c. Report an issue: GitHub.