fix(mcp-tools): enhance tool lookup logic to support partial matches (#8473)

* fix(mcp-tools): enhance tool lookup logic to support partial matches

- Updated the tool lookup logic in `geminiFunctionCallToMcpTool` to include partial matches for both tool IDs and names, improving the flexibility of tool identification.

* refactor(mcp-tools): simplify tool lookup logic for improved clarity

- Refactored the tool lookup logic in `geminiFunctionCallToMcpTool` to streamline the identification process by consolidating checks for tool IDs and names into a single variable. This enhances readability and maintains functionality for partial matches.
This commit is contained in:
SuYao 2025-07-25 00:14:09 +08:00 committed by GitHub
parent 4c0167cc03
commit d8c5c31e61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -417,10 +417,12 @@ export function geminiFunctionCallToMcpTool(
): MCPTool | undefined {
if (!toolCall) return undefined
if (!mcpTools) return undefined
const tool = mcpTools.find((tool) => tool.id === toolCall.name || tool.name === toolCall.name)
if (!tool) {
return undefined
}
const toolName = toolCall.name || toolCall.id
if (!toolName) return undefined
const tool = mcpTools.find((tool) => tool.id.includes(toolName) || tool.name.includes(toolName))
return tool
}