From 72ad558240e105f4b409212e7ec9a3ffadbfb516 Mon Sep 17 00:00:00 2001
From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com>
Date: Mon, 19 Jan 2026 19:50:07 +0530
Subject: [PATCH] refactor: consolidate MCP connector handling in UI components
- Replaced MCPConnectorListView with ConnectorAccountsListView for better integration and UI consistency.
- Updated ConnectorCard to display connector counts for MCP connectors.
- Enhanced MCPConnectForm to improve connection testing feedback and error handling.
- Streamlined MCPConfig validation logic and improved user feedback for configuration errors.
- Adjusted AllConnectorsTab to count and display MCP connectors accurately.
- Removed redundant MCP-specific components to simplify the codebase.
---
.../assistant-ui/connector-popup.tsx | 23 ++-
.../components/connector-card.tsx | 24 ++-
.../components/mcp-connect-form.tsx | 96 +++---------
.../components/mcp-config.tsx | 69 +++++----
.../views/connector-edit-view.tsx | 2 +-
.../hooks/use-connector-dialog.ts | 4 +-
.../tabs/all-connectors-tab.tsx | 9 +-
.../utils/mcp-config-validator.ts | 17 +-
.../views/connector-accounts-list-view.tsx | 49 +++++-
.../views/mcp-connector-list-view.tsx | 145 ------------------
10 files changed, 148 insertions(+), 290 deletions(-)
delete mode 100644 surfsense_web/components/assistant-ui/connector-popup/views/mcp-connector-list-view.tsx
diff --git a/surfsense_web/components/assistant-ui/connector-popup.tsx b/surfsense_web/components/assistant-ui/connector-popup.tsx
index 90113707e..a366bd37f 100644
--- a/surfsense_web/components/assistant-ui/connector-popup.tsx
+++ b/surfsense_web/components/assistant-ui/connector-popup.tsx
@@ -22,7 +22,6 @@ import { useIndexingConnectors } from "./connector-popup/hooks/use-indexing-conn
import { ActiveConnectorsTab } from "./connector-popup/tabs/active-connectors-tab";
import { AllConnectorsTab } from "./connector-popup/tabs/all-connectors-tab";
import { ConnectorAccountsListView } from "./connector-popup/views/connector-accounts-list-view";
-import { MCPConnectorListView } from "./connector-popup/views/mcp-connector-list-view";
import { YouTubeCrawlerView } from "./connector-popup/views/youtube-crawler-view";
export const ConnectorIndicator: FC = () => {
@@ -177,18 +176,16 @@ export const ConnectorIndicator: FC = () => {
{isYouTubeView && searchSpaceId ? (
- {formatDocumentCount(documentCount)} - {accountCount !== undefined && accountCount > 0 && ( + {isMCP && connectorCount !== undefined ? ( + + {connectorCount} {connectorCount === 1 ? "server" : "servers"} + + ) : ( <> - • - - {accountCount} {accountCount === 1 ? "Account" : "Accounts"} - + {formatDocumentCount(documentCount)} + {accountCount !== undefined && accountCount > 0 && ( + <> + • + + {accountCount} {accountCount === 1 ? "Account" : "Accounts"} + + > + )} > )}
diff --git a/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/mcp-connect-form.tsx b/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/mcp-connect-form.tsx index 68ec12610..17c6245bd 100644 --- a/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/mcp-connect-form.tsx +++ b/surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/mcp-connect-form.tsx @@ -1,20 +1,18 @@ "use client"; -import { CheckCircle2, ChevronDown, ChevronUp, Server, XCircle } from "lucide-react"; +import { Server } from "lucide-react"; import { type FC, useRef, useState } from "react"; -import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import { toast } from "sonner"; +import { Alert, AlertDescription } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import { EnumConnectorName } from "@/contracts/enums/connector"; -import type { MCPToolDefinition } from "@/contracts/types/mcp.types"; import type { ConnectFormProps } from ".."; import { extractServerName, parseMCPConfig, testMCPConnection, - type MCPConnectionTestResult, } from "../../utils/mcp-config-validator"; export const MCPConnectForm: FCJSON Error: {jsonError}
+{jsonError}
)}
Paste a single MCP server configuration. Must include: name, command, args (optional), env (optional), transport (optional).
@@ -158,72 +161,9 @@ export const MCPConnectForm: FC
- Available tools:
-
+ A friendly name to identify this connector.
+
Manage your connector settings and sync configuration
diff --git a/surfsense_web/components/assistant-ui/connector-popup/hooks/use-connector-dialog.ts b/surfsense_web/components/assistant-ui/connector-popup/hooks/use-connector-dialog.ts
index 7ac0d3e0f..b7fb9880a 100644
--- a/surfsense_web/components/assistant-ui/connector-popup/hooks/use-connector-dialog.ts
+++ b/surfsense_web/components/assistant-ui/connector-popup/hooks/use-connector-dialog.ts
@@ -645,7 +645,7 @@ export const useConnectorDialog = () => {
});
const successMessage = currentConnectorType === "MCP_CONNECTOR"
- ? `${connector.name} MCP server added successfully`
+ ? `${connector.name} added successfully`
: `${connectorTitle} connected and indexing started!`;
toast.success(successMessage, {
description: periodicEnabledForIndexing
@@ -709,7 +709,7 @@ export const useConnectorDialog = () => {
} else {
// Other non-indexable connectors - just show success message and close
const successMessage = currentConnectorType === "MCP_CONNECTOR"
- ? `${connector.name} MCP server added successfully`
+ ? `${connector.name} added successfully`
: `${connectorTitle} connected successfully!`;
toast.success(successMessage);
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 d358037c2..260d6c926 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
@@ -1,6 +1,7 @@
"use client";
import type { FC } from "react";
+import { EnumConnectorName } from "@/contracts/enums/connector";
import type { SearchSourceConnector } from "@/contracts/types/connector.types";
import { ConnectorCard } from "../components/connector-card";
import { CRAWLERS, OAUTH_CONNECTORS, OTHER_CONNECTORS } from "../constants/connector-constants";
@@ -162,6 +163,12 @@ export const AllConnectorsTab: FC
+ {isMCP
+ ? "Get started by adding your first Model Context Protocol server"
+ : `Get started by connecting your first ${connectorTitle} account`}
+
- {getConnectorDisplayName(connector.name)}
+ {getDisplayName(connector)}
@@ -193,7 +229,8 @@ export const ConnectorAccountsListView: FC
- Manage your Model Context Protocol servers
-
- Get started by adding your first Model Context Protocol server
-
- {serverName}
-
- {testResult.tools.map((tool, i) => (
-
-
- {testResult.tools.map((tool, i) => (
-
- {connector.connector_type === "MCP_CONNECTOR" ? "MCP Server" : connector.name}
+ {connector.name}
+ {isMCP ? "No MCP Servers" : `No ${connectorTitle} Accounts`}
+
+ MCP Connectors
- No MCP Servers
-