refactor: show error on missing mcp tool (#7587)

This commit is contained in:
one 2025-06-27 16:09:06 +08:00 committed by GitHub
parent e8e9a2d86f
commit 766897e733
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 5 deletions

View File

@ -1478,7 +1478,8 @@
"version": "Version"
},
"errors": {
"32000": "MCP server failed to start, please check the parameters according to the tutorial"
"32000": "MCP server failed to start, please check the parameters according to the tutorial",
"toolNotFound": "Tool {{name}} not found"
},
"serverPlural": "servers",
"serverSingular": "server",

View File

@ -1473,7 +1473,8 @@
"updateSuccess": "サーバーが正常に更新されました",
"url": "URL",
"errors": {
"32000": "MCP サーバーが起動しませんでした。パラメーターを確認してください"
"32000": "MCP サーバーが起動しませんでした。パラメーターを確認してください",
"toolNotFound": "ツール {{name}} が見つかりません"
},
"editMcpJson": "MCP 設定を編集",
"installHelp": "インストールヘルプを取得",

View File

@ -1465,7 +1465,8 @@
"version": "Версия"
},
"errors": {
"32000": "MCP сервер не запущен, пожалуйста, проверьте параметры"
"32000": "MCP сервер не запущен, пожалуйста, проверьте параметры",
"toolNotFound": "Инструмент {{name}} не найден"
},
"serverPlural": "серверы",
"serverSingular": "сервер",

View File

@ -1478,7 +1478,8 @@
"version": "版本"
},
"errors": {
"32000": "MCP 服务器启动失败,请根据教程检查参数是否填写完整"
"32000": "MCP 服务器启动失败,请根据教程检查参数是否填写完整",
"toolNotFound": "未找到工具 {{name}}"
},
"serverPlural": "服务器",
"serverSingular": "服务器",

View File

@ -1468,7 +1468,8 @@
"version": "版本"
},
"errors": {
"32000": "MCP 伺服器啟動失敗,請根據教程檢查參數是否填寫完整"
"32000": "MCP 伺服器啟動失敗,請根據教程檢查參數是否填寫完整",
"toolNotFound": "未找到工具 {{name}}"
},
"serverPlural": "伺服器",
"serverSingular": "伺服器",

View File

@ -2,6 +2,7 @@ import { ContentBlockParam, MessageParam, ToolUnion, ToolUseBlock } from '@anthr
import { Content, FunctionCall, Part, Tool, Type as GeminiSchemaType } from '@google/genai'
import Logger from '@renderer/config/logger'
import { isFunctionCallingModel, isVisionModel } from '@renderer/config/models'
import i18n from '@renderer/i18n'
import store from '@renderer/store'
import { addMCPServer } from '@renderer/store/mcp'
import {
@ -479,6 +480,7 @@ export function parseToolUse(content: string, mcpTools: MCPTool[]): ToolUseRespo
const mcpTool = mcpTools.find((tool) => tool.id === toolName)
if (!mcpTool) {
Logger.error(`Tool "${toolName}" not found in MCP tools`)
window.message.error(i18n.t('settings.mcp.errors.toolNotFound', { name: toolName }))
continue
}