diff --git a/backend/app/service/mcp_server.go b/backend/app/service/mcp_server.go index c6e64981f..4b940587e 100644 --- a/backend/app/service/mcp_server.go +++ b/backend/app/service/mcp_server.go @@ -238,7 +238,7 @@ func (m McpServerService) GetBindDomain() (response.McpBindDomainRes, error) { } website, err := websiteRepo.GetFirst(commonRepo.WithByID(websiteID)) if err != nil { - return res, err + return res, nil } res.WebsiteID = website.ID res.Domain = website.PrimaryDomain diff --git a/backend/app/service/website.go b/backend/app/service/website.go index 271ee702b..bd3e2d9ea 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -498,7 +498,7 @@ func (w WebsiteService) DeleteWebsite(req request.WebsiteDelete) error { } websiteID := GetWebsiteID() if req.ID == websiteID { - _ = settingRepo.UpdateOrCreate("MCP_WEBSITE_ID", "0") + _ = settingRepo.Update("MCP_WEBSITE_ID", "0") } tx.Commit() diff --git a/frontend/src/api/interface/ai.ts b/frontend/src/api/interface/ai.ts index 43fbd8248..bcd970342 100644 --- a/frontend/src/api/interface/ai.ts +++ b/frontend/src/api/interface/ai.ts @@ -135,6 +135,8 @@ export namespace AI { volumes: Volume[]; dir?: string; hostIP: string; + protocol: string; + url: string; } export interface McpServerSearch extends ReqPage { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 75c0cedfd..38c9a496a 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -2609,7 +2609,7 @@ const message = { edit: 'Edit MCP Server', commandHelper: 'For example: npx -y {0}', baseUrl: 'External Access Path', - baseUrlHelper: 'For example: https://127.0.0.1:8080', + baseUrlHelper: 'For example: http://192.168.1.2:8000', ssePath: 'SSE Path', ssePathHelper: 'For example: /sse, note not to duplicate with other servers', environment: 'Environment Variables', diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts index 558277092..80b4d29e2 100644 --- a/frontend/src/lang/modules/ja.ts +++ b/frontend/src/lang/modules/ja.ts @@ -2579,7 +2579,7 @@ const message = { edit: 'サーバーを編集', commandHelper: '例: npx -y {0}', baseUrl: '外部アクセスパス', - baseUrlHelper: '例: https://127.0.0.1:8080', + baseUrlHelper: '例: http://192.168.1.2:8000', ssePath: 'SSE パス', ssePathHelper: '例: /sse, 他のサーバーと重複しないように注意してください', environment: '環境変数', diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts index 3c4283898..58ad7f7e2 100644 --- a/frontend/src/lang/modules/ko.ts +++ b/frontend/src/lang/modules/ko.ts @@ -2538,7 +2538,7 @@ const message = { edit: 'サーバーを編集', commandHelper: '例: npx -y {0}', baseUrl: '外部アクセスパス', - baseUrlHelper: '例: https://127.0.0.1:8080', + baseUrlHelper: '例: http://192.168.1.2:8000', ssePath: 'SSE パス', ssePathHelper: '例: /sse, 他のサーバーと重複しないように注意してください', environment: '環境変数', diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts index 6f98667bd..a02c03bb1 100644 --- a/frontend/src/lang/modules/ms.ts +++ b/frontend/src/lang/modules/ms.ts @@ -2637,7 +2637,7 @@ const message = { edit: 'Edit Pelayan', commandHelper: 'Contoh: npx -y {0}', baseUrl: 'Laluan Akses Luar', - baseUrlHelper: 'Contoh: https://127.0.0.1:8080', + baseUrlHelper: 'Contoh: http://192.168.1.2:8000', ssePath: 'Laluan SSE', ssePathHelper: 'Contoh: /sse, berhati-hati jangan bertindan dengan pelayan lain', environment: 'Pemboleh Ubah Persekitaran', diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts index ba4974724..507536783 100644 --- a/frontend/src/lang/modules/pt-br.ts +++ b/frontend/src/lang/modules/pt-br.ts @@ -2635,7 +2635,7 @@ const message = { edit: 'Editar Servidor', commandHelper: 'Por exemplo: npx -y {0}', baseUrl: 'Caminho de Acesso Externo', - baseUrlHelper: 'Por exemplo: https://127.0.0.1:8080', + baseUrlHelper: 'Por exemplo: http://192.168.1.2:8000', ssePath: 'Caminho SSE', ssePathHelper: 'Por exemplo: /sse, tome cuidado para não duplicar com outros servidores', environment: 'Variáveis de Ambiente', diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts index 43a276f61..d902e8b9f 100644 --- a/frontend/src/lang/modules/ru.ts +++ b/frontend/src/lang/modules/ru.ts @@ -2631,7 +2631,7 @@ const message = { edit: 'Редактировать сервер', commandHelper: 'Например: npx -y {0}', baseUrl: 'Внешний путь доступа', - baseUrlHelper: 'Например: https://127.0.0.1:8080', + baseUrlHelper: 'Например: http://192.168.1.2:8000', ssePath: 'Путь SSE', ssePathHelper: 'Например: /sse, будьте осторожны, чтобы не дублировать с другими серверами', environment: 'Переменные среды', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 5d83b1a9d..0f133ba87 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -2444,7 +2444,7 @@ const message = { edit: '編輯 MCP Server', commandHelper: '例如:npx -y {0}', baseUrl: '外部訪問路徑', - baseUrlHelper: '例如:https://127.0.0.1:8080', + baseUrlHelper: '例如:http://192.168.1.2:8000', ssePath: 'SSE 路徑', ssePathHelper: '例如:/sse,注意不要與其他 Server 重複', environment: '環境變數', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 20ce76a31..20d0e614c 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -2446,7 +2446,7 @@ const message = { edit: '编辑 MCP Server', commandHelper: '例如:npx -y {0}', baseUrl: '外部访问路径', - baseUrlHelper: '例如:https://127.0.0.1:8080', + baseUrlHelper: '例如:http://192.168.1.1:8000', ssePath: 'SSE 路径', ssePathHelper: '例如:/sse,注意不要与其他 Server 重复', environment: '环境变量', diff --git a/frontend/src/views/ai/mcp/server/operate/index.vue b/frontend/src/views/ai/mcp/server/operate/index.vue index f78c7a824..6dc3da252 100644 --- a/frontend/src/views/ai/mcp/server/operate/index.vue +++ b/frontend/src/views/ai/mcp/server/operate/index.vue @@ -82,8 +82,15 @@ - - + + + + {{ $t('mcp.baseUrlHelper') }} @@ -142,6 +149,8 @@ const newMcpServer = () => { environments: [], volumes: [], hostIP: '127.0.0.1', + protocol: 'http://', + url: '', }; }; const em = defineEmits(['close']); @@ -151,7 +160,7 @@ const rules = ref({ command: [Rules.requiredInput], port: [Rules.requiredInput, Rules.port], containerName: [Rules.requiredInput], - baseUrl: [Rules.requiredInput], + url: [Rules.requiredInput], ssePath: [Rules.requiredInput], key: [Rules.requiredInput], value: [Rules.requiredInput], @@ -167,6 +176,9 @@ const acceptParams = async (params: AI.McpServer) => { if (!mcpServer.value.volumes) { mcpServer.value.volumes = []; } + const parts = mcpServer.value.baseUrl.split(/(https?:\/\/)/).filter(Boolean); + mcpServer.value.protocol = parts[0]; + mcpServer.value.url = parts[1]; } else { mcpServer.value = newMcpServer(); if (params.port) { @@ -174,7 +186,12 @@ const acceptParams = async (params: AI.McpServer) => { } try { const res = await getMcpDomain(); - mcpServer.value.baseUrl = res.data.connUrl; + if (res.data.connUrl != '') { + const parts = res.data.connUrl.split(/(https?:\/\/)/).filter(Boolean); + mcpServer.value.protocol = parts[0]; + mcpServer.value.url = parts[1]; + mcpServer.value.baseUrl = res.data.connUrl; + } } catch (error) { MsgError(error); } @@ -229,6 +246,7 @@ const submit = async (formEl: FormInstance | undefined) => { } try { loading.value = true; + mcpServer.value.baseUrl = mcpServer.value.protocol + mcpServer.value.url; if (mode.value == 'create') { await createMcpServer(mcpServer.value); MsgSuccess(i18n.global.t('commons.msg.createSuccess'));