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:
Wanlin Du
2025-07-16 14:32:34 -07:00
committed by GitHub
parent 21eb44b242
commit f6ee0d182b
7 changed files with 40 additions and 20 deletions

View File

@@ -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,