diff --git a/surfsense_web/components/assistant-ui/connector-popup.tsx b/surfsense_web/components/assistant-ui/connector-popup.tsx index 28fe5b5b0..01670f3fd 100644 --- a/surfsense_web/components/assistant-ui/connector-popup.tsx +++ b/surfsense_web/components/assistant-ui/connector-popup.tsx @@ -156,7 +156,15 @@ export const ConnectorIndicator: FC = () => { const hasConnectors = connectors.length > 0; const hasSources = hasConnectors || activeDocumentTypes.length > 0; const totalSourceCount = connectors.length + activeDocumentTypes.length; - const activeConnectorsCount = connectors.length; // Only actual connectors, not document types + + // Count connectors properly: for MCP, count each server; for others, count connectors + const activeConnectorsCount = connectors.reduce((total, c: SearchSourceConnector) => { + if (c.connector_type === "MCP_CONNECTOR") { + const serverConfigs = c.config?.server_configs; + return total + (Array.isArray(serverConfigs) ? serverConfigs.length : 0); + } + return total + 1; + }, 0); // Check which connectors are already connected const connectedTypes = new Set( diff --git a/surfsense_web/components/assistant-ui/connector-popup/tabs/active-connectors-tab.tsx b/surfsense_web/components/assistant-ui/connector-popup/tabs/active-connectors-tab.tsx index 1b1c3ea4d..a095a1fe5 100644 --- a/surfsense_web/components/assistant-ui/connector-popup/tabs/active-connectors-tab.tsx +++ b/surfsense_web/components/assistant-ui/connector-popup/tabs/active-connectors-tab.tsx @@ -218,7 +218,14 @@ export const ActiveConnectorsTab: FC = ({ connectorType, documentTypeCounts ); - const accountCount = typeConnectors.length; + // Calculate account count - for MCP, count servers; for others, count connectors + const accountCount = + connectorType === "MCP_CONNECTOR" + ? typeConnectors.reduce((total, c) => { + const serverConfigs = c.config?.server_configs; + return total + (Array.isArray(serverConfigs) ? serverConfigs.length : 0); + }, 0) + : typeConnectors.length; const mostRecentLastIndexed = getMostRecentLastIndexed(typeConnectors); const handleManageClick = () => { diff --git a/surfsense_web/components/assistant-ui/connector-popup/tabs/all-connectors-tab.tsx b/surfsense_web/components/assistant-ui/connector-popup/tabs/all-connectors-tab.tsx index 6129b49b7..a51b7d26a 100644 --- a/surfsense_web/components/assistant-ui/connector-popup/tabs/all-connectors-tab.tsx +++ b/surfsense_web/components/assistant-ui/connector-popup/tabs/all-connectors-tab.tsx @@ -103,6 +103,15 @@ export const AllConnectorsTab: FC = ({ ) : []; + // Calculate account count - for MCP, count servers; for others, count connectors + const accountCount = + connector.connectorType === "MCP_CONNECTOR" + ? typeConnectors.reduce((total, c) => { + const serverConfigs = c.config?.server_configs; + return total + (Array.isArray(serverConfigs) ? serverConfigs.length : 0); + }, 0) + : typeConnectors.length; + // Get the most recent last_indexed_at across all accounts const mostRecentLastIndexed = typeConnectors.reduce( (latest, c) => { @@ -138,7 +147,7 @@ export const AllConnectorsTab: FC = ({ isConnected={isConnected} isConnecting={isConnecting} documentCount={documentCount} - accountCount={typeConnectors.length} + accountCount={accountCount} lastIndexedAt={mostRecentLastIndexed} isIndexing={isIndexing} activeTask={activeTask}