| | |
| | | return JsonRpcResponse.err(id, -32000, "Server error", e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public List<Map<String, Object>> listTools() { |
| | | return registry.listTools(); |
| | | } |
| | | |
| | | public Object callTool(String toolName, JSONObject arguments) throws Exception { |
| | | if (toolName == null || toolName.trim().isEmpty()) { |
| | | throw new IllegalArgumentException("missing tool name"); |
| | | } |
| | | ToolDefinition def = registry.get(toolName); |
| | | if (def == null) { |
| | | throw new IllegalArgumentException("tool not found: " + toolName); |
| | | } |
| | | return def.getHandler().handle(arguments == null ? new JSONObject() : arguments); |
| | | } |
| | | } |