Add cleanSearchResponseObject()

This commit is contained in:
mohitdeuex 2025-06-16 23:03:49 +05:30
parent f940f27988
commit 0e2c00bd00

View File

@ -119,7 +119,7 @@ public class SearchMetadataTool implements McpTool {
"SearchMetadataTool does not support limits enforcement.");
}
private static Map<String, Object> cleanSearchResponse(Map<String, Object> searchResponse) {
public static Map<String, Object> cleanSearchResponse(Map<String, Object> searchResponse) {
if (searchResponse == null) return Collections.emptyMap();
Map<String, Object> topHits = safeGetMap(searchResponse.get("hits"));
@ -142,6 +142,12 @@ public class SearchMetadataTool implements McpTool {
return Collections.emptyMap();
}
@SuppressWarnings("unused")
public static Map<String, Object> cleanSearchResponseObject(Map<String, Object> object) {
IGNORE_SEARCH_KEYS.forEach(object::remove);
return object;
}
@SuppressWarnings("unchecked")
private static Map<String, Object> safeGetMap(Object obj) {
return (obj instanceof Map) ? (Map<String, Object>) obj : null;