feat: import mcp server support env (#8344)
Some checks are pending
SonarCloud Scan / SonarCloud (push) Waiting to run

This commit is contained in:
zhengkunwang 2025-04-08 11:11:52 +08:00 committed by GitHub
parent 170bd22062
commit 8196c11010
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -59,7 +59,7 @@ const onConfirm = async () => {
mcpServerConfig.value = Object.entries(data.mcpServers).map(([name, config]: any) => ({
name,
command: [config.command, ...config.args].join(' '),
environments: data.env ? Object.entries(data.env).map(([key, value]) => ({ key, value })) : [],
environments: config.env ? Object.entries(config.env).map(([key, value]) => ({ key, value })) : [],
ssePath: '/' + name,
containerName: name,
}));

View file

@ -165,8 +165,10 @@ const rules = ref({
key: [Rules.requiredInput],
value: [Rules.requiredInput],
});
const hasWebsite = ref(false);
const acceptParams = async (params: AI.McpServer) => {
hasWebsite.value = false;
mode.value = params.id ? 'edit' : 'create';
if (mode.value == 'edit') {
mcpServer.value = params;
@ -191,6 +193,7 @@ const acceptParams = async (params: AI.McpServer) => {
mcpServer.value.protocol = parts[0];
mcpServer.value.url = parts[1];
mcpServer.value.baseUrl = res.data.connUrl;
hasWebsite.value = true;
}
} catch (error) {
MsgError(error);
@ -244,6 +247,18 @@ const submit = async (formEl: FormInstance | undefined) => {
if (!valid) {
return;
}
let request = true;
if (!hasWebsite.value) {
await ElMessageBox.confirm(i18n.global.t('app.installWarn'), i18n.global.t('app.checkTitle'), {
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
}).catch(() => {
request = false;
});
}
if (!request) {
return;
}
try {
loading.value = true;
mcpServer.value.baseUrl = mcpServer.value.protocol + mcpServer.value.url;