Jelajahi Sumber

fix: 修改mcp选项接口

jiaxing.liao 1 Minggu lalu
induk
melakukan
de879c71f2

+ 3 - 3
apps/web/src/views/agent/components/EditModal.vue

@@ -1534,10 +1534,10 @@ async function searchMcpServices(keyword: string) {
 	if (res?.isSuccess) {
 		mcpServiceOptions.value = mergeOptions(
 			mcpServiceOptions.value,
-			((res.result || []) as McpItem[])
-				.filter((item): item is McpItem & { id: string } => !!item.id)
+			(res.result || [])
+				.filter((item) => !!item.id)
 				.map((item) => ({
-					label: item.name || item.id,
+					label: item.name || '-',
 					value: item.id
 				})),
 			form.config.setting_config.mcp_services

+ 4 - 8
apps/web/src/views/mcp/index.vue

@@ -106,8 +106,10 @@
 							</div>
 						</div>
 						<div class="badge-row">
-							<span class="badge">{{ row.transport_type || '未设置传输类型' }}</span>
-							<span class="badge subtle">{{ row.enabled ? '启用中' : '已禁用' }}</span>
+							<el-tag :type="row.enabled ? 'success' : 'warining'" class="badge subtle">{{
+								row.enabled ? '启用中' : '已禁用'
+							}}</el-tag>
+							<el-tag class="badge">{{ row.transport_type || '未设置传输类型' }}</el-tag>
 						</div>
 					</div>
 
@@ -873,12 +875,6 @@ onMounted(() => {
 	border: 1px solid var(--border-light);
 }
 
-.badge.subtle {
-	background: var(--text-strong);
-	color: var(--bg-base);
-	border-color: transparent;
-}
-
 .desc {
 	min-height: 44px;
 	color: var(--text-secondary);

+ 38 - 148
packages/api-service/schema/resource.openapi.json

@@ -3511,7 +3511,7 @@
 		},
 		"/api/ai/mcp/selectList": {
 			"post": {
-				"summary": "获取mcp选择列表",
+				"summary": "MCP选择列表",
 				"deprecated": false,
 				"description": "",
 				"tags": ["resource"],
@@ -3520,10 +3520,9 @@
 						"name": "Authorization",
 						"in": "header",
 						"description": "",
-						"example": "bpm_client_1513029045627916288",
+						"example": "bpm_client_1521524767180460032",
 						"schema": {
-							"type": "string",
-							"default": "bpm_client_1513029045627916288"
+							"type": "string"
 						}
 					}
 				],
@@ -3537,13 +3536,10 @@
 										"type": "string"
 									}
 								},
-								"required": []
+								"required": ["keyword"]
 							},
 							"example": {
-								"keyword": "",
-								"transport_type": "",
-								"pageIndex": 1,
-								"pageSize": 20
+								"keyword": ""
 							}
 						}
 					},
@@ -3564,113 +3560,19 @@
 											"type": "integer"
 										},
 										"result": {
-											"type": "object",
-											"properties": {
-												"currentPage": {
-													"type": "integer"
-												},
-												"hasNextPage": {
-													"type": "boolean"
-												},
-												"hasPreviousPage": {
-													"type": "boolean"
-												},
-												"model": {
-													"type": "array",
-													"items": {
-														"type": "object",
-														"properties": {
-															"advanced_config": {
-																"type": "object",
-																"properties": {
-																	"retry_count": {
-																		"type": "integer"
-																	},
-																	"retry_delay": {
-																		"type": "integer"
-																	},
-																	"timeout": {
-																		"type": "integer"
-																	}
-																},
-																"required": ["retry_count", "retry_delay", "timeout"]
-															},
-															"auth_config": {
-																"type": "object",
-																"properties": {}
-															},
-															"creationTime": {
-																"type": "string"
-															},
-															"creatorUserId": {
-																"type": "string"
-															},
-															"description": {
-																"type": "string"
-															},
-															"enabled": {
-																"type": "boolean"
-															},
-															"env_vars": {
-																"type": "object",
-																"properties": {}
-															},
-															"headers": {
-																"type": "object",
-																"properties": {}
-															},
-															"id": {
-																"type": "string"
-															},
-															"isDeleted": {
-																"type": "boolean"
-															},
-															"is_builtin": {
-																"type": "boolean"
-															},
-															"name": {
-																"type": "string"
-															},
-															"stdio_config": {
-																"type": "object",
-																"properties": {
-																	"command": {
-																		"type": "string"
-																	}
-																},
-																"required": ["command"]
-															},
-															"transport_type": {
-																"type": "string"
-															},
-															"updateTime": {
-																"type": "string"
-															},
-															"url": {
-																"type": "string"
-															}
-														}
+											"type": "array",
+											"items": {
+												"type": "object",
+												"properties": {
+													"id": {
+														"type": "string"
+													},
+													"name": {
+														"type": "string"
 													}
 												},
-												"pageSize": {
-													"type": "integer"
-												},
-												"totalCount": {
-													"type": "integer"
-												},
-												"totalPages": {
-													"type": "integer"
-												}
-											},
-											"required": [
-												"currentPage",
-												"hasNextPage",
-												"hasPreviousPage",
-												"model",
-												"pageSize",
-												"totalCount",
-												"totalPages"
-											]
+												"required": ["id", "name"]
+											}
 										},
 										"isAuthorized": {
 											"type": "boolean"
@@ -3681,40 +3583,28 @@
 								"example": {
 									"isSuccess": true,
 									"code": 1,
-									"result": {
-										"currentPage": 1,
-										"hasNextPage": true,
-										"hasPreviousPage": false,
-										"model": [
-											{
-												"advanced_config": {
-													"retry_count": 3,
-													"retry_delay": 1,
-													"timeout": 30
-												},
-												"auth_config": {},
-												"creationTime": "2026-05-15 16:51:27",
-												"creatorUserId": "7F8A2BFE-402D-4499-9BB8-2EF7FFC7B993",
-												"description": "沙鲁的MCP服务",
-												"enabled": false,
-												"env_vars": {},
-												"headers": {},
-												"id": "da3f6fb2-171b-434a-976f-be2260b3f0dc",
-												"isDeleted": false,
-												"is_builtin": false,
-												"name": "新的MCP",
-												"stdio_config": {
-													"command": ""
-												},
-												"transport_type": "http-streamable",
-												"updateTime": "2026-05-15 16:51:27",
-												"url": "http://shalu-componenttesting-c-dev.shalu.com/api/mcp/account"
-											}
-										],
-										"pageSize": 20,
-										"totalCount": 1,
-										"totalPages": 1
-									},
+									"result": [
+										{
+											"id": "1ebd8255-f326-44bb-9270-9d1e9d3b4b1a",
+											"name": "业务表操作工具"
+										},
+										{
+											"id": "0eff85f9-35e0-4244-a22f-fe222eb8afab",
+											"name": "流程工具"
+										},
+										{
+											"id": "961c47f7-42dc-4135-bdc6-689ee736f12c",
+											"name": "视图数据工具"
+										},
+										{
+											"id": "4d8faa4a-db87-4044-b8f6-b3bafadc291b",
+											"name": "基础数据工具"
+										},
+										{
+											"id": "c0f5ff81-983b-4733-ac19-ac42b9f6c52d",
+											"name": "账户工具"
+										}
+									],
 									"isAuthorized": true
 								}
 							}

+ 3 - 28
packages/api-service/servers/resource/api/resource.ts

@@ -199,42 +199,17 @@ export async function postMcpResources(
   )
 }
 
-/** 获取mcp选择列表 POST /api/ai/mcp/selectList */
+/** MCP选择列表 POST /api/ai/mcp/selectList */
 export async function postMcpSelectList(
   body: {
-    keyword?: string
+    keyword: string
   },
   options?: { [key: string]: any }
 ) {
   return request<{
     isSuccess: boolean
     code: number
-    result: {
-      currentPage: number
-      hasNextPage: boolean
-      hasPreviousPage: boolean
-      model: {
-        advanced_config: { retry_count: number; retry_delay: number; timeout: number }
-        auth_config?: Record<string, any>
-        creationTime?: string
-        creatorUserId?: string
-        description?: string
-        enabled?: boolean
-        env_vars?: Record<string, any>
-        headers?: Record<string, any>
-        id?: string
-        isDeleted?: boolean
-        is_builtin?: boolean
-        name?: string
-        stdio_config: { command: string }
-        transport_type?: string
-        updateTime?: string
-        url?: string
-      }[]
-      pageSize: number
-      totalCount: number
-      totalPages: number
-    }
+    result: { id: string; name: string }[]
     isAuthorized: boolean
   }>('/api/ai/mcp/selectList', {
     method: 'POST',