{"record":{"id":"c5466243a6d942e9","repo":"micro/go-micro","slug":"name-is-required","errorCode":null,"errorMessage":"name is required","messagePattern":"name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gateway/mcp/mcp.go","lineNumber":460,"sourceCode":"\t\t\t\tnames = append(names, svc.Name)\n\t\t\t}\n\t\t\treturn map[string]interface{}{\"services\": names}, nil\n\t\t},\n\t})\n\n\taddFramework(&Tool{\n\t\tName:        \"micro_registry_get\",\n\t\tDescription: \"Get details for a registered service including nodes and endpoints\",\n\t\tInputSchema: map[string]interface{}{\n\t\t\t\"type\": \"object\",\n\t\t\t\"properties\": map[string]interface{}{\n\t\t\t\t\"name\": map[string]interface{}{\"type\": \"string\", \"description\": \"Service name\"},\n\t\t\t},\n\t\t},\n\t\tHandler: func(input map[string]interface{}) (interface{}, error) {\n\t\t\tname, _ := input[\"name\"].(string)\n\t\t\tif name == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"name is required\")\n\t\t\t}\n\t\t\tservices, err := s.opts.Registry.GetService(name)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\treturn services, nil\n\t\t},\n\t})\n\n\taddFramework(&Tool{\n\t\tName:        \"micro_store_list\",\n\t\tDescription: \"List keys in the data store\",\n\t\tInputSchema: map[string]interface{}{\"type\": \"object\", \"properties\": map[string]interface{}{}},\n\t\tHandler: func(input map[string]interface{}) (interface{}, error) {\n\t\t\tkeys, err := store.List()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/gateway/mcp/mcp.go#L442-L478","documentation":"The built-in \"get_service\" MCP tool handler requires the caller to supply the \"name\" input parameter identifying which registered service to look up. When the parameter is absent or an empty string, the handler returns \"name is required\" as the tool error.","triggerScenarios":"An MCP client calls the get_service tool with input {} or input {\"name\": \"\"} — the empty name fails the guard before Registry.GetService is invoked.","commonSituations":"An LLM omits the required argument in its tool call; a hand-written JSON-RPC client forgets the params.name field; schema/tools listing was cached and the client sends outdated arguments.","solutions":["Include a non-empty \"name\" string in the tool input: {\"name\": \"myservice\"}.","Check the service name against what the registry reports (ListServices) — names are case-sensitive.","On the client side, validate required params before sending the tools/call request."],"exampleFix":"// before\n{\"method\": \"tools/call\", \"params\": {\"name\": \"get_service\", \"arguments\": {}}}\n// after\n{\"method\": \"tools/call\", \"params\": {\"name\": \"get_service\", \"arguments\": {\"name\": \"myservice\"}}}","handlingStrategy":"validation","validationCode":"name, _ := input[\"name\"].(string)\nif name == \"\" {\n    return errors.New(\"get_service requires a non-empty 'name' argument\")\n}","typeGuard":"func validName(input map[string]interface{}) (string, bool) {\n    n, ok := input[\"name\"].(string)\n    return n, ok && n != \"\"\n}","tryCatchPattern":"result, err := callTool(\"get_service\", map[string]interface{}{\"name\": svc})\nif err != nil {\n    if strings.Contains(err.Error(), \"name is required\") {\n        // fix arguments and retry once\n    }\n}","preventionTips":["Read the tool's inputSchema before calling and supply every required property.","Treat tool error strings as contract violations and fix the caller, not the server.","When driving tools with an LLM, constrain argument generation to the declared schema."],"tags":["mcp","validation","tool-parameters"],"backgroundTag":"missing-required-argument","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}