From ed4c55d3d60e1e19daceee4dd30d40da3d4102a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=E9=AD=8F?= Date: Thu, 14 Aug 2025 14:52:29 +0800 Subject: [PATCH] =?UTF-8?q?MCP=E6=9C=8D=E5=8A=A1=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=EF=BC=8C=E7=8A=B6=E6=80=81=E5=B1=95=E7=A4=BA=EF=BC=8C=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/paths/mcp.ts | 13 +- src/assets/svgs/warning.svg | 8 ++ src/views/api/components/McpDrawer.vue | 2 +- src/views/api/components/PluginCard.vue | 3 +- src/views/api/index.vue | 171 +++++++++++++++++++----- 5 files changed, 157 insertions(+), 40 deletions(-) create mode 100644 src/assets/svgs/warning.svg diff --git a/src/apis/paths/mcp.ts b/src/apis/paths/mcp.ts index 31ec1eb5..c85d8390 100644 --- a/src/apis/paths/mcp.ts +++ b/src/apis/paths/mcp.ts @@ -10,6 +10,8 @@ const getMcpList = (params: { keyword?: string; page?: number; pageSize?: number; + isInstall?: boolean | null; + isActive?: boolean | null; }) => { return get<{ currentPage: number; @@ -69,13 +71,13 @@ const createOrUpdateMcpService = (params: { name: string; overview: string; description: string; - config: string; + config: object; mcpType: 'stdio' | 'sse' | 'stream'; }) => { return post<{ service_id: string; name: string; - }>(`${MCP_BASE_URL}`, params); + }>(`${MCP_BASE_URL}`, params, { 'Content-Type': 'application/json' }); }; const deleteMcpService = (id: string) => { @@ -86,6 +88,10 @@ const activeMcpService = (id: string, active: boolean) => { return post<{ serviceId: string }>(`${MCP_BASE_URL}/${id}`, { active }); }; +const installMcpService = (id: string) => { + return post<{ serviceId: string }>(`${MCP_BASE_URL}/${id}/install`); +}; + // 定义一个名为uploadMcpIcon的函数,接收两个参数serviceId和icon const uploadMcpIcon = (params: { serviceId: string; @@ -96,7 +102,7 @@ const uploadMcpIcon = (params: { formData.append('icon', params.icon); // 使用post方法向MCP_BASE_URL/${id}发送请求,请求体为{ icon: params.icon } return post<{ icon: string }>( - `${MCP_BASE_URL}`, + `${MCP_BASE_URL}/icon/${params.serviceId}`, formData, { serviceId: params.serviceId, @@ -111,5 +117,6 @@ export const mcpApi = { createOrUpdateMcpService, deleteMcpService, activeMcpService, + installMcpService, uploadMcpIcon }; diff --git a/src/assets/svgs/warning.svg b/src/assets/svgs/warning.svg new file mode 100644 index 00000000..71554801 --- /dev/null +++ b/src/assets/svgs/warning.svg @@ -0,0 +1,8 @@ + + + Created with Pixso. + + + + + diff --git a/src/views/api/components/McpDrawer.vue b/src/views/api/components/McpDrawer.vue index a44eff4a..ccf2060d 100644 --- a/src/views/api/components/McpDrawer.vue +++ b/src/views/api/components/McpDrawer.vue @@ -149,7 +149,7 @@ async function onConfirm(formEl: FormInstance | undefined) { icon: form.icon, name: form.name, description: form.description, - config: form.mcpConfig, + config: JSON.parse(form.mcpConfig), mcpType: form.type, }); diff --git a/src/views/api/components/PluginCard.vue b/src/views/api/components/PluginCard.vue index 1ae57c95..a39ac291 100644 --- a/src/views/api/components/PluginCard.vue +++ b/src/views/api/components/PluginCard.vue @@ -54,6 +54,7 @@ const props = defineProps(); display: flex; flex-direction: column; gap: 4px; + width: 70%; &__top { min-height: 24px; @@ -66,7 +67,7 @@ const props = defineProps(); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; - width: 80%; + width: 70%; font-weight: 700; } } diff --git a/src/views/api/index.vue b/src/views/api/index.vue index a566f503..00c3a330 100644 --- a/src/views/api/index.vue +++ b/src/views/api/index.vue @@ -103,6 +103,30 @@ :lazy="true" > + + + + +
+
-
+ +
{{ t('plugin_center.mcp.install_failed') }}
+ +
+ +
+ {{ t('plugin_center.mcp.install_success') }} +
+
+ +
+ +
+ {{ t('plugin_center.mcp.not_installed') }} +
+