Skip to content

Open-source SEO, GEO, and marketing skills for AI agents.

feat(connections): open connector browser directly

Yuting Zhong6ac4f198e97c
diff --git a/notfair/src/components/add-mcp-server-card.test.tsx b/notfair/src/components/add-mcp-server-card.test.tsx
index af9a3981..7fac6dc6 100644
--- a/notfair/src/components/add-mcp-server-card.test.tsx
+++ b/notfair/src/components/add-mcp-server-card.test.tsx
@@ -27,25 +27,24 @@ beforeEach(() => {
vi.clearAllMocks();
});
-function openMenu() {
- fireEvent.keyDown(screen.getByRole("button", { name: /add server/i }), {
- key: "Enter",
- });
+function openBrowser() {
+ fireEvent.click(screen.getByRole("button", { name: /add server/i }));
}
describe("AddMcpServerMenu", () => {
- it("offers Browse and Custom paths from the default trigger", () => {
+ it("opens Browse connectors directly from the default trigger", () => {
render(<AddMcpServerMenu />);
- openMenu();
+ openBrowser();
expect(
- screen.getByRole("menuitem", { name: /browse connectors/i }),
+ screen.getByRole("heading", { name: "Browse connectors" }),
).toBeInTheDocument();
expect(
- screen.getByRole("menuitem", { name: /add custom connector/i }),
+ screen.getByRole("button", { name: /add custom connector/i }),
).toBeInTheDocument();
+ expect(screen.queryByRole("menu")).toBeNull();
});
- it("renders a custom trigger node instead of the default pill", () => {
+ it("opens Browse connectors directly from a custom trigger", () => {
render(
<AddMcpServerMenu
trigger={<button type="button">More tools</button>}
@@ -53,24 +52,17 @@ describe("AddMcpServerMenu", () => {
);
expect(screen.getByRole("button", { name: "More tools" })).toBeInTheDocument();
expect(screen.queryByRole("button", { name: /add server/i })).toBeNull();
- });
-
- it("opens the Browse connectors grid from the menu", async () => {
- render(<AddMcpServerMenu />);
- openMenu();
- fireEvent.click(screen.getByRole("menuitem", { name: /browse connectors/i }));
+ fireEvent.click(screen.getByRole("button", { name: "More tools" }));
expect(
- await screen.findByRole("heading", { name: "Browse connectors" }),
+ screen.getByRole("heading", { name: "Browse connectors" }),
).toBeInTheDocument();
});
it("adds a custom OAuth connector and refreshes on success", async () => {
addServer.mockResolvedValue({ ok: true, key: "stripe" });
render(<AddMcpServerMenu />);
- openMenu();
- fireEvent.click(
- screen.getByRole("menuitem", { name: /add custom connector/i }),
- );
+ openBrowser();
+ fireEvent.click(screen.getByRole("button", { name: /add custom connector/i }));
fireEvent.change(await screen.findByLabelText("Name"), {
target: { value: "Stripe" },
});
@@ -94,10 +86,8 @@ describe("AddMcpServerMenu", () => {
it("shows the probe failure inline and keeps the dialog open", async () => {
addServer.mockResolvedValue({ ok: false, error: "No OAuth discovery." });
render(<AddMcpServerMenu />);
- openMenu();
- fireEvent.click(
- screen.getByRole("menuitem", { name: /add custom connector/i }),
- );
+ openBrowser();
+ fireEvent.click(screen.getByRole("button", { name: /add custom connector/i }));
fireEvent.change(await screen.findByLabelText("Name"), {
target: { value: "Broken" },
});
diff --git a/notfair/src/components/add-mcp-server-card.tsx b/notfair/src/components/add-mcp-server-card.tsx
index 59d463ab..3a6e10c3 100644
--- a/notfair/src/components/add-mcp-server-card.tsx
+++ b/notfair/src/components/add-mcp-server-card.tsx
@@ -1,8 +1,9 @@
"use client";
-import { type ReactNode, useState } from "react";
+import { type ReactElement, useState } from "react";
import { useRouter } from "next/navigation";
-import { Plus, Loader2, BookOpenText, MoreHorizontal } from "lucide-react";
+import { Plus, Loader2 } from "lucide-react";
+import { Slot } from "radix-ui";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -15,19 +16,13 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuTrigger,
-} from "@/components/ui/dropdown-menu";
import { toast } from "sonner";
import { addUserMcpServerAction } from "@/server/actions/mcp";
import { BrowseConnectorsDialog } from "@/components/browse-connectors-dialog";
/**
- * "Add server" dropdown trigger for the Connections page header. Two
- * paths:
+ * "Add server" trigger for the Connections page header. It opens the
+ * connector browser directly, where users can choose either path:
*
* - **Browse connectors** → curated grid of trusted MCPs (Stripe,
* PostHog, NotFair, etc.). Click adds it to this project via the
@@ -44,7 +39,6 @@ export function AddMcpServerMenu({
connectedResourceUrls = [],
hideKeys = [],
trigger,
- align = "end",
}: {
/** Catalog keys whose runtime status is `connected`. Browse tiles for
* these are filtered out of the grid entirely. */
@@ -61,51 +55,25 @@ export function AddMcpServerMenu({
* "Add server" button used by the Connections page header. Pass a
* custom button-shaped node when slotting this into a list row,
* grouped list, or other in-line surface. */
- trigger?: ReactNode;
- /** Radix `align` for the dropdown content. */
- align?: "start" | "center" | "end";
+ trigger?: ReactElement;
}) {
const [browseOpen, setBrowseOpen] = useState(false);
const [customOpen, setCustomOpen] = useState(false);
return (
<>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- {trigger ?? (
- <button type="button" className="ns-btn ns-btn-primary">
- <Plus className="size-3.5" />
- Add server
- </button>
- )}
- </DropdownMenuTrigger>
- <DropdownMenuContent align={align} className="w-60">
- <DropdownMenuItem
- onSelect={() => setBrowseOpen(true)}
- className="gap-2 py-2.5"
- >
- <BookOpenText className="size-4 text-muted-foreground" />
- <div className="flex flex-col">
- <span className="text-sm">Browse connectors</span>
- <span className="text-[11px] text-muted-foreground">
- Stripe, PostHog, and more
- </span>
- </div>
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={() => setCustomOpen(true)}
- className="gap-2 py-2.5"
- >
- <MoreHorizontal className="size-4 text-muted-foreground" />
- <div className="flex flex-col">
- <span className="text-sm">Add custom connector</span>
- <span className="text-[11px] text-muted-foreground">
- Paste an OAuth 2.0 MCP URL
- </span>
- </div>
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ {trigger ? (
+ <Slot.Root onClick={() => setBrowseOpen(true)}>{trigger}</Slot.Root>
+ ) : (
+ <button
+ type="button"
+ className="ns-btn ns-btn-primary"
+ onClick={() => setBrowseOpen(true)}
+ >
+ <Plus className="size-3.5" />
+ Add server
+ </button>
+ )}
<BrowseConnectorsDialog
open={browseOpen}
@@ -113,6 +81,10 @@ export function AddMcpServerMenu({
connectedKeys={connectedKeys}
connectedResourceUrls={connectedResourceUrls}
hideKeys={hideKeys}
+ onAddCustom={() => {
+ setBrowseOpen(false);
+ setCustomOpen(true);
+ }}
/>
<CustomConnectorDialog open={customOpen} onOpenChange={setCustomOpen} />
</>
diff --git a/notfair/src/components/browse-connectors-dialog.test.tsx b/notfair/src/components/browse-connectors-dialog.test.tsx
index 2f163d19..91546796 100644
--- a/notfair/src/components/browse-connectors-dialog.test.tsx
+++ b/notfair/src/components/browse-connectors-dialog.test.tsx
@@ -31,7 +31,13 @@ const ALL_IDS = TRUSTED_CONNECTORS.map((c) => c.id);
describe("BrowseConnectorsDialog", () => {
it("lists every trusted connector that is not yet connected", () => {
- render(<BrowseConnectorsDialog open onOpenChange={vi.fn()} />);
+ render(
+ <BrowseConnectorsDialog
+ open
+ onOpenChange={vi.fn()}
+ onAddCustom={vi.fn()}
+ />,
+ );
expect(screen.getByText("NotFair Google Ads")).toBeInTheDocument();
expect(screen.getByText("Stripe")).toBeInTheDocument();
});
@@ -41,6 +47,7 @@ describe("BrowseConnectorsDialog", () => {
<BrowseConnectorsDialog
open
onOpenChange={vi.fn()}
+ onAddCustom={vi.fn()}
connectedKeys={["notfair-googleads"]}
// Trailing slash + uppercase host still match after normalization.
connectedResourceUrls={["https://mcp.stripe.com"]}
@@ -56,12 +63,39 @@ describe("BrowseConnectorsDialog", () => {
<BrowseConnectorsDialog
open
onOpenChange={vi.fn()}
+ onAddCustom={vi.fn()}
hideKeys={ALL_IDS}
/>,
);
expect(
screen.getByText("All available connectors are already connected."),
).toBeInTheDocument();
+ expect(
+ screen.getByRole("button", { name: /add custom connector/i }),
+ ).toBeInTheDocument();
+ });
+
+ it("renders the custom connector path after the trusted connectors", () => {
+ const onAddCustom = vi.fn();
+ render(
+ <BrowseConnectorsDialog
+ open
+ onOpenChange={vi.fn()}
+ onAddCustom={onAddCustom}
+ />,
+ );
+
+ const stripe = screen.getByRole("button", { name: /Stripe/ });
+ const custom = screen.getByRole("button", {
+ name: /add custom connector/i,
+ });
+ expect(
+ stripe.compareDocumentPosition(custom) & Node.DOCUMENT_POSITION_FOLLOWING,
+ ).toBeTruthy();
+ expect(screen.getByText("Paste an OAuth 2.0 MCP URL")).toBeInTheDocument();
+
+ fireEvent.click(custom);
+ expect(onAddCustom).toHaveBeenCalledOnce();
});
it("adds with the canonical key and passes return_to into OAuth", async () => {
@@ -69,7 +103,13 @@ describe("BrowseConnectorsDialog", () => {
// Fail the connect step so the test never assigns window.location.href.
startConnect.mockResolvedValue({ ok: false, error: "issuer down" });
const onOpenChange = vi.fn();
- render(<BrowseConnectorsDialog open onOpenChange={onOpenChange} />);
+ render(
+ <BrowseConnectorsDialog
+ open
+ onOpenChange={onOpenChange}
+ onAddCustom={vi.fn()}
+ />,
+ );
fireEvent.click(
screen.getByRole("button", { name: /NotFair Google Ads/ }),
@@ -92,7 +132,13 @@ describe("BrowseConnectorsDialog", () => {
addServer.mockResolvedValue({ ok: true, key: "notfair-googleads" });
startConnect.mockResolvedValue({ ok: false, error: "issuer down" });
const onOpenChange = vi.fn();
- render(<BrowseConnectorsDialog open onOpenChange={onOpenChange} />);
+ render(
+ <BrowseConnectorsDialog
+ open
+ onOpenChange={onOpenChange}
+ onAddCustom={vi.fn()}
+ />,
+ );
fireEvent.click(
screen.getByRole("button", { name: /NotFair Google Ads/ }),
@@ -109,7 +155,13 @@ describe("BrowseConnectorsDialog", () => {
it("surfaces an add failure without starting OAuth", async () => {
addServer.mockResolvedValue({ ok: false, error: "probe failed" });
- render(<BrowseConnectorsDialog open onOpenChange={vi.fn()} />);
+ render(
+ <BrowseConnectorsDialog
+ open
+ onOpenChange={vi.fn()}
+ onAddCustom={vi.fn()}
+ />,
+ );
fireEvent.click(screen.getByRole("button", { name: /Stripe/ }));
diff --git a/notfair/src/components/browse-connectors-dialog.tsx b/notfair/src/components/browse-connectors-dialog.tsx
index 94dbd476..145e6294 100644
--- a/notfair/src/components/browse-connectors-dialog.tsx
+++ b/notfair/src/components/browse-connectors-dialog.tsx
@@ -2,7 +2,7 @@
import { useState, useTransition } from "react";
import { useRouter } from "next/navigation";
-import { Loader2 } from "lucide-react";
+import { Loader2, Plus } from "lucide-react";
import {
Dialog,
@@ -39,6 +39,9 @@ type Props = {
* dialog would render duplicates of the tiles the user already sees.
*/
hideKeys?: string[];
+ /** Opens the custom MCP URL flow. This is always the final option in the
+ * connector grid, including when every trusted connector is connected. */
+ onAddCustom: () => void;
};
/**
@@ -59,6 +62,7 @@ export function BrowseConnectorsDialog({
connectedKeys = [],
connectedResourceUrls = [],
hideKeys = [],
+ onAddCustom,
}: Props) {
const connectedKeySet = new Set(connectedKeys);
const connectedUrlSet = new Set(connectedResourceUrls);
@@ -79,21 +83,38 @@ export function BrowseConnectorsDialog({
flow in one step.
</DialogDescription>
</DialogHeader>
- {availableConnectors.length === 0 ? (
- <p className="py-8 text-center text-sm text-muted-foreground">
- All available connectors are already connected.
- </p>
- ) : (
- <div className="grid grid-cols-1 gap-2 sm:grid-cols-2">
- {availableConnectors.map((c) => (
+ <div className="grid grid-cols-1 gap-2 sm:grid-cols-2">
+ {availableConnectors.length === 0 ? (
+ <p className="py-8 text-center text-sm text-muted-foreground sm:col-span-2">
+ All available connectors are already connected.
+ </p>
+ ) : (
+ availableConnectors.map((c) => (
<ConnectorTile
key={c.id}
connector={c}
onAdded={() => onOpenChange(false)}
/>
- ))}
- </div>
- )}
+ ))
+ )}
+ <button
+ type="button"
+ onClick={onAddCustom}
+ className="flex items-start gap-3 rounded-md border border-dashed border-border bg-muted/20 p-3 text-left transition-colors hover:bg-muted/50 sm:col-span-2"
+ >
+ <span className="flex size-10 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground">
+ <Plus className="size-5" />
+ </span>
+ <span className="min-w-0 flex-1">
+ <span className="block text-sm font-medium">
+ Add custom connector
+ </span>
+ <span className="mt-0.5 block text-xs text-muted-foreground">
+ Paste an OAuth 2.0 MCP URL
+ </span>
+ </span>
+ </button>
+ </div>
</DialogContent>
</Dialog>
);
diff --git a/notfair/src/components/onboarding-flow.tsx b/notfair/src/components/onboarding-flow.tsx
index 360cdfa5..d821f8c1 100644
--- a/notfair/src/components/onboarding-flow.tsx
+++ b/notfair/src/components/onboarding-flow.tsx
@@ -534,12 +534,10 @@ function ConnectStep({
</li>
))}
<li>
- {/* Reuse the connections-page Add-MCP menu so onboarding gets the
- same Browse + Custom paths. The trigger is a tile-shaped
- button so it sits naturally as the last row of the grouped
- list; the dropdown opens from there. */}
+ {/* Reuse the connections-page Add-MCP flow so onboarding gets the
+ same connector browser and final custom-connector option. The
+ trigger is tile-shaped so it sits naturally as the last row. */}
<AddMcpServerMenu
- align="start"
// Hide the always-visible recommended MCPs from Browse — they
// each have their own row above already.
hideKeys={RECOMMENDED_MCP_KEYS}