fix(mcp-tools): enhance tool lookup to match by name in addition to ID (#4323)

This commit is contained in:
LiuVaayne 2025-04-02 23:20:07 +08:00 committed by GitHub
parent a42283e789
commit b53dbcbb30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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