Skip to content

Commit 16ed20f

Browse files
zhendizhendi.wang
andauthored
feat(mcp_server): add environment configuration (#1142)
Co-authored-by: zhendi.wang <[email protected]>
1 parent 26c3f7f commit 16ed20f

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

frontend/src/components/application_spaces/ApplicationSpaceSettings.vue

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,36 @@
222222
</div>
223223
</div>
224224

225+
<!-- mcp space env -->
226+
<el-divider v-if="theSdk === 'mcp_server' && Object.keys(mcpEnv).length > 0"/>
227+
<div v-if="theSdk === 'mcp_server' && Object.keys(mcpEnv).length > 0">
228+
<div class="flex xl:flex-col gap-8">
229+
<div class="w-[380px] sm:w-full flex flex-col">
230+
<div class="text-sm text-gray-700 leading-[20px] font-medium">
231+
{{ $t('mcps.deploy.envDesc') }}
232+
</div>
233+
</div>
234+
<div class="flex flex-col gap-[6px]">
235+
<div v-for="(_, envKey) in mcpEnv" :key="envKey" class="mb-3">
236+
<label
237+
:for="envKey"
238+
class="text-gray-600 text-sm block mb-1"
239+
>
240+
{{ envKey }}
241+
</label>
242+
<el-input
243+
v-model="mcpEnv[envKey]"
244+
size="large"
245+
class="!w-[400px] sm:!w-full"
246+
/>
247+
</div>
248+
<el-button @click="updateEnv" class="w-[100px]" data-test="update-mcp-env">
249+
{{ $t('all.update') }}
250+
</el-button>
251+
</div>
252+
</div>
253+
</div>
254+
225255
<el-divider />
226256

227257
<!-- 修改可见性 -->
@@ -408,6 +438,7 @@
408438
],
409439
uploadCoverImageUrl: '/images/default_cover_image.png',
410440
imageUploaded: false,
441+
mcpEnv: {},
411442
t: useI18n()
412443
}
413444
},
@@ -471,6 +502,9 @@
471502
emits: ['showSpaceLogs'],
472503
mounted() {
473504
this.fetchSpaceResources()
505+
if (this.theSdk === 'mcp_server') {
506+
this.fetchSpaceDetail()
507+
}
474508
},
475509
inject: ['fetchRepoDetail'],
476510
methods: {
@@ -608,6 +642,30 @@
608642
}
609643
},
610644
645+
async fetchSpaceDetail () {
646+
const { data, error } = await useFetchApi(
647+
`/spaces/${this.path}`
648+
).json()
649+
if (error.value) {
650+
console.log(error.value.msg)
651+
} else {
652+
const body = data.value
653+
const envJSON = body.data.env
654+
if (envJSON) {
655+
try {
656+
this.mcpEnv = JSON.parse(envJSON)
657+
} catch (error) {
658+
console.log(error)
659+
}
660+
}
661+
}
662+
},
663+
664+
updateEnv() {
665+
const payload = { env: JSON.stringify(this.mcpEnv) }
666+
this.updateApplicationSpace(payload)
667+
},
668+
611669
changeVisibility(value) {
612670
ElMessageBox({
613671
title: this.$t('application_spaces.edit.changeVisibility'),

0 commit comments

Comments
 (0)