summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/mcp-client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/tools/mcp-client.ts')
-rw-r--r--packages/core/src/tools/mcp-client.ts37
1 files changed, 2 insertions, 35 deletions
diff --git a/packages/core/src/tools/mcp-client.ts b/packages/core/src/tools/mcp-client.ts
index 359ce30a..bb92ab05 100644
--- a/packages/core/src/tools/mcp-client.ts
+++ b/packages/core/src/tools/mcp-client.ts
@@ -14,13 +14,8 @@ import {
import { parse } from 'shell-quote';
import { MCPServerConfig } from '../config/config.js';
import { DiscoveredMCPTool } from './mcp-tool.js';
-import {
- CallableTool,
- FunctionDeclaration,
- mcpToTool,
- Schema,
-} from '@google/genai';
-import { ToolRegistry } from './tool-registry.js';
+import { CallableTool, FunctionDeclaration, mcpToTool } from '@google/genai';
+import { sanitizeParameters, ToolRegistry } from './tool-registry.js';
export const MCP_DEFAULT_TIMEOUT_MSEC = 10 * 60 * 1000; // default to 10 minutes
@@ -384,31 +379,3 @@ async function connectAndDiscover(
}
}
}
-
-/**
- * Sanitizes a JSON schema object to ensure compatibility with Vertex AI.
- * This function recursively processes the schema to remove problematic properties
- * that can cause issues with the Gemini API.
- *
- * @param schema The JSON schema object to sanitize (modified in-place)
- */
-export function sanitizeParameters(schema?: Schema) {
- if (!schema) {
- return;
- }
- if (schema.anyOf) {
- // Vertex AI gets confused if both anyOf and default are set.
- schema.default = undefined;
- for (const item of schema.anyOf) {
- sanitizeParameters(item);
- }
- }
- if (schema.items) {
- sanitizeParameters(schema.items);
- }
- if (schema.properties) {
- for (const item of Object.values(schema.properties)) {
- sanitizeParameters(item);
- }
- }
-}