Skip to content

Commit 6cf1351

Browse files
committed
add new method to get all the applications
1 parent bb6bbde commit 6cf1351

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/main/java/com/contrast/labs/ai/mcp/contrast/AssessService.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,27 @@ public List<ApplicationData> getActiveApplications(String appName) throws IOExce
247247
throw new IOException("Failed to list applications: " + e.getMessage(), e);
248248
}
249249
}
250+
251+
252+
@Tool(name = "list__all_applications", description = "Takes no argument and list all the applications")
253+
public List<ApplicationData> getActiveApplications() throws IOException {
254+
logger.info("Listing all applications");
255+
ContrastSDK contrastSDK = SDKHelper.getSDK(hostName, apiKey, serviceKey, userName);
256+
try {
257+
List<Application> applications = contrastSDK.getApplications(orgID).getApplications();
258+
logger.debug("Retrieved {} total applications from Contrast", applications.size());
259+
260+
List<ApplicationData> ReturnedApps = new ArrayList<>();
261+
for(Application app : applications) {
262+
ReturnedApps.add(new ApplicationData(app.getName(), app.getStatus(), app.getId()));
263+
}
264+
265+
logger.info("Found {} applications matching'", ReturnedApps.size());
266+
return ReturnedApps;
267+
268+
} catch (Exception e) {
269+
logger.error("Error listing all applications", e);
270+
throw new IOException("Failed to list applications: " + e.getMessage(), e);
271+
}
272+
}
250273
}

0 commit comments

Comments
 (0)