fix: update google/genai to v1.9.0 and switch to parametersJsonSchema for MCP related tools (#4176)
Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
This commit is contained in:
parent
21eb44b242
commit
f6ee0d182b
|
@ -930,15 +930,13 @@
|
|||
"link": true
|
||||
},
|
||||
"node_modules/@google/genai": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@google/genai/-/genai-1.8.0.tgz",
|
||||
"integrity": "sha512-n3KiMFesQCy2R9iSdBIuJ0JWYQ1HZBJJkmt4PPZMGZKvlgHhBAGw1kUMyX+vsAIzprN3lK45DI755lm70wPOOg==",
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@google/genai/-/genai-1.9.0.tgz",
|
||||
"integrity": "sha512-w9P93OXKPMs9H1mfAx9+p3zJqQGrWBGdvK/SVc7cLZEXNHr/3+vW2eif7ZShA6wU24rNLn9z9MK2vQFUvNRI2Q==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"google-auth-library": "^9.14.2",
|
||||
"ws": "^8.18.0",
|
||||
"zod": "^3.22.4",
|
||||
"zod-to-json-schema": "^3.22.4"
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
|
@ -11925,7 +11923,7 @@
|
|||
"name": "@google/gemini-cli-core",
|
||||
"version": "0.1.12",
|
||||
"dependencies": {
|
||||
"@google/genai": "1.8.0",
|
||||
"@google/genai": "1.9.0",
|
||||
"@modelcontextprotocol/sdk": "^1.11.0",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
"@opentelemetry/exporter-logs-otlp-grpc": "^0.52.0",
|
||||
|
|
|
@ -170,11 +170,13 @@ const getMcpStatus = async (
|
|||
// Use cyan color for the tool name even when not showing descriptions
|
||||
message += ` - ${COLOR_CYAN}${tool.name}${RESET_COLOR}\n`;
|
||||
}
|
||||
if (showSchema && tool.parameterSchema) {
|
||||
const parameters =
|
||||
tool.schema.parametersJsonSchema ?? tool.schema.parameters;
|
||||
if (showSchema && parameters) {
|
||||
// Prefix the parameters in cyan
|
||||
message += ` ${COLOR_CYAN}Parameters:${RESET_COLOR}\n`;
|
||||
|
||||
const paramsLines = JSON.stringify(tool.parameterSchema, null, 2)
|
||||
const paramsLines = JSON.stringify(parameters, null, 2)
|
||||
.trim()
|
||||
.split('\n');
|
||||
if (paramsLines) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@google/genai": "1.8.0",
|
||||
"@google/genai": "1.9.0",
|
||||
"@modelcontextprotocol/sdk": "^1.11.0",
|
||||
"@opentelemetry/api": "^1.9.0",
|
||||
"@opentelemetry/exporter-logs-otlp-grpc": "^0.52.0",
|
||||
|
|
|
@ -18,8 +18,9 @@ import {
|
|||
import { parse } from 'shell-quote';
|
||||
import { MCPServerConfig } from '../config/config.js';
|
||||
import { DiscoveredMCPTool } from './mcp-tool.js';
|
||||
import { FunctionDeclaration, Type, mcpToTool } from '@google/genai';
|
||||
import { sanitizeParameters, ToolRegistry } from './tool-registry.js';
|
||||
|
||||
import { FunctionDeclaration, mcpToTool } from '@google/genai';
|
||||
import { ToolRegistry } from './tool-registry.js';
|
||||
import {
|
||||
ActiveFileNotificationSchema,
|
||||
IDE_SERVER_NAME,
|
||||
|
@ -275,15 +276,13 @@ export async function discoverTools(
|
|||
|
||||
const toolNameForModel = generateValidName(funcDecl, mcpServerName);
|
||||
|
||||
sanitizeParameters(funcDecl.parameters);
|
||||
|
||||
discoveredTools.push(
|
||||
new DiscoveredMCPTool(
|
||||
mcpCallableTool,
|
||||
mcpServerName,
|
||||
toolNameForModel,
|
||||
funcDecl.description ?? '',
|
||||
funcDecl.parameters ?? { type: Type.OBJECT, properties: {} },
|
||||
funcDecl.parametersJsonSchema ?? { type: 'object', properties: {} },
|
||||
funcDecl.name!,
|
||||
mcpServerConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC,
|
||||
mcpServerConfig.trust,
|
||||
|
|
|
@ -65,7 +65,8 @@ describe('DiscoveredMCPTool', () => {
|
|||
expect(tool.name).toBe(toolNameForModel);
|
||||
expect(tool.schema.name).toBe(toolNameForModel);
|
||||
expect(tool.schema.description).toBe(baseDescription);
|
||||
expect(tool.schema.parameters).toEqual(inputSchema);
|
||||
expect(tool.schema.parameters).toBeUndefined();
|
||||
expect(tool.schema.parametersJsonSchema).toEqual(inputSchema);
|
||||
expect(tool.serverToolName).toBe(serverToolName);
|
||||
expect(tool.timeout).toBeUndefined();
|
||||
});
|
||||
|
@ -81,6 +82,8 @@ describe('DiscoveredMCPTool', () => {
|
|||
serverToolName,
|
||||
);
|
||||
expect(tool.schema.description).toBe(baseDescription);
|
||||
expect(tool.schema.parameters).toBeUndefined();
|
||||
expect(tool.schema.parametersJsonSchema).toEqual(inputSchema);
|
||||
});
|
||||
|
||||
it('should accept and store a custom timeout', () => {
|
||||
|
|
|
@ -11,7 +11,13 @@ import {
|
|||
ToolConfirmationOutcome,
|
||||
ToolMcpConfirmationDetails,
|
||||
} from './tools.js';
|
||||
import { CallableTool, Part, FunctionCall, Schema } from '@google/genai';
|
||||
import {
|
||||
CallableTool,
|
||||
Part,
|
||||
FunctionCall,
|
||||
FunctionDeclaration,
|
||||
Type,
|
||||
} from '@google/genai';
|
||||
|
||||
type ToolParams = Record<string, unknown>;
|
||||
|
||||
|
@ -23,7 +29,7 @@ export class DiscoveredMCPTool extends BaseTool<ToolParams, ToolResult> {
|
|||
readonly serverName: string,
|
||||
readonly name: string,
|
||||
readonly description: string,
|
||||
readonly parameterSchema: Schema,
|
||||
readonly parameterSchemaJson: unknown,
|
||||
readonly serverToolName: string,
|
||||
readonly timeout?: number,
|
||||
readonly trust?: boolean,
|
||||
|
@ -32,12 +38,24 @@ export class DiscoveredMCPTool extends BaseTool<ToolParams, ToolResult> {
|
|||
name,
|
||||
`${serverToolName} (${serverName} MCP Server)`,
|
||||
description,
|
||||
parameterSchema,
|
||||
{ type: Type.OBJECT }, // this is a dummy Schema for MCP, will be not be used to construct the FunctionDeclaration
|
||||
true, // isOutputMarkdown
|
||||
false, // canUpdateOutput
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the base schema to use parametersJsonSchema when building
|
||||
* FunctionDeclaration
|
||||
*/
|
||||
override get schema(): FunctionDeclaration {
|
||||
return {
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
parametersJsonSchema: this.parameterSchemaJson,
|
||||
};
|
||||
}
|
||||
|
||||
async shouldConfirmExecute(
|
||||
_params: ToolParams,
|
||||
_abortSignal: AbortSignal,
|
||||
|
|
|
@ -97,7 +97,7 @@ export abstract class BaseTool<
|
|||
* @param description Description of what the tool does
|
||||
* @param isOutputMarkdown Whether the tool's output should be rendered as markdown
|
||||
* @param canUpdateOutput Whether the tool supports live (streaming) output
|
||||
* @param parameterSchema JSON Schema defining the parameters
|
||||
* @param parameterSchema Open API 3.0 Schema defining the parameters
|
||||
*/
|
||||
constructor(
|
||||
readonly name: string,
|
||||
|
|
Loading…
Reference in New Issue