2025-06-03 08:08:49 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<el-dialog
|
|
|
|
|
|
align-center
|
|
|
|
|
|
:title="$t('common.setting')"
|
|
|
|
|
|
v-model="dialogVisible"
|
|
|
|
|
|
style="width: 550px"
|
|
|
|
|
|
append-to-body
|
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
|
:close-on-press-escape="false"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-form
|
|
|
|
|
|
label-position="top"
|
|
|
|
|
|
ref="paramFormRef"
|
|
|
|
|
|
:model="form"
|
|
|
|
|
|
require-asterisk-position="right"
|
2025-08-19 09:36:23 +00:00
|
|
|
|
hide-required-asterisk
|
|
|
|
|
|
@submit.prevent
|
2025-06-03 08:08:49 +00:00
|
|
|
|
>
|
2025-08-12 03:14:44 +00:00
|
|
|
|
<el-form-item>
|
2025-08-20 09:16:55 +00:00
|
|
|
|
<el-radio-group v-model="form.mcp_source" @change="mcpSourceChange">
|
2025-08-12 03:14:44 +00:00
|
|
|
|
<el-radio value="referencing">
|
|
|
|
|
|
{{ $t('views.applicationWorkflow.nodes.mcpNode.reference') }}
|
|
|
|
|
|
</el-radio>
|
|
|
|
|
|
<el-radio value="custom">{{ $t('common.custom') }}</el-radio>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
2025-08-19 09:36:23 +00:00
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="form.mcp_source === 'referencing'"
|
|
|
|
|
|
:rules="[
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message:
|
|
|
|
|
|
$t('common.selectPlaceholder') +
|
|
|
|
|
|
` MCP ${$t('views.applicationWorkflow.nodes.mcpNode.tool')}`,
|
|
|
|
|
|
},
|
|
|
|
|
|
]"
|
|
|
|
|
|
prop="mcp_tool_id"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #label>
|
|
|
|
|
|
{{ `MCP ${$t('views.applicationWorkflow.nodes.mcpNode.tool')}` }}
|
|
|
|
|
|
<span class="color-danger">*</span>
|
|
|
|
|
|
</template>
|
2025-08-12 03:14:44 +00:00
|
|
|
|
<el-select v-model="form.mcp_tool_id" filterable>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="mcpTool in mcpToolSelectOptions"
|
|
|
|
|
|
:key="mcpTool.id"
|
|
|
|
|
|
:label="mcpTool.name"
|
|
|
|
|
|
:value="mcpTool.id"
|
|
|
|
|
|
>
|
2025-08-19 09:36:23 +00:00
|
|
|
|
<div class="flex align-center">
|
|
|
|
|
|
<el-avatar shape="square" :size="20" class="mr-8">
|
|
|
|
|
|
<img src="@/assets/workflow/icon_mcp.svg" style="width: 75%" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
<span>{{ mcpTool.name }}</span>
|
|
|
|
|
|
<el-tag v-if="mcpTool.scope === 'SHARED'" type="info" class="info-tag ml-8 mt-4">
|
|
|
|
|
|
{{ $t('views.shared.title') }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</div>
|
2025-08-12 03:14:44 +00:00
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
2025-06-03 08:08:49 +00:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
2025-08-12 03:14:44 +00:00
|
|
|
|
v-else
|
2025-06-03 08:08:49 +00:00
|
|
|
|
prop="mcp_servers"
|
2025-08-19 09:36:23 +00:00
|
|
|
|
:rules="[
|
|
|
|
|
|
{
|
|
|
|
|
|
required: true,
|
|
|
|
|
|
message: $t('common.inputPlaceholder') + ' ' + $t('views.tool.form.mcp.label'),
|
|
|
|
|
|
},
|
|
|
|
|
|
]"
|
2025-06-03 08:08:49 +00:00
|
|
|
|
>
|
2025-08-19 09:36:23 +00:00
|
|
|
|
<template #label>
|
|
|
|
|
|
{{ $t('views.tool.form.mcp.label') }}
|
|
|
|
|
|
<span class="color-danger">*</span>
|
|
|
|
|
|
<el-text type="info" class="color-secondary">
|
|
|
|
|
|
({{ $t('views.tool.form.mcp.tip') }})
|
|
|
|
|
|
</el-text>
|
|
|
|
|
|
</template>
|
2025-06-03 08:08:49 +00:00
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="form.mcp_servers"
|
|
|
|
|
|
:rows="6"
|
|
|
|
|
|
type="textarea"
|
|
|
|
|
|
:placeholder="mcpServerJson"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
|
<el-button @click.prevent="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="submit()" :loading="loading">
|
|
|
|
|
|
{{ $t('common.save') }}
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
2025-08-19 09:36:23 +00:00
|
|
|
|
import { computed, inject, onMounted, ref, watch } from 'vue'
|
|
|
|
|
|
import { loadSharedApi } from '@/utils/dynamics-api/shared-api.ts'
|
|
|
|
|
|
import { useRoute } from 'vue-router'
|
2025-06-03 08:08:49 +00:00
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['refresh'])
|
2025-08-20 09:16:55 +00:00
|
|
|
|
|
2025-06-03 08:08:49 +00:00
|
|
|
|
const paramFormRef = ref()
|
|
|
|
|
|
|
|
|
|
|
|
const mcpServerJson = `{
|
|
|
|
|
|
"math": {
|
|
|
|
|
|
"url": "your_server",
|
|
|
|
|
|
"transport": "sse"
|
|
|
|
|
|
}
|
|
|
|
|
|
}`
|
|
|
|
|
|
|
|
|
|
|
|
const form = ref<any>({
|
|
|
|
|
|
mcp_servers: '',
|
2025-08-12 03:14:44 +00:00
|
|
|
|
mcp_tool_id: '',
|
|
|
|
|
|
mcp_source: 'referencing',
|
2025-06-03 08:08:49 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-12 03:14:44 +00:00
|
|
|
|
const mcpToolSelectOptions = ref<any[]>([])
|
|
|
|
|
|
|
2025-06-03 08:08:49 +00:00
|
|
|
|
const dialogVisible = ref<boolean>(false)
|
2025-08-12 03:14:44 +00:00
|
|
|
|
|
2025-06-03 08:08:49 +00:00
|
|
|
|
const loading = ref(false)
|
2025-08-12 03:14:44 +00:00
|
|
|
|
|
2025-06-03 08:08:49 +00:00
|
|
|
|
watch(dialogVisible, (bool) => {
|
|
|
|
|
|
if (!bool) {
|
|
|
|
|
|
form.value = {
|
|
|
|
|
|
mcp_servers: '',
|
2025-08-12 03:14:44 +00:00
|
|
|
|
mcp_tool_id: '',
|
|
|
|
|
|
mcp_source: 'referencing',
|
2025-06-03 08:08:49 +00:00
|
|
|
|
}
|
2025-08-19 09:36:23 +00:00
|
|
|
|
paramFormRef.value?.clearValidate()
|
2025-06-03 08:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-20 09:16:55 +00:00
|
|
|
|
function mcpSourceChange() {
|
|
|
|
|
|
if (form.value.mcp_source === 'referencing') {
|
|
|
|
|
|
form.value.mcp_servers = ''
|
|
|
|
|
|
} else {
|
|
|
|
|
|
form.value.mcp_tool_id = ''
|
|
|
|
|
|
}
|
2025-08-12 03:14:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-20 09:16:55 +00:00
|
|
|
|
|
|
|
|
|
|
const open = (data: any, selectOptions: any) => {
|
2025-08-19 09:36:23 +00:00
|
|
|
|
form.value = { ...form.value, ...data }
|
|
|
|
|
|
form.value.mcp_source = data.mcp_source || 'referencing'
|
2025-06-03 08:08:49 +00:00
|
|
|
|
dialogVisible.value = true
|
2025-08-20 09:16:55 +00:00
|
|
|
|
mcpToolSelectOptions.value = selectOptions || []
|
2025-06-03 08:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const submit = () => {
|
2025-08-19 09:36:23 +00:00
|
|
|
|
paramFormRef.value.validate((valid: any) => {
|
2025-06-03 08:08:49 +00:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
emit('refresh', form.value)
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-19 09:36:23 +00:00
|
|
|
|
defineExpose({ open })
|
2025-06-03 08:08:49 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped></style>
|