From b53dbcbb30a7582819784e304e4ff01bac2a7685 Mon Sep 17 00:00:00 2001 From: LiuVaayne <10231735+vaayne@users.noreply.github.com> Date: Wed, 2 Apr 2025 23:20:07 +0800 Subject: [PATCH] fix(mcp-tools): enhance tool lookup to match by name in addition to ID (#4323) --- src/renderer/src/utils/mcp-tools.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/utils/mcp-tools.ts b/src/renderer/src/utils/mcp-tools.ts index 46eea760..079472cb 100644 --- a/src/renderer/src/utils/mcp-tools.ts +++ b/src/renderer/src/utils/mcp-tools.ts @@ -1,16 +1,19 @@ import { Tool, ToolUnion, ToolUseBlock } from '@anthropic-ai/sdk/resources' -import { FunctionCall, FunctionDeclaration, SchemaType, Tool as geminiTool } from '@google/generative-ai' import { ArraySchema, BaseSchema, BooleanSchema, EnumStringSchema, + FunctionCall, + FunctionDeclaration, FunctionDeclarationSchema, FunctionDeclarationSchemaProperty, IntegerSchema, NumberSchema, ObjectSchema, - SimpleStringSchema + SchemaType, + SimpleStringSchema, + Tool as geminiTool } from '@google/generative-ai' import { nanoid } from '@reduxjs/toolkit' import store from '@renderer/store' @@ -182,7 +185,9 @@ export function openAIToolsToMcpTool( return undefined } - const tool = mcpTools.find((mcptool) => mcptool.id === llmTool.function.name) + const tool = mcpTools.find( + (mcptool) => mcptool.id === llmTool.function.name || mcptool.name === llmTool.function.name + ) if (!tool) { console.warn('No MCP Tool found for tool call:', llmTool)