diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 7e6d40826b..303899f2e8 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -1519,6 +1519,7 @@ "registry": "Package Registry", "registryTooltip": "Choose the registry for package installation to resolve network issues with the default registry.", "registryDefault": "Default", + "customRegistryPlaceholder": "Enter private registry URL, e.g.: https://npm.company.com", "not_support": "Model not supported", "user": "User", "system": "System", diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index 4e2c5b0646..bd20c61ead 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -1513,6 +1513,7 @@ "registry": "パッケージ管理レジストリ", "registryTooltip": "デフォルトのレジストリでネットワークの問題が発生した場合、パッケージインストールに使用するレジストリを選択してください。", "registryDefault": "デフォルト", + "customRegistryPlaceholder": "プライベート倉庫のアドレスを入力してください(例:https://npm.company.com)", "not_support": "モデルはサポートされていません", "user": "ユーザー", "system": "システム", diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index 8f52666854..fcd5487b92 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -1513,6 +1513,7 @@ "registry": "Реестр пакетов", "registryTooltip": "Выберите реестр для установки пакетов, если возникают проблемы с сетью при использовании реестра по умолчанию.", "registryDefault": "По умолчанию", + "customRegistryPlaceholder": "Введите адрес частного склада, например: https://npm.company.com", "not_support": "Модель не поддерживается", "user": "Пользователь", "system": "Система", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 9a2ad2597c..9bc4201f71 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -1519,6 +1519,7 @@ "registry": "包管理源", "registryTooltip": "选择用于安装包的源,以解决默认源的网络问题", "registryDefault": "默认", + "customRegistryPlaceholder": "请输入私有仓库地址,如: https://npm.company.com", "not_support": "模型不支持", "user": "用户", "system": "系统", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 64ef5bac85..e99c57e170 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -1516,6 +1516,7 @@ "registry": "套件管理源", "registryTooltip": "選擇用於安裝套件的源,以解決預設源的網路問題", "registryDefault": "預設", + "customRegistryPlaceholder": "請輸入私有倉庫位址,如: https://npm.company.com", "not_support": "不支援此模型", "user": "用戶", "system": "系統", diff --git a/src/renderer/src/pages/settings/MCPSettings/McpSettings.tsx b/src/renderer/src/pages/settings/MCPSettings/McpSettings.tsx index c20df064d3..3dc423b202 100644 --- a/src/renderer/src/pages/settings/MCPSettings/McpSettings.tsx +++ b/src/renderer/src/pages/settings/MCPSettings/McpSettings.tsx @@ -41,7 +41,10 @@ interface Registry { url: string } -const NpmRegistry: Registry[] = [{ name: '淘宝 NPM Mirror', url: 'https://registry.npmmirror.com' }] +const NpmRegistry: Registry[] = [ + { name: '淘宝 NPM Mirror', url: 'https://registry.npmmirror.com' }, + { name: '自定义', url: 'custom' } +] const PipRegistry: Registry[] = [ { name: '清华大学', url: 'https://pypi.tuna.tsinghua.edu.cn/simple' }, { name: '阿里云', url: 'http://mirrors.aliyun.com/pypi/simple/' }, @@ -86,6 +89,8 @@ const McpSettings: React.FC = () => { const [resources, setResources] = useState([]) const [isShowRegistry, setIsShowRegistry] = useState(false) const [registry, setRegistry] = useState() + const [customRegistryUrl, setCustomRegistryUrl] = useState('') + const [selectedRegistryType, setSelectedRegistryType] = useState('') const [showAdvanced, setShowAdvanced] = useState(false) @@ -107,15 +112,34 @@ const McpSettings: React.FC = () => { setIsShowRegistry(true) // Determine registry type based on command + let currentRegistry: Registry[] = [] if (server.command.includes('uv') || server.command.includes('uvx')) { + currentRegistry = PipRegistry setRegistry(PipRegistry) } else if ( server.command.includes('npx') || server.command.includes('bun') || server.command.includes('bunx') ) { + currentRegistry = NpmRegistry setRegistry(NpmRegistry) } + + // Check if the registryUrl is a custom URL (not in the predefined list) + const isCustomRegistry = + currentRegistry.length > 0 && + !currentRegistry.some((reg) => reg.url === server.registryUrl) && + server.registryUrl !== '' // empty string is default + + if (isCustomRegistry) { + // Set custom registry state + setSelectedRegistryType('custom') + setCustomRegistryUrl(server.registryUrl) + } else { + // Reset custom registry state for predefined registries + setSelectedRegistryType('') + setCustomRegistryUrl('') + } } } @@ -294,6 +318,16 @@ const McpSettings: React.FC = () => { const onSelectRegistry = (url: string) => { const command = form.getFieldValue('command') || '' + // If custom registry is selected + if (url === 'custom') { + setSelectedRegistryType('custom') + // Don't set the registryUrl yet, wait for user input + return + } + + setSelectedRegistryType('') + setCustomRegistryUrl('') + // Add new registry env variables if (command.includes('uv') || command.includes('uvx')) { // envs['PIP_INDEX_URL'] = url @@ -308,6 +342,12 @@ const McpSettings: React.FC = () => { setIsFormChanged(true) } + const onCustomRegistryChange = (url: string) => { + setCustomRegistryUrl(url) + form.setFieldsValue({ registryUrl: url }) + setIsFormChanged(true) + } + const onDeleteMcpServer = useCallback( async (server: MCPServer) => { try { @@ -484,7 +524,8 @@ const McpSettings: React.FC = () => { name="registryUrl" label={t('settings.mcp.registry')} tooltip={t('settings.mcp.registryTooltip')}> - + { ))} + {selectedRegistryType === 'custom' && ( + onCustomRegistryChange(e.target.value)} + style={{ marginTop: 8 }} + /> + )} )}