{"record":{"id":"dfc0315af0385bb0","repo":"apache/answer","slug":"unknown-tool-s","errorCode":null,"errorMessage":"unknown tool: %s","messagePattern":"unknown tool: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/controller/ai_controller.go","lineNumber":776,"sourceCode":"\tlog.Debugf(\"Calling MCP tool: %s with arguments: %v\", toolName, arguments)\n\n\tswitch toolName {\n\tcase \"get_questions\":\n\t\tresult, err = c.mcpController.MCPQuestionsHandler()(ctx, request)\n\tcase \"get_answers_by_question_id\":\n\t\tresult, err = c.mcpController.MCPAnswersHandler()(ctx, request)\n\tcase \"get_comments\":\n\t\tresult, err = c.mcpController.MCPCommentsHandler()(ctx, request)\n\tcase \"get_tags\":\n\t\tresult, err = c.mcpController.MCPTagsHandler()(ctx, request)\n\tcase \"get_tag_detail\":\n\t\tresult, err = c.mcpController.MCPTagDetailsHandler()(ctx, request)\n\tcase \"get_user\":\n\t\tresult, err = c.mcpController.MCPUserDetailsHandler()(ctx, request)\n\tcase \"semantic_search\":\n\t\tresult, err = c.mcpController.MCPSemanticSearchHandler()(ctx, request)\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown tool: %s\", toolName)\n\t}\n\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tdata, _ := json.Marshal(result)\n\tlog.Debugf(\"MCP tool %s called successfully, result: %v\", toolName, string(data))\n\n\tif result != nil && len(result.Content) > 0 {\n\t\tif textContent, ok := result.Content[0].(mcp.TextContent); ok {\n\t\t\treturn textContent.Text, nil\n\t\t}\n\t}\n\n\treturn \"No result found\", nil\n}\n","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/controller/ai_controller.go#L758-L794","documentation":"Fires in callMCPTool's default switch branch when an LLM tool call names a toolName not in the whitelist of supported MCP tools (get_questions, get_answers_by_question_id, get_comments, get_tags, get_tag_detail, get_user, semantic_search). It is a plain guard rejecting the unknown tool name sent by the model.","triggerScenarios":"Thrown at internal/controller/ai_controller.go:776 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the registered tool names: get_questions, get_answers_by_question_id, get_comments, get_tags, get_tag_detail, get_user, etc.","Check the tool name passed by the LLM for typos or hallucinated names; constrain tool choices in the prompt/schema","Verify the LLM client advertises only the tools registered by callMCPTool so the model cannot select unknown names","Add the missing tool case to the switch if a new MCP tool was implemented but not registered here"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}