jeecgboot/JeecgBoot · warning · RuntimeException
未知工具: {toolName}
Error message
未知工具: {toolName} What it means
handleToolsCall() dispatches tools/call by toolName across only 'hello', 'get_time', 'calculate'. Any other toolName throws a RuntimeException that becomes a tool-call error in the MCP response.
Source
Thrown at jeecg-boot/jeecg-boot-module/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/mcp/McpDemoController.java:293
}
case "get_time" -> {
yield "当前时间: " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
case "calculate" -> {
double a = arguments.getDoubleValue("a");
double b = arguments.getDoubleValue("b");
String op = arguments.getString("operator");
if (op == null) op = "+";
double res = switch (op) {
case "+" -> a + b;
case "-" -> a - b;
case "*" -> a * b;
case "/" -> b != 0 ? a / b : Double.NaN;
default -> throw new RuntimeException("不支持的运算符: " + op);
};
yield String.format("%.2f %s %.2f = %.2f", a, op, b, res);
}
default -> throw new RuntimeException("未知工具: " + toolName);
};
return Map.of(
"content", List.of(Map.of(
"type", "text",
"text", result
))
);
}
/**
* 使用说明页面
*/
@IgnoreAuth
@GetMapping("/info")
@Operation(summary = "MCP Server 使用说明")
public Map<String, Object> info(HttpServletRequest request) {
log.info("[MCP Server] Hello 接口被访问");View on GitHub (pinned to 96fb33f5ec)
Solutions
- Call only hello, get_time, or calculate.
- Re-fetch tools via tools/list to sync the client.
- If you add a tool, register it in both the TOOLS array and the switch.
Defensive patterns
Strategy: validation
Validate before calling
private static final Set<String> TOOL_NAMES = Set.of("hello","get_time","calculate");
String toolName = params.getString("name");
if (!TOOL_NAMES.contains(toolName)) {
// return tool error: unknown tool, hint tools/list
} Try / catch
// Return the error as a tool result (isError=true) so the MCP client surfaces it.
return Map.of("content", List.of(Map.of("type","text","text","未知工具: "+toolName)), "isError", true); Prevention
- Derive TOOL_NAMES from the same array used in tools/list to avoid drift.
- Have clients call tools/list before invoking tools/call.
When it happens
Trigger: A client invokes a tool not present in the static TOOLS list; a typo in the tool name; client/server tool list out of sync.
Common situations: Generic MCP client cached an old tool list; typo; tool was renamed.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/12136488473facd2.
Report an issue: GitHub.