Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/main/java/com/google/genai/Caches.java
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,25 @@ ObjectNode listCachedContentsResponseFromVertex(JsonNode fromObject, ObjectNode
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode mcpServerToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"name"}))) {
throw new IllegalArgumentException(
"name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise"
+ " Agent Platform mode.");
}

if (!Common.isZero(
Common.getValueByPath(fromObject, new String[] {"streamableHttpTransport"}))) {
throw new IllegalArgumentException(
"streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in"
+ " Gemini Enterprise Agent Platform mode.");
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -1291,10 +1310,16 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"mcpServers"}))) {
throw new IllegalArgumentException(
"mcpServers parameter is only supported in Gemini Developer API mode, not in Gemini"
+ " Enterprise Agent Platform mode.");
if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
ArrayNode keyArray =
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"mcpServers"});
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode result = objectMapper.createArrayNode();

for (JsonNode item : keyArray) {
result.add(mcpServerToVertex(JsonSerializable.toJsonNode(item), toObject));
}
Common.setValueByPath(toObject, new String[] {"mcpServers"}, result);
}

return toObject;
Expand Down
33 changes: 29 additions & 4 deletions src/main/java/com/google/genai/LiveConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,25 @@ ObjectNode liveServerMessageFromVertex(JsonNode fromObject, ObjectNode parentObj
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode mcpServerToVertex(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"name"}))) {
throw new IllegalArgumentException(
"name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise"
+ " Agent Platform mode.");
}

if (!Common.isZero(
Common.getValueByPath(fromObject, new String[] {"streamableHttpTransport"}))) {
throw new IllegalArgumentException(
"streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in"
+ " Gemini Enterprise Agent Platform mode.");
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -2169,10 +2188,16 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"mcpServers"}))) {
throw new IllegalArgumentException(
"mcpServers parameter is only supported in Gemini Developer API mode, not in Gemini"
+ " Enterprise Agent Platform mode.");
if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
ArrayNode keyArray =
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"mcpServers"});
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode result = objectMapper.createArrayNode();

for (JsonNode item : keyArray) {
result.add(mcpServerToVertex(JsonSerializable.toJsonNode(item), toObject));
}
Common.setValueByPath(toObject, new String[] {"mcpServers"}, result);
}

return toObject;
Expand Down
33 changes: 29 additions & 4 deletions src/main/java/com/google/genai/Models.java
Original file line number Diff line number Diff line change
Expand Up @@ -4060,6 +4060,25 @@ ObjectNode maskReferenceConfigToVertex(
return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode mcpServerToVertex(JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"name"}))) {
throw new IllegalArgumentException(
"name parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise"
+ " Agent Platform mode.");
}

if (!Common.isZero(
Common.getValueByPath(fromObject, new String[] {"streamableHttpTransport"}))) {
throw new IllegalArgumentException(
"streamableHttpTransport parameter is only supported in Gemini Developer API mode, not in"
+ " Gemini Enterprise Agent Platform mode.");
}

return toObject;
}

@ExcludeFromGeneratedCoverageReport
ObjectNode modelFromMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
Expand Down Expand Up @@ -5200,10 +5219,16 @@ ObjectNode toolToVertex(JsonNode fromObject, ObjectNode parentObject, JsonNode r
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (!Common.isZero(Common.getValueByPath(fromObject, new String[] {"mcpServers"}))) {
throw new IllegalArgumentException(
"mcpServers parameter is only supported in Gemini Developer API mode, not in Gemini"
+ " Enterprise Agent Platform mode.");
if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
ArrayNode keyArray =
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"mcpServers"});
ObjectMapper objectMapper = new ObjectMapper();
ArrayNode result = objectMapper.createArrayNode();

for (JsonNode item : keyArray) {
result.add(mcpServerToVertex(JsonSerializable.toJsonNode(item), toObject, rootObject));
}
Common.setValueByPath(toObject, new String[] {"mcpServers"}, result);
}

return toObject;
Expand Down
Loading