|
22 | 22 | import com.google.adk.tools.BaseTool;
|
23 | 23 | import com.google.common.collect.ImmutableMap;
|
24 | 24 | import com.google.genai.types.FunctionDeclaration;
|
25 |
| -import com.google.genai.types.Schema; |
26 | 25 | import io.modelcontextprotocol.spec.McpSchema.CallToolResult;
|
27 | 26 | import io.modelcontextprotocol.spec.McpSchema.Content;
|
28 | 27 | import io.modelcontextprotocol.spec.McpSchema.JsonSchema;
|
29 | 28 | import io.modelcontextprotocol.spec.McpSchema.TextContent;
|
30 | 29 | import io.modelcontextprotocol.spec.McpSchema.Tool;
|
31 |
| -import java.io.IOException; |
32 | 30 | import java.util.ArrayList;
|
33 | 31 | import java.util.List;
|
34 | 32 | import java.util.Map;
|
@@ -76,32 +74,17 @@ public T getMcpSession() {
|
76 | 74 | return this.mcpSession;
|
77 | 75 | }
|
78 | 76 |
|
79 |
| - protected Schema toGeminiSchema(JsonSchema openApiSchema) { |
80 |
| - try { |
81 |
| - return GeminiSchemaUtil.toGeminiSchema(openApiSchema, this.objectMapper); |
82 |
| - } catch (IOException | IllegalArgumentException e) { |
83 |
| - throw new IllegalArgumentException( |
84 |
| - "Error generating function declaration for tool '" + this.name() + "': " + e.getMessage(), |
85 |
| - e); |
86 |
| - } |
87 |
| - } |
88 |
| - |
89 | 77 | @Override
|
90 | 78 | public Optional<FunctionDeclaration> declaration() {
|
91 |
| - try { |
92 |
| - Schema schema = toGeminiSchema(this.mcpTool.inputSchema()); |
93 |
| - return Optional.ofNullable(schema) |
94 |
| - .map( |
95 |
| - value -> |
96 |
| - FunctionDeclaration.builder() |
97 |
| - .name(this.name()) |
98 |
| - .description(this.description()) |
99 |
| - .parameters(value) |
100 |
| - .build()); |
101 |
| - } catch (IllegalArgumentException e) { |
102 |
| - System.err.println(e.getMessage()); |
103 |
| - return Optional.empty(); |
104 |
| - } |
| 79 | + JsonSchema schema = this.mcpTool.inputSchema(); |
| 80 | + return Optional.ofNullable(schema) |
| 81 | + .map( |
| 82 | + value -> |
| 83 | + FunctionDeclaration.builder() |
| 84 | + .name(this.name()) |
| 85 | + .description(this.description()) |
| 86 | + .parametersJsonSchema(value) |
| 87 | + .build()); |
105 | 88 | }
|
106 | 89 |
|
107 | 90 | @SuppressWarnings("PreferredInterfaceType") // BaseTool.runAsync() returns Map<String, Object>
|
|
0 commit comments