diff --git a/java-cfenv-boot-tanzu-genai/src/main/java/io/pivotal/cfenv/boot/genai/DefaultGenaiLocator.java b/java-cfenv-boot-tanzu-genai/src/main/java/io/pivotal/cfenv/boot/genai/DefaultGenaiLocator.java index 5f5cf92..66cc16b 100644 --- a/java-cfenv-boot-tanzu-genai/src/main/java/io/pivotal/cfenv/boot/genai/DefaultGenaiLocator.java +++ b/java-cfenv-boot-tanzu-genai/src/main/java/io/pivotal/cfenv/boot/genai/DefaultGenaiLocator.java @@ -231,6 +231,9 @@ public List getMcpServers() { private List getAllModelConnectivityDetails() { ConfigEndpoint e = getEndpointConfig(); + if (e.advertisedModels == null) { + return List.of(); + } return e.advertisedModels .stream() .map( a -> @@ -239,14 +242,24 @@ private List getAllModelConnectivityDetails() { a.capabilities(), a.labels(), apiKey, - apiBase + e.wireFormat().toLowerCase()) + merge(apiBase, e.wireFormat().toLowerCase())) ) .toList(); } + private String merge(String apiBase, String wireFormat) { + if (apiBase.endsWith("/")) { + return apiBase + wireFormat; + } + return apiBase + "/" + wireFormat; + } + private List getAllMcpConnectivityDetails() { - return getEndpointConfig() - .advertisedMcpServers + ConfigEndpoint e = getEndpointConfig(); + if (e.advertisedMcpServers == null) { + return List.of(); + } + return e.advertisedMcpServers .stream() .map(m -> new McpConnectivity(m.url())) .toList();