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
3 changes: 3 additions & 0 deletions src/main/java/com/google/genai/AfcUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ static ImmutableList<Integer> findAfcIncompatibleToolIndexes(GenerateContentConf
if (tool.functionDeclarations().isPresent() && !tool.functionDeclarations().get().isEmpty()) {
incompatibleToolsIndexesBuilder.add(i);
}
if (tool.mcpServers().isPresent() && !tool.mcpServers().get().isEmpty()) {
incompatibleToolsIndexesBuilder.add(i);
}
}

return incompatibleToolsIndexesBuilder.build();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/google/genai/Batches.java
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"mcpServers"},
Common.getValueByPath(fromObject, new String[] {"mcpServers"}));
}

return toObject;
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/google/genai/Caches.java
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"mcpServers"},
Common.getValueByPath(fromObject, new String[] {"mcpServers"}));
}

return toObject;
}

Expand Down Expand Up @@ -950,6 +957,10 @@ 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 not supported in Vertex AI.");
}

return toObject;
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/google/genai/LiveConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"mcpServers"},
Common.getValueByPath(fromObject, new String[] {"mcpServers"}));
}

return toObject;
}

Expand Down Expand Up @@ -1708,6 +1715,10 @@ 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 not supported in Vertex AI.");
}

return toObject;
}

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/google/genai/Models.java
Original file line number Diff line number Diff line change
Expand Up @@ -4573,6 +4573,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode ro
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"mcpServers"},
Common.getValueByPath(fromObject, new String[] {"mcpServers"}));
}

return toObject;
}

Expand Down Expand Up @@ -4652,6 +4659,10 @@ 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 not supported in Vertex AI.");
}

return toObject;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/google/genai/TokensConverters.java
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,13 @@ ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
Common.getValueByPath(fromObject, new String[] {"urlContext"}));
}

if (Common.getValueByPath(fromObject, new String[] {"mcpServers"}) != null) {
Common.setValueByPath(
toObject,
new String[] {"mcpServers"},
Common.getValueByPath(fromObject, new String[] {"mcpServers"}));
}

return toObject;
}
}
119 changes: 119 additions & 0 deletions src/main/java/com/google/genai/types/McpServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Auto-generated code. Do not edit.

package com.google.genai.types;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.auto.value.AutoValue;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.genai.JsonSerializable;
import java.util.Optional;

/**
* A MCPServer is a server that can be called by the model to perform actions. It is a server that
* implements the MCP protocol. Next ID: 5. This data type is not supported in Vertex AI.
*/
@AutoValue
@JsonDeserialize(builder = McpServer.Builder.class)
public abstract class McpServer extends JsonSerializable {
/** The name of the MCPServer. */
@JsonProperty("name")
public abstract Optional<String> name();

/** A transport that can stream HTTP requests and responses. */
@JsonProperty("streamableHttpTransport")
public abstract Optional<StreamableHttpTransport> streamableHttpTransport();

/** Instantiates a builder for McpServer. */
@ExcludeFromGeneratedCoverageReport
public static Builder builder() {
return new AutoValue_McpServer.Builder();
}

/** Creates a builder with the same values as this instance. */
public abstract Builder toBuilder();

/** Builder for McpServer. */
@AutoValue.Builder
public abstract static class Builder {
/** For internal usage. Please use `McpServer.builder()` for instantiation. */
@JsonCreator
private static Builder create() {
return new AutoValue_McpServer.Builder();
}

/**
* Setter for name.
*
* <p>name: The name of the MCPServer.
*/
@JsonProperty("name")
public abstract Builder name(String name);

@ExcludeFromGeneratedCoverageReport
abstract Builder name(Optional<String> name);

/** Clears the value of name field. */
@ExcludeFromGeneratedCoverageReport
@CanIgnoreReturnValue
public Builder clearName() {
return name(Optional.empty());
}

/**
* Setter for streamableHttpTransport.
*
* <p>streamableHttpTransport: A transport that can stream HTTP requests and responses.
*/
@JsonProperty("streamableHttpTransport")
public abstract Builder streamableHttpTransport(
StreamableHttpTransport streamableHttpTransport);

/**
* Setter for streamableHttpTransport builder.
*
* <p>streamableHttpTransport: A transport that can stream HTTP requests and responses.
*/
@CanIgnoreReturnValue
public Builder streamableHttpTransport(
StreamableHttpTransport.Builder streamableHttpTransportBuilder) {
return streamableHttpTransport(streamableHttpTransportBuilder.build());
}

@ExcludeFromGeneratedCoverageReport
abstract Builder streamableHttpTransport(
Optional<StreamableHttpTransport> streamableHttpTransport);

/** Clears the value of streamableHttpTransport field. */
@ExcludeFromGeneratedCoverageReport
@CanIgnoreReturnValue
public Builder clearStreamableHttpTransport() {
return streamableHttpTransport(Optional.empty());
}

public abstract McpServer build();
}

/** Deserializes a JSON string to a McpServer object. */
@ExcludeFromGeneratedCoverageReport
public static McpServer fromJson(String jsonString) {
return JsonSerializable.fromJsonString(jsonString, McpServer.class);
}
}
Loading