apache/answer · error
unknown tool: %s
Error message
unknown tool: %s
What it means
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.
Source
Thrown at internal/controller/ai_controller.go:776
log.Debugf("Calling MCP tool: %s with arguments: %v", toolName, arguments)
switch toolName {
case "get_questions":
result, err = c.mcpController.MCPQuestionsHandler()(ctx, request)
case "get_answers_by_question_id":
result, err = c.mcpController.MCPAnswersHandler()(ctx, request)
case "get_comments":
result, err = c.mcpController.MCPCommentsHandler()(ctx, request)
case "get_tags":
result, err = c.mcpController.MCPTagsHandler()(ctx, request)
case "get_tag_detail":
result, err = c.mcpController.MCPTagDetailsHandler()(ctx, request)
case "get_user":
result, err = c.mcpController.MCPUserDetailsHandler()(ctx, request)
case "semantic_search":
result, err = c.mcpController.MCPSemanticSearchHandler()(ctx, request)
default:
return "", fmt.Errorf("unknown tool: %s", toolName)
}
if err != nil {
return "", err
}
data, _ := json.Marshal(result)
log.Debugf("MCP tool %s called successfully, result: %v", toolName, string(data))
if result != nil && len(result.Content) > 0 {
if textContent, ok := result.Content[0].(mcp.TextContent); ok {
return textContent.Text, nil
}
}
return "No result found", nil
}
View on GitHub (pinned to 3b9f137061)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/controller/ai_controller.go:776 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/dfc0315af0385bb0.
Report an issue: GitHub.