فهرست منبع

feat: Display the number of clients instead of the number of available tools.

Kadxy 10 ماه پیش
والد
کامیت
be59de56f0
2فایلهای تغییر یافته به همراه3 افزوده شده و 19 حذف شده
  1. 2 14
      app/components/mcp-market.tsx
  2. 1 5
      app/mcp/actions.ts

+ 2 - 14
app/components/mcp-market.tsx

@@ -61,16 +61,6 @@ export function McpMarketPage() {
     return id in (config?.mcpServers ?? {});
   };
 
-  // 获取客户端状态
-  const updateClientStatus = async (clientId: string) => {
-    const status = await getClientStatus(clientId);
-    setClientStatuses((prev) => ({
-      ...prev,
-      [clientId]: status,
-    }));
-    return status;
-  };
-
   // 从服务器获取初始状态
   useEffect(() => {
     const loadInitialState = async () => {
@@ -82,8 +72,7 @@ export function McpMarketPage() {
         // 获取所有客户端的状态
         const statuses: Record<string, any> = {};
         for (const clientId of Object.keys(config.mcpServers)) {
-          const status = await getClientStatus(clientId);
-          statuses[clientId] = status;
+          statuses[clientId] = await getClientStatus(clientId);
         }
         setClientStatuses(statuses);
       } catch (error) {
@@ -220,8 +209,7 @@ export function McpMarketPage() {
       // 更新所有客户端状态
       const statuses: Record<string, any> = {};
       for (const clientId of Object.keys(newConfig.mcpServers)) {
-        const status = await getClientStatus(clientId);
-        statuses[clientId] = status;
+        statuses[clientId] = await getClientStatus(clientId);
       }
       setClientStatuses(statuses);
 

+ 1 - 5
app/mcp/actions.ts

@@ -40,11 +40,7 @@ export async function getClientTools(clientId: string) {
 // 获取可用客户端数量
 export async function getAvailableClientsCount() {
   let count = 0;
-  clientsMap.forEach((map) => {
-    if (!map.errorMsg) {
-      count += map?.tools?.tools?.length ?? 0;
-    }
-  });
+  clientsMap.forEach((map) => !map.errorMsg && count++);
   return count;
 }