diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts index 1685ecbc95..9214670714 100644 --- a/web/src/locales/en.ts +++ b/web/src/locales/en.ts @@ -3020,6 +3020,7 @@ Important structured information may include: names, dates, locations, events, k bulkManage: 'Bulk manage', exitBulkManage: 'Exit bulk manage', selected: 'Selected', + noServerSelected: 'Please select at least one MCP server', }, search: { searchApps: 'Search apps', diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts index 28745279c9..4692728763 100644 --- a/web/src/locales/zh.ts +++ b/web/src/locales/zh.ts @@ -2603,6 +2603,7 @@ Tokenizer 会根据所选方式将内容存储为对应的数据结构。`, selected: '已选择', bulkManage: '批量管理', exitBulkManage: '退出批量管理', + noServerSelected: '请至少选择一个 MCP 服务器', }, search: { searchApps: '搜索', diff --git a/web/src/pages/user-setting/mcp/use-export-mcp.ts b/web/src/pages/user-setting/mcp/use-export-mcp.ts index e07b29fa19..93b8e52fb5 100644 --- a/web/src/pages/user-setting/mcp/use-export-mcp.ts +++ b/web/src/pages/user-setting/mcp/use-export-mcp.ts @@ -1,16 +1,22 @@ +import message from '@/components/ui/message'; import { useExportMcpServer } from '@/hooks/use-mcp-request'; import { IMcpServer } from '@/interfaces/database/mcp'; import { downloadJsonFile } from '@/utils/file-util'; +import i18n from '@/locales/config'; import { useCallback } from 'react'; -export function useExportMcp(mcp: IMcpServer) { +export function useExportMcp(mcp?: IMcpServer) { const { exportMcpServer } = useExportMcpServer(); const handleExportMcpJson = useCallback( (ids: string[]) => async () => { + if (ids.length === 0) { + message.warning(i18n.t('mcp.noServerSelected')); + return; + } const data = await exportMcpServer(ids); - if (data.code === 0 && mcp) { - downloadJsonFile(data.data, `${mcp.name || 'mcp'}.json`); + if (data.code === 0) { + downloadJsonFile(data.data, `${mcp?.name || 'mcp'}.json`); } }, [exportMcpServer, mcp],