Skip to content

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

feat(notfair-cmo): browse connectors + connections redesign (0.4.0)

Yuting Zhongdf867726d48f
diff --git a/notfair-cmo/CHANGELOG.md b/notfair-cmo/CHANGELOG.md
index ad81b2a8..af139a4e 100644
--- a/notfair-cmo/CHANGELOG.md
+++ b/notfair-cmo/CHANGELOG.md
@@ -1,5 +1,33 @@
# notfair-cmo
+## 0.4.0 — 2026-05-31
+
+Redesigned Connections page + curated "Browse connectors" UX. The catalog now ships with a small directory of trusted MCPs you opt into; clicking a tile adds it to the project and starts OAuth in one step. The page itself was rebuilt as an editorial list with a top-right "Add server" menu.
+
+**Connections page redesign.** Cards became list rows inside a single bordered container; sharper typographic hierarchy (eyebrow + large H1 + mono section labels); status communicated via small colored dot + small-caps mono label instead of pill backgrounds; the "Add server" affordance moved to the header.
+
+**Browse connectors.** New dropdown menu on the header splits "Browse connectors" (curated grid of NotFair Google Ads, NotFair Meta Ads, Stripe, PostHog, Supabase, Mixpanel) and "Add custom connector" (paste-a-URL form). Tile click chains `addUserMcpServerAction` → `startMcpConnect` → browser redirect — no second click. Tiles for connectors already connected in the project render non-clickable with a green "connected" lozenge.
+
+**Preset connectors are now removable.** New migration `012` adds `projects.hidden_mcp_preset_keys_json`. Removing a preset (e.g. NotFair Google Ads) hides it from the project's catalog and clears its token + adapter wiring; re-adding from Browse unhides it.
+
+**OAuth fidelity fixes that shook out during dogfooding:**
+- RFC 8414 §3.1 inserted form for AS metadata. Stripe's issuer `https://access.stripe.com/mcp` only resolves via the inserted variant.
+- `client_secret_post` fallback when an AS doesn't advertise `none` as a token-endpoint auth method (Supabase). DCR registers as a confidential client; the callback already forwards `client_secret` at token exchange.
+- `MCP-Protocol-Version: 2025-06-18` on every JSON-RPC call. Some servers (Supabase) 400 without it.
+- Status probe uses spec-mandated `initialize` instead of `tools/list`. Tool count moves to on-demand fetch via the Tools dialog.
+- `localhost` → `127.0.0.1` normalization on the redirect URI. RFC 8252 §7.3.
+- HTTP-error response body is captured + surfaced in the unreachable message instead of just "HTTP 400".
+- AS-metadata candidate-URL probing (RFC 8414 inserted, OIDC inserted, appended fallbacks).
+
+**Idempotent add + URL-based dedup.** `addUserMcpServerAction` now accepts a canonical `key` override (used by Browse so "NotFair Google Ads" hits the preset key `notfair-googleads` instead of slugifying into a different identifier). The action also detects "this same MCP server URL is already in the project" and returns the existing key instead of writing a duplicate.
+
+**Trusted connectors curated.** Vercel and Supabase were each verified end-to-end:
+- Stripe, PostHog, Mixpanel: kept after URL corrections (most live at `/mcp`, not `/`).
+- Supabase: kept after the `client_secret_post` fallback landed.
+- Vercel: omitted. Their DCR endpoint silently returns a single fixed `client_id` and the authorize endpoint rejects every loopback redirect URI — only their first-party integrations work today.
+
+**New components:** `browse-connectors-dialog`, `mcp-icon` (shared brand favicon via Google's faviconV2 service, subdomain-stripped to the registrable domain), `add-mcp-server-card` (now a `AddMcpServerMenu` dropdown trigger; the custom-URL dialog moved inside).
+
## 0.3.1 — 2026-05-31
User-configurable MCP catalog. The Connections page is no longer limited to the curated preset list — users can register any OAuth-2.0 MCP server (Stripe, Vercel, Supabase, or their own) by pasting a resource URL. The portal probes RFC 9728 protected-resource discovery + RFC 8414 AS metadata before persisting, so only servers that actually support dynamic client registration get past the form.
diff --git a/notfair-cmo/package.json b/notfair-cmo/package.json
index 974c5626..6d835554 100644
--- a/notfair-cmo/package.json
+++ b/notfair-cmo/package.json
@@ -1,6 +1,6 @@
{
"name": "notfair-cmo",
- "version": "0.3.1",
+ "version": "0.4.0",
"description": "Open-source AI marketing CMO portal. Run locally; orchestrates marketing agents (Google Ads, SEO, and more) on top of Claude Code, Codex, or other local AI coding agents.",
"license": "MIT",
"bin": {
diff --git a/notfair-cmo/src/app/(app)/[project]/connections/page.tsx b/notfair-cmo/src/app/(app)/[project]/connections/page.tsx
index ecadaecc..c74e4a98 100644
--- a/notfair-cmo/src/app/(app)/[project]/connections/page.tsx
+++ b/notfair-cmo/src/app/(app)/[project]/connections/page.tsx
@@ -1,5 +1,4 @@
import { notFound } from "next/navigation";
-import { Card, CardContent } from "@/components/ui/card";
import { getProject } from "@/server/db/projects";
import { getMcpCatalog } from "@/server/mcp-catalog";
import { getMcpStatus } from "@/server/mcp/state";
@@ -7,7 +6,8 @@ import { summarizeBuiltinTools } from "@/server/mcp-server/tool-summaries";
import { McpCard } from "@/components/mcp-card";
import { BuiltinMcpCard } from "@/components/builtin-mcp-card";
import { McpFlashBanner } from "@/components/mcp-flash-banner";
-import { AddMcpServerCard } from "@/components/add-mcp-server-card";
+import { AddMcpServerMenu } from "@/components/add-mcp-server-card";
+import { normalizeResourceUrl } from "@/server/mcp/discovery-url";
type Search = { mcp_connected?: string; mcp_error?: string };
@@ -30,47 +30,108 @@ export default async function ConnectionsPage({
catalog.map((s) => getMcpStatus(project.slug, s.key)),
);
- // Built-in MCP: notfair-orchestration ships with the platform and serves
- // every agent without OAuth or setup. We hand its tool summary straight
- // to the card so the tools dialog opens with zero RPC delay.
const builtinTools = summarizeBuiltinTools();
+ const connectedCount = statuses.filter((s) => s.state === "connected").length;
+ // Used by the Browse-connectors dialog to render already-connected
+ // tiles as non-clickable "connected" pills. We pass both keys *and*
+ // normalized resource URLs because the trusted-connector id and the
+ // stored mcp_tokens.server_name don't always match (e.g. NotFair Meta
+ // Ads was historically slugified to `notfair-meta-ads` while the tile
+ // uses canonical id `notfair-metaads`). The URL is the stable signal.
+ const connectedSpecs = catalog.filter(
+ (_, i) => statuses[i].state === "connected",
+ );
+ const connectedKeys = connectedSpecs.map((s) => s.key);
+ const connectedResourceUrls = connectedSpecs.map((s) =>
+ normalizeResourceUrl(s.resource_url),
+ );
return (
- <div className="mx-auto max-w-3xl space-y-6">
- <header>
- <h1 className="text-2xl font-semibold tracking-tight">
- MCP Connections
- </h1>
- <p className="text-sm text-muted-foreground">
- MCPs are the tool servers your agents call into. Connect external
- ones (Google Ads, etc.) with one click, or browse the orchestration
- tools that ship built-in.
- </p>
+ <div className="mx-auto max-w-3xl px-6 py-12">
+ {/* Editorial header — eyebrow, large title, sublabel, and the
+ primary action lifted into the top-right slot. */}
+ <header className="border-b border-border/60 pb-8">
+ <div className="flex items-start justify-between gap-6">
+ <div className="min-w-0">
+ <p className="font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">
+ Project · {project.display_name}
+ </p>
+ <h1 className="mt-2 text-3xl font-semibold tracking-tight">
+ Connections
+ </h1>
+ <p className="mt-3 max-w-md text-sm leading-relaxed text-muted-foreground">
+ MCP servers are the tools your agents call. Browse the curated
+ list or paste any OAuth&nbsp;2.0 URL.
+ </p>
+ </div>
+ <div className="shrink-0">
+ <AddMcpServerMenu
+ connectedKeys={connectedKeys}
+ connectedResourceUrls={connectedResourceUrls}
+ />
+ </div>
+ </div>
</header>
<McpFlashBanner connected={mcp_connected} error={mcp_error} />
- <div className="space-y-3">
- <BuiltinMcpCard
- name="Orchestration"
- description="Built-in tools your agents use to coordinate: assign tasks, request approvals, write PROJECT.md, comment, and report status."
- tools={builtinTools}
+ {/* Built-in section — visually anchored with the orchestration
+ accent so users can tell at a glance it's not an external MCP. */}
+ <section className="mt-10">
+ <SectionHeading
+ label="Built-in"
+ meta="ships with the platform"
/>
+ <div className="mt-3 overflow-hidden rounded-xl border border-border bg-card">
+ <BuiltinMcpCard
+ name="Orchestration"
+ description="Built-in tools your agents use to coordinate: assign tasks, request approvals, write PROJECT.md, comment, and report status."
+ tools={builtinTools}
+ />
+ </div>
+ </section>
+ {/* External servers — one list, one container, sharp row dividers. */}
+ <section className="mt-10">
+ <SectionHeading
+ label="Servers"
+ meta={
+ catalog.length === 0
+ ? "none yet"
+ : `${connectedCount} of ${catalog.length} connected`
+ }
+ />
{catalog.length === 0 ? (
- <Card>
- <CardContent className="py-12 text-center text-sm text-muted-foreground">
- No external MCP servers in the catalog yet.
- </CardContent>
- </Card>
+ <div className="mt-3 overflow-hidden rounded-xl border border-dashed border-border bg-card">
+ <p className="px-6 py-12 text-center text-sm text-muted-foreground">
+ No external MCP servers yet. Use{" "}
+ <span className="font-medium text-foreground">Add server</span>{" "}
+ above to browse trusted connectors or paste a URL.
+ </p>
+ </div>
) : (
- catalog.map((spec, i) => (
- <McpCard key={spec.key} spec={spec} status={statuses[i]} />
- ))
+ <ol className="mt-3 overflow-hidden rounded-xl border border-border bg-card divide-y divide-border">
+ {catalog.map((spec, i) => (
+ <li key={spec.key}>
+ <McpCard spec={spec} status={statuses[i]} />
+ </li>
+ ))}
+ </ol>
)}
+ </section>
+ </div>
+ );
+}
- <AddMcpServerCard />
- </div>
+function SectionHeading({ label, meta }: { label: string; meta: string }) {
+ return (
+ <div className="flex items-baseline justify-between gap-4">
+ <h2 className="font-mono text-[11px] uppercase tracking-[0.18em] text-muted-foreground">
+ {label}
+ </h2>
+ <span className="font-mono text-[10px] uppercase tracking-[0.14em] text-muted-foreground/70">
+ {meta}
+ </span>
</div>
);
}
diff --git a/notfair-cmo/src/components/add-mcp-server-card.tsx b/notfair-cmo/src/components/add-mcp-server-card.tsx
index c78ba8a8..fd119f52 100644
--- a/notfair-cmo/src/components/add-mcp-server-card.tsx
+++ b/notfair-cmo/src/components/add-mcp-server-card.tsx
@@ -2,9 +2,8 @@
import { useState } from "react";
import { useRouter } from "next/navigation";
-import { Plus, Loader2 } from "lucide-react";
+import { Plus, Loader2, BookOpenText, MoreHorizontal } from "lucide-react";
-import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
@@ -16,21 +15,104 @@ 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";
/**
- * Connections-page card that opens an "Add MCP server" dialog. Any
- * server that publishes RFC 9728 discovery + a DCR-capable AS metadata
- * doc can be added — Stripe, Vercel, Supabase, etc.
+ * "Add server" dropdown trigger for the Connections page header. Two
+ * paths:
+ *
+ * - **Browse connectors** → curated grid of trusted MCPs (Stripe,
+ * PostHog, NotFair, etc.). Click adds it to this project via the
+ * same OAuth probe + persistence path as a custom URL.
+ * - **Add custom connector** → paste-a-URL dialog for any OAuth 2.0
+ * MCP that publishes RFC 9728 discovery + DCR.
*
- * No bearer-paste path: OAuth 2.0 only. The form submits to
- * `addUserMcpServerAction`, which probes discovery before persisting
- * the row, so a server that won't connect is rejected before the user
- * even sees a Connect button.
+ * No bearer-paste path: OAuth 2.0 only. The probe in
+ * `addUserMcpServerAction` rejects servers that won't connect before
+ * the user even sees a Connect button.
*/
-export function AddMcpServerCard() {
- const [open, setOpen] = useState(false);
+export function AddMcpServerMenu({
+ connectedKeys = [],
+ connectedResourceUrls = [],
+}: {
+ /** Catalog keys whose runtime status is `connected`. Browse tiles for
+ * these render as non-clickable "connected" pills. */
+ connectedKeys?: string[];
+ /** Normalized resource URLs of connected entries — paired with
+ * `connectedKeys` so legacy rows (where the key was slugified
+ * differently than the trusted-connector id) still match by URL. */
+ connectedResourceUrls?: string[];
+}) {
+ const [browseOpen, setBrowseOpen] = useState(false);
+ const [customOpen, setCustomOpen] = useState(false);
+
+ return (
+ <>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ size="sm"
+ className="h-9 gap-1.5 rounded-full px-4 shadow-sm"
+ >
+ <Plus className="size-3.5" />
+ Add server
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" 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>
+
+ <BrowseConnectorsDialog
+ open={browseOpen}
+ onOpenChange={setBrowseOpen}
+ connectedKeys={connectedKeys}
+ connectedResourceUrls={connectedResourceUrls}
+ />
+ <CustomConnectorDialog open={customOpen} onOpenChange={setCustomOpen} />
+ </>
+ );
+}
+
+function CustomConnectorDialog({
+ open,
+ onOpenChange,
+}: {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}) {
const [submitting, setSubmitting] = useState(false);
const [displayName, setDisplayName] = useState("");
const [resourceUrl, setResourceUrl] = useState("");
@@ -56,8 +138,10 @@ export function AddMcpServerCard() {
setError(result.error);
return;
}
- toast.success(`Added MCP server '${result.key}'. Click Connect to authorize.`);
- setOpen(false);
+ toast.success(
+ `Added MCP server '${result.key}'. Click Connect to authorize.`,
+ );
+ onOpenChange(false);
reset();
router.refresh();
} catch (err) {
@@ -68,99 +152,76 @@ export function AddMcpServerCard() {
}
return (
- <>
- <Card>
- <CardContent className="flex items-center justify-between gap-4 py-4">
- <div className="space-y-0.5">
- <p className="text-sm font-medium">Add an MCP server</p>
+ <Dialog
+ open={open}
+ onOpenChange={(next) => {
+ onOpenChange(next);
+ if (!next) reset();
+ }}
+ >
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>Add custom connector</DialogTitle>
+ <DialogDescription>
+ Paste the MCP server&apos;s resource URL. We&apos;ll verify it
+ advertises OAuth 2.0 dynamic client registration before saving.
+ </DialogDescription>
+ </DialogHeader>
+ <form onSubmit={onSubmit} className="space-y-4">
+ <div className="space-y-1.5">
+ <Label htmlFor="mcp-display-name">Name</Label>
+ <Input
+ id="mcp-display-name"
+ placeholder="Stripe"
+ value={displayName}
+ onChange={(e) => setDisplayName(e.target.value)}
+ disabled={submitting}
+ required
+ autoFocus
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="mcp-resource-url">Remote MCP server URL</Label>
+ <Input
+ id="mcp-resource-url"
+ type="url"
+ placeholder="https://mcp.stripe.com/"
+ value={resourceUrl}
+ onChange={(e) => setResourceUrl(e.target.value)}
+ disabled={submitting}
+ required
+ />
<p className="text-xs text-muted-foreground">
- Connect any OAuth 2.0 MCP server — Stripe, Vercel, Supabase, or
- your own.
+ The HTTPS endpoint your agents will call. We derive the OAuth
+ discovery URL from this automatically.
</p>
</div>
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => setOpen(true)}
- >
- <Plus className="size-3.5" />
- Add server
- </Button>
- </CardContent>
- </Card>
-
- <Dialog
- open={open}
- onOpenChange={(next) => {
- setOpen(next);
- if (!next) reset();
- }}
- >
- <DialogContent>
- <DialogHeader>
- <DialogTitle>Add MCP server</DialogTitle>
- <DialogDescription>
- Paste the MCP server&apos;s resource URL. We&apos;ll verify it
- advertises OAuth 2.0 dynamic client registration before saving.
- </DialogDescription>
- </DialogHeader>
- <form onSubmit={onSubmit} className="space-y-4">
- <div className="space-y-1.5">
- <Label htmlFor="mcp-display-name">Name</Label>
- <Input
- id="mcp-display-name"
- placeholder="Stripe"
- value={displayName}
- onChange={(e) => setDisplayName(e.target.value)}
- disabled={submitting}
- required
- autoFocus
- />
- </div>
- <div className="space-y-1.5">
- <Label htmlFor="mcp-resource-url">Remote MCP server URL</Label>
- <Input
- id="mcp-resource-url"
- type="url"
- placeholder="https://mcp.stripe.com/"
- value={resourceUrl}
- onChange={(e) => setResourceUrl(e.target.value)}
- disabled={submitting}
- required
- />
- <p className="text-xs text-muted-foreground">
- The HTTPS endpoint your agents will call. We derive the OAuth
- discovery URL from this automatically.
- </p>
- </div>
- {error ? (
- <p
- className="rounded border border-destructive/30 bg-destructive/5 p-2 text-xs text-destructive"
- role="alert"
- >
- {error}
- </p>
- ) : null}
- <DialogFooter>
- <Button
- type="button"
- variant="ghost"
- onClick={() => setOpen(false)}
- disabled={submitting}
- >
- Cancel
- </Button>
- <Button type="submit" disabled={submitting}>
- {submitting ? (
- <Loader2 className="size-3.5 animate-spin" />
- ) : null}
- Add server
- </Button>
- </DialogFooter>
- </form>
- </DialogContent>
- </Dialog>
- </>
+ {error ? (
+ <p
+ className="rounded border border-destructive/30 bg-destructive/5 p-2 text-xs text-destructive"
+ role="alert"
+ >
+ {error}
+ </p>
+ ) : null}
+ <DialogFooter>
+ <Button
+ type="button"
+ variant="ghost"
+ onClick={() => onOpenChange(false)}
+ disabled={submitting}
+ >
+ Cancel
+ </Button>
+ <Button type="submit" disabled={submitting}>
+ {submitting ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : null}
+ Add server
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
);
}
diff --git a/notfair-cmo/src/components/browse-connectors-dialog.tsx b/notfair-cmo/src/components/browse-connectors-dialog.tsx
new file mode 100644
index 00000000..a0bfcefc
--- /dev/null
+++ b/notfair-cmo/src/components/browse-connectors-dialog.tsx
@@ -0,0 +1,187 @@
+"use client";
+
+import { useState, useTransition } from "react";
+import { useRouter } from "next/navigation";
+import { CheckCircle2, Loader2 } from "lucide-react";
+
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { toast } from "sonner";
+import {
+ addUserMcpServerAction,
+ startMcpConnect,
+} from "@/server/actions/mcp";
+import {
+ TRUSTED_CONNECTORS,
+ type TrustedConnector,
+} from "@/server/trusted-connectors";
+import { McpIcon } from "@/components/mcp-icon";
+import { normalizeResourceUrl } from "@/server/mcp/discovery-url";
+
+type Props = {
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+ /** Catalog keys whose runtime status is `connected`. */
+ connectedKeys?: string[];
+ /** Normalized resource URLs of connected entries — used to detect
+ * legacy rows whose key doesn't match the trusted-connector id. */
+ connectedResourceUrls?: string[];
+};
+
+/**
+ * Two-column grid of trusted MCP connectors. Clicking a tile is a
+ * one-shot setup: `addUserMcpServerAction` writes the row (idempotent —
+ * re-clicking a stale row is fine), then `startMcpConnect` is fired
+ * immediately and the browser is redirected to the issuer's authorize
+ * URL. The user lands back on the connections page already connected —
+ * no second "Connect" click required.
+ *
+ * Tiles for connectors already showing as `connected` on the page are
+ * rendered non-interactive with a green "connected" indicator so users
+ * don't re-trigger an OAuth roundtrip for something that's already live.
+ */
+export function BrowseConnectorsDialog({
+ open,
+ onOpenChange,
+ connectedKeys = [],
+ connectedResourceUrls = [],
+}: Props) {
+ const connectedKeySet = new Set(connectedKeys);
+ const connectedUrlSet = new Set(connectedResourceUrls);
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-2xl">
+ <DialogHeader>
+ <DialogTitle>Browse connectors</DialogTitle>
+ <DialogDescription>
+ Pick a trusted MCP server. We&apos;ll add it and start the OAuth
+ flow in one step.
+ </DialogDescription>
+ </DialogHeader>
+ <div className="grid grid-cols-1 gap-2 sm:grid-cols-2">
+ {TRUSTED_CONNECTORS.map((c) => {
+ const alreadyConnected =
+ connectedKeySet.has(c.id) ||
+ connectedUrlSet.has(normalizeResourceUrl(c.resource_url));
+ return (
+ <ConnectorTile
+ key={c.id}
+ connector={c}
+ alreadyConnected={alreadyConnected}
+ onAdded={() => onOpenChange(false)}
+ />
+ );
+ })}
+ </div>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+function ConnectorTile({
+ connector,
+ alreadyConnected,
+ onAdded,
+}: {
+ connector: TrustedConnector;
+ alreadyConnected: boolean;
+ onAdded: () => void;
+}) {
+ const [pending, startTransition] = useTransition();
+ const [adding, setAdding] = useState(false);
+ const router = useRouter();
+ const busy = adding || pending;
+
+ function onPick() {
+ setAdding(true);
+ startTransition(async () => {
+ const addResult = await addUserMcpServerAction({
+ display_name: connector.display_name,
+ resource_url: connector.resource_url,
+ // Force the canonical preset/connector key so adding "NotFair
+ // Google Ads" hits the preset (`notfair-googleads`) rather than
+ // slugifying into a different identifier.
+ key: connector.id,
+ });
+ if (!addResult.ok) {
+ toast.error(addResult.error);
+ setAdding(false);
+ return;
+ }
+ // Chain straight into OAuth so the user only clicks once. The
+ // upcoming full-page redirect is the visible feedback — we
+ // intentionally don't toast a separate "added" success.
+ const connectResult = await startMcpConnect({ mcp_key: addResult.key });
+ if (!connectResult.ok) {
+ toast.error(
+ `Added ${connector.display_name}, but couldn't start OAuth: ${connectResult.error}`,
+ );
+ router.refresh();
+ onAdded();
+ setAdding(false);
+ return;
+ }
+ // Full-page navigation: the authorize URL is on the issuer's
+ // origin, so we can't push() into Next's router.
+ window.location.href = connectResult.authorize_url;
+ });
+ }
+
+ if (alreadyConnected) {
+ return (
+ <div
+ aria-disabled
+ className="flex items-start gap-3 rounded-md border border-emerald-500/30 bg-emerald-500/5 p-3 text-left ring-1 ring-inset ring-emerald-500/10"
+ >
+ <McpIcon
+ resourceUrl={connector.resource_url}
+ alt={connector.display_name}
+ size="lg"
+ />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <p className="text-sm font-medium">{connector.display_name}</p>
+ <span className="inline-flex items-center gap-1 font-mono text-[10px] uppercase tracking-[0.14em] text-emerald-700 dark:text-emerald-400">
+ <CheckCircle2 className="size-3" />
+ connected
+ </span>
+ </div>
+ <p className="mt-0.5 line-clamp-2 text-xs text-muted-foreground">
+ {connector.description}
+ </p>
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <button
+ type="button"
+ onClick={onPick}
+ disabled={busy}
+ className="flex items-start gap-3 rounded-md border border-border bg-background p-3 text-left transition-colors hover:bg-muted/50 disabled:cursor-not-allowed disabled:opacity-60"
+ >
+ <McpIcon
+ resourceUrl={connector.resource_url}
+ alt={connector.display_name}
+ size="lg"
+ />
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <p className="text-sm font-medium">{connector.display_name}</p>
+ {busy ? (
+ <Loader2 className="size-3 animate-spin text-muted-foreground" />
+ ) : null}
+ </div>
+ <p className="mt-0.5 line-clamp-2 text-xs text-muted-foreground">
+ {connector.description}
+ </p>
+ </div>
+ </button>
+ );
+}
diff --git a/notfair-cmo/src/components/builtin-mcp-card.tsx b/notfair-cmo/src/components/builtin-mcp-card.tsx
index ca4c40e3..8e8be36b 100644
--- a/notfair-cmo/src/components/builtin-mcp-card.tsx
+++ b/notfair-cmo/src/components/builtin-mcp-card.tsx
@@ -3,25 +3,15 @@
import { useState } from "react";
import { Workflow, BookOpenText } from "lucide-react";
-import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
-import { Badge } from "@/components/ui/badge";
import { McpToolsDialog } from "@/components/mcp-tools-dialog";
import type { ToolSummary } from "@/server/mcp-server/tool-summaries";
/**
- * Card for an MCP that ships with notfair-cmo itself — no OAuth, no
- * connect/disconnect, always available to every agent. We distinguish
- * it visually from external OAuth MCPs through:
- *
- * - icon: `Workflow` (orchestration) instead of `Plug` (external wire)
- * - badge: "Built-in" emerald chip in place of a connection-state badge
- * - right-side action: "View tools" only (no Connect button)
- * - footer line states the tool count + "Self-hosted" instead of a
- * connection-state detail line
- *
- * Tool list is supplied directly from the server-side describeTool walk
- * so the dialog opens instantly — no RPC roundtrip.
+ * Row for an MCP that ships with notfair-cmo itself — no OAuth, no
+ * connect/disconnect, always available to every agent. Visually
+ * distinguished from external rows by an emerald-tinted icon tile and
+ * a small "BUILT-IN" lozenge in place of a connection-state badge.
*/
type Props = {
name: string;
@@ -34,46 +24,49 @@ export function BuiltinMcpCard({ name, description, tools }: Props) {
return (
<>
- <Card>
- <CardContent className="space-y-4 p-5">
- <div className="flex items-start justify-between gap-3">
- <div className="flex min-w-0 items-start gap-3">
- <div className="flex size-9 shrink-0 items-center justify-center rounded-md bg-emerald-500/10 ring-1 ring-inset ring-emerald-500/20">
- <Workflow className="size-4 text-emerald-700 dark:text-emerald-400" />
- </div>
- <div className="min-w-0">
- <div className="flex items-center gap-2">
- <h3 className="text-sm font-medium">{name}</h3>
- <Badge
- variant="secondary"
- className="h-4 gap-1 border-emerald-500/20 bg-emerald-500/10 px-1.5 text-[10px] font-medium tracking-wide text-emerald-700 uppercase dark:text-emerald-400"
- >
- Built-in
- </Badge>
- </div>
- <p className="mt-0.5 text-xs text-muted-foreground">
- {description}
- </p>
- <p className="mt-1 font-mono text-[11px] text-muted-foreground">
- {tools.length} tool{tools.length === 1 ? "" : "s"} · self-hosted ·
- no setup
- </p>
- </div>
- </div>
- <div className="shrink-0">
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => setOpen(true)}
- >
- <BookOpenText className="size-3.5" />
- View tools
- </Button>
- </div>
+ <article className="flex items-center gap-4 px-5 py-4">
+ <div className="flex size-10 shrink-0 items-center justify-center rounded-md bg-emerald-500/10 ring-1 ring-inset ring-emerald-500/25">
+ <Workflow className="size-5 text-emerald-700 dark:text-emerald-400" />
+ </div>
+
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <h3 className="truncate text-sm font-medium tracking-tight">
+ {name}
+ </h3>
+ <span className="inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-emerald-700 dark:text-emerald-400">
+ <span
+ className="size-1.5 rounded-full bg-emerald-500"
+ aria-hidden
+ />
+ built-in
+ </span>
</div>
- </CardContent>
- </Card>
+ <p className="mt-0.5 line-clamp-1 text-xs text-muted-foreground">
+ {description}
+ </p>
+ <p className="mt-1 truncate font-mono text-[10.5px] text-muted-foreground/80">
+ self-hosted
+ <span className="mx-1.5 text-muted-foreground/40">·</span>
+ {tools.length} tool{tools.length === 1 ? "" : "s"}
+ <span className="mx-1.5 text-muted-foreground/40">·</span>
+ no setup
+ </p>
+ </div>
+
+ <div className="shrink-0">
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="h-8"
+ onClick={() => setOpen(true)}
+ >
+ <BookOpenText className="size-3.5" />
+ Tools
+ </Button>
+ </div>
+ </article>
<McpToolsDialog
open={open}
diff --git a/notfair-cmo/src/components/mcp-card.test.tsx b/notfair-cmo/src/components/mcp-card.test.tsx
index dd70fc7c..c445346d 100644
--- a/notfair-cmo/src/components/mcp-card.test.tsx
+++ b/notfair-cmo/src/components/mcp-card.test.tsx
@@ -80,27 +80,18 @@ afterEach(() => {
});
describe("McpCard", () => {
- it("shows spec metadata (name, description, resource_url)", () => {
+ it("shows spec metadata (name, description, host)", () => {
render(<McpCard spec={spec} status={{ state: "not_configured" }} />);
expect(screen.getByText(spec.display_name)).toBeInTheDocument();
expect(screen.getByText(spec.description)).toBeInTheDocument();
- expect(screen.getByText(spec.resource_url)).toBeInTheDocument();
+ // The row shows the resource URL's host, not the full URL.
+ expect(screen.getByText("notfair.co")).toBeInTheDocument();
});
- it("renders a 'connected' badge and tool count when status is connected", () => {
- render(<McpCard spec={spec} status={connected({ tools_count: 12 })} />);
- expect(screen.getByText("connected")).toBeInTheDocument();
- expect(screen.getByText(/12 tools available/)).toBeInTheDocument();
- });
-
- it("uses the singular 'tool' wording when tools_count is 1", () => {
- render(<McpCard spec={spec} status={connected({ tools_count: 1 })} />);
- expect(screen.getByText(/1 tool available/)).toBeInTheDocument();
- });
-
- it("falls back to 'Live.' when tools_count is null", () => {
+ it("renders a 'connected' indicator with the verified time when connected", () => {
render(<McpCard spec={spec} status={connected({ tools_count: null })} />);
- expect(screen.getByText(/Live\./)).toBeInTheDocument();
+ expect(screen.getByText("connected")).toBeInTheDocument();
+ expect(screen.getByText(/live · verified/)).toBeInTheDocument();
});
it("shows a Disconnect button when connected and a Connect button otherwise", () => {
@@ -160,7 +151,7 @@ describe("McpCard", () => {
);
expect(screen.getByText(/no token/i)).toBeInTheDocument();
expect(
- screen.getByText(/Config exists but has no bearer token/i),
+ screen.getByText(/config saved, awaiting bearer/i),
).toBeInTheDocument();
});
diff --git a/notfair-cmo/src/components/mcp-card.tsx b/notfair-cmo/src/components/mcp-card.tsx
index 8027a57b..ca8c4365 100644
--- a/notfair-cmo/src/components/mcp-card.tsx
+++ b/notfair-cmo/src/components/mcp-card.tsx
@@ -4,17 +4,12 @@ import { useState, useTransition } from "react";
import { useRouter } from "next/navigation";
import {
Plug,
- CheckCircle2,
- AlertTriangle,
Loader2,
Unplug,
- XCircle,
BookOpenText,
Trash2,
} from "lucide-react";
-import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
-import { Badge } from "@/components/ui/badge";
import { toast } from "sonner";
import {
startMcpConnect,
@@ -25,15 +20,24 @@ import {
import type { McpSpec } from "@/server/mcp-catalog";
import type { McpRuntimeStatus } from "@/server/mcp/state";
import { McpToolsDialog } from "@/components/mcp-tools-dialog";
+import { McpIcon } from "@/components/mcp-icon";
type Props = {
spec: McpSpec;
status: McpRuntimeStatus;
};
+/**
+ * One row in the Connections list. Drops the outer Card border because
+ * the parent `<ol>` provides a single shared container + dividers; this
+ * keeps the visual rhythm of a refined editorial list rather than a
+ * stack of disconnected boxes.
+ */
export function McpCard({ spec, status }: Props) {
const [pending, startTransition] = useTransition();
- const [busy, setBusy] = useState<"connect" | "disconnect" | "remove" | null>(null);
+ const [busy, setBusy] = useState<"connect" | "disconnect" | "remove" | null>(
+ null,
+ );
const [toolsOpen, setToolsOpen] = useState(false);
const router = useRouter();
@@ -63,9 +67,6 @@ export function McpCard({ spec, status }: Props) {
toast.error(result.error);
} else {
toast.success(`${spec.display_name} disconnected`);
- // revalidatePath inside the action invalidates the cached server
- // render, but the client still needs to re-fetch — router.refresh()
- // forces the RSC payload to repopulate this card's `status` prop.
router.refresh();
}
setBusy(null);
@@ -88,93 +89,98 @@ export function McpCard({ spec, status }: Props) {
const isBusy = busy !== null || pending;
const canViewTools = status.state === "connected";
- const canRemove = spec.source === "user";
+ // Every connector is removable now — presets get hidden per-project
+ // via the hidden_mcp_preset_keys list; user rows get deleted. Either
+ // way the card disappears from the connections list.
+ const canRemove = true;
return (
<>
- <Card>
- <CardContent className="space-y-4 p-5">
- <div className="flex items-start justify-between gap-3">
- <div className="flex items-start gap-3 min-w-0">
- <McpIcon resourceUrl={spec.resource_url} alt={spec.display_name} />
- <div className="min-w-0">
- <div className="flex items-center gap-2">
- <h3 className="text-sm font-medium">{spec.display_name}</h3>
- <StatusBadge status={status} />
- </div>
- <p className="mt-0.5 text-xs text-muted-foreground">
- {spec.description}
- </p>
- <p className="mt-1 truncate font-mono text-[11px] text-muted-foreground">
- {spec.resource_url}
- </p>
- </div>
- </div>
- <div className="shrink-0">
- {status.state === "connected" ? (
- <Button
- type="button"
- variant="outline"
- size="sm"
- disabled={isBusy}
- onClick={onDisconnect}
- >
- {busy === "disconnect" ? (
- <Loader2 className="size-3.5 animate-spin" />
- ) : (
- <Unplug className="size-3.5" />
- )}
- Disconnect
- </Button>
- ) : (
- <Button type="button" size="sm" disabled={isBusy} onClick={onConnect}>
- {busy === "connect" ? (
- <Loader2 className="size-3.5 animate-spin" />
- ) : (
- <Plug className="size-3.5" />
- )}
- {status.state === "stale_token" ? "Reconnect" : "Connect"}
- </Button>
- )}
- </div>
+ <article className="flex items-center gap-4 px-5 py-4 transition-colors hover:bg-muted/30">
+ <McpIcon
+ resourceUrl={spec.resource_url}
+ alt={spec.display_name}
+ size="lg"
+ />
+
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center gap-2">
+ <h3 className="truncate text-sm font-medium tracking-tight">
+ {spec.display_name}
+ </h3>
+ <StatusDot status={status} />
</div>
+ <p className="mt-0.5 line-clamp-1 text-xs text-muted-foreground">
+ {spec.description}
+ </p>
+ <StatusLine status={status} resourceUrl={spec.resource_url} />
+ </div>
- <div className="flex items-center justify-between gap-3">
- <StatusDetail status={status} />
- <div className="flex shrink-0 items-center gap-1">
- {canViewTools && (
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="h-7 px-2 text-xs text-muted-foreground hover:text-foreground"
- onClick={() => setToolsOpen(true)}
- >
- <BookOpenText className="size-3.5" />
- View tools
- </Button>
+ <div className="flex shrink-0 items-center gap-1.5">
+ {canViewTools && (
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ className="h-8 px-2 text-xs text-muted-foreground hover:text-foreground"
+ onClick={() => setToolsOpen(true)}
+ >
+ <BookOpenText className="size-3.5" />
+ Tools
+ </Button>
+ )}
+ {canRemove && (
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ className="h-8 px-2 text-xs text-muted-foreground hover:text-destructive"
+ disabled={isBusy}
+ onClick={onRemove}
+ aria-label={`Remove ${spec.display_name}`}
+ title="Remove server"
+ >
+ {busy === "remove" ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : (
+ <Trash2 className="size-3.5" />
)}
- {canRemove && (
- <Button
- type="button"
- variant="ghost"
- size="sm"
- className="h-7 px-2 text-xs text-muted-foreground hover:text-destructive"
- disabled={isBusy}
- onClick={onRemove}
- >
- {busy === "remove" ? (
- <Loader2 className="size-3.5 animate-spin" />
- ) : (
- <Trash2 className="size-3.5" />
- )}
- Remove server
- </Button>
+ </Button>
+ )}
+ {status.state === "connected" ? (
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="h-8"
+ disabled={isBusy}
+ onClick={onDisconnect}
+ >
+ {busy === "disconnect" ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : (
+ <Unplug className="size-3.5" />
)}
- </div>
- </div>
- </CardContent>
- </Card>
+ Disconnect
+ </Button>
+ ) : (
+ <Button
+ type="button"
+ size="sm"
+ className="h-8"
+ disabled={isBusy}
+ onClick={onConnect}
+ >
+ {busy === "connect" ? (
+ <Loader2 className="size-3.5 animate-spin" />
+ ) : (
+ <Plug className="size-3.5" />
+ )}
+ {status.state === "stale_token" ? "Reconnect" : "Connect"}
+ </Button>
+ )}
+ </div>
+ </article>
<McpToolsDialog
open={toolsOpen}
@@ -188,134 +194,74 @@ export function McpCard({ spec, status }: Props) {
}
/**
- * Renders the MCP server's brand favicon via Google's `faviconV2` service.
- *
- * We strip subdomains down to the registrable domain (`mcp.stripe.com` →
- * `stripe.com`) so the icon reflects the company's brand, not the API
- * subdomain — Google rarely has a real favicon indexed for `mcp.*` or
- * `api.*` hosts. Falls back to a Plug glyph on malformed URLs.
+ * Inline status indicator — a small filled dot next to the name. Color
+ * carries the state, no background pill needed.
*/
-function McpIcon({ resourceUrl, alt }: { resourceUrl: string; alt: string }) {
- const [errored, setErrored] = useState(false);
- let host: string | null = null;
- try {
- host = new URL(resourceUrl).hostname;
- } catch {
- host = null;
- }
- const brandHost = host ? brandDomain(host) : null;
- const showImg = !!brandHost && !errored;
+function StatusDot({ status }: { status: McpRuntimeStatus }) {
+ const map: Record<McpRuntimeStatus["state"], { color: string; label: string }> =
+ {
+ connected: { color: "bg-emerald-500", label: "connected" },
+ stale_token: { color: "bg-amber-500", label: "token expired" },
+ unreachable: { color: "bg-destructive", label: "unreachable" },
+ configured_no_token: { color: "bg-amber-500", label: "no token" },
+ not_configured: { color: "bg-muted-foreground/40", label: "not connected" },
+ };
+ const { color, label } = map[status.state];
return (
- <div className="flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-md bg-muted">
- {showImg ? (
- // eslint-disable-next-line @next/next/no-img-element
- <img
- src={`https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://${brandHost}&size=32`}
- alt={alt}
- width={20}
- height={20}
- className="size-5"
- referrerPolicy="no-referrer"
- onError={() => setErrored(true)}
- />
- ) : (
- <Plug className="size-4" />
- )}
- </div>
+ <span
+ className="inline-flex items-center gap-1.5 font-mono text-[10px] uppercase tracking-[0.14em] text-muted-foreground"
+ role="status"
+ >
+ <span className={`size-1.5 rounded-full ${color}`} aria-hidden />
+ {label}
+ </span>
);
}
/**
- * Reduce a hostname to a "brand" host for favicon lookup. The Public
- * Suffix List is the only fully correct answer here; the simple last-2-
- * labels heuristic is wrong for some multipart TLDs (`example.co.uk`),
- * but it's right for ~all consumer SaaS the connections page targets.
- * Hosts that are already 2 labels or fewer (`notfair.co`, `localhost`)
- * pass through unchanged.
+ * Bottom metadata line: brand host (mono small) plus connection-state
+ * details (verified Xm ago, error blurb, etc.) separated by a thin dot.
*/
-function brandDomain(host: string): string {
- const parts = host.split(".").filter(Boolean);
- if (parts.length <= 2) return host;
- return parts.slice(-2).join(".");
-}
-
-function StatusBadge({ status }: { status: McpRuntimeStatus }) {
- switch (status.state) {
- case "connected":
- return (
- <Badge variant="secondary" className="gap-1 text-[10px]">
- <CheckCircle2 className="size-3 text-emerald-600" />
- connected
- </Badge>
- );
- case "stale_token":
- return (
- <Badge variant="outline" className="gap-1 text-[10px]">
- <AlertTriangle className="size-3 text-amber-600" />
- token expired
- </Badge>
- );
- case "unreachable":
- return (
- <Badge variant="outline" className="gap-1 text-[10px]">
- <XCircle className="size-3 text-destructive" />
- unreachable
- </Badge>
- );
- case "configured_no_token":
- return (
- <Badge variant="outline" className="gap-1 text-[10px]">
- <AlertTriangle className="size-3 text-amber-600" />
- no token
- </Badge>
- );
- case "not_configured":
- return (
- <Badge variant="outline" className="text-[10px]">
- not connected
- </Badge>
- );
- }
+function StatusLine({
+ status,
+ resourceUrl,
+}: {
+ status: McpRuntimeStatus;
+ resourceUrl: string;
+}) {
+ const host = (() => {
+ try {
+ return new URL(resourceUrl).host;
+ } catch {
+ return resourceUrl;
+ }
+ })();
+ const detail = describeStatus(status);
+ return (
+ <p className="mt-1 truncate font-mono text-[10.5px] text-muted-foreground/80">
+ <span>{host}</span>
+ {detail ? (
+ <>
+ <span className="mx-1.5 text-muted-foreground/40">·</span>
+ <span>{detail}</span>
+ </>
+ ) : null}
+ </p>
+ );
}
-function StatusDetail({ status }: { status: McpRuntimeStatus }) {
+function describeStatus(status: McpRuntimeStatus): string | null {
switch (status.state) {
case "connected":
- return (
- <p className="text-xs text-muted-foreground">
- {status.tools_count !== null
- ? `${status.tools_count} tool${status.tools_count === 1 ? "" : "s"} available`
- : "Live."}
- {" · Verified "}
- {timeAgo(status.last_checked_at)}
- </p>
- );
+ return `live · verified ${timeAgo(status.last_checked_at)}`;
case "stale_token":
- return (
- <p className="text-xs text-muted-foreground">
- Server rejected the saved token (HTTP {status.http_status}). Reconnect
- to refresh.
- </p>
- );
+ return `token rejected (HTTP ${status.http_status})`;
case "unreachable":
- return (
- <p className="text-xs text-muted-foreground">
- Couldn’t reach the MCP server: {status.error}
- </p>
- );
+ return status.error;
case "configured_no_token":
- return (
- <p className="text-xs text-muted-foreground">
- Config exists but has no bearer token. Click Connect to fix.
- </p>
- );
+ return "config saved, awaiting bearer";
case "not_configured":
- return (
- <p className="text-xs text-muted-foreground">
- One click runs the OAuth flow against the issuer and saves the token
- locally to this project.
- </p>
- );
+ return "one-click OAuth saves the token locally";
}
}
diff --git a/notfair-cmo/src/components/mcp-icon.tsx b/notfair-cmo/src/components/mcp-icon.tsx
new file mode 100644
index 00000000..852e931e
--- /dev/null
+++ b/notfair-cmo/src/components/mcp-icon.tsx
@@ -0,0 +1,69 @@
+"use client";
+
+import { useState } from "react";
+import { Plug } from "lucide-react";
+
+/**
+ * Brand favicon for an MCP server, fetched via Google's `faviconV2`
+ * service. Subdomain-aware: `mcp.stripe.com` resolves to `stripe.com`
+ * so we get the company brand mark, not the API-subdomain glyph (which
+ * usually isn't indexed).
+ *
+ * Falls back to the `Plug` lucide icon on malformed input or image
+ * load failure.
+ */
+export function McpIcon({
+ resourceUrl,
+ alt,
+ size = "md",
+}: {
+ resourceUrl: string;
+ alt: string;
+ size?: "md" | "lg";
+}) {
+ const [errored, setErrored] = useState(false);
+ let host: string | null = null;
+ try {
+ host = new URL(resourceUrl).hostname;
+ } catch {
+ host = null;
+ }
+ const brandHost = host ? brandDomain(host) : null;
+ const showImg = !!brandHost && !errored;
+ const boxClass = size === "lg" ? "size-10" : "size-9";
+ const imgClass = size === "lg" ? "size-6" : "size-5";
+ const fallbackClass = size === "lg" ? "size-5" : "size-4";
+ return (
+ <div
+ className={`flex ${boxClass} shrink-0 items-center justify-center overflow-hidden rounded-md bg-muted`}
+ >
+ {showImg ? (
+ // eslint-disable-next-line @next/next/no-img-element
+ <img
+ src={`https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://${brandHost}&size=32`}
+ alt={alt}
+ width={32}
+ height={32}
+ className={imgClass}
+ referrerPolicy="no-referrer"
+ onError={() => setErrored(true)}
+ />
+ ) : (
+ <Plug className={fallbackClass} />
+ )}
+ </div>
+ );
+}
+
+/**
+ * Reduce a hostname to its registrable brand domain
+ * (`mcp.stripe.com` → `stripe.com`). Simple last-2-labels heuristic;
+ * wrong for `.co.uk` and friends, but right for ~all consumer SaaS the
+ * connections page targets, and `faviconV2`'s `fallback_opts` cushions
+ * the rest.
+ */
+export function brandDomain(host: string): string {
+ const parts = host.split(".").filter(Boolean);
+ if (parts.length <= 2) return host;
+ return parts.slice(-2).join(".");
+}
diff --git a/notfair-cmo/src/server/actions/mcp.ts b/notfair-cmo/src/server/actions/mcp.ts
index cdd39bcc..8e3aceb6 100644
--- a/notfair-cmo/src/server/actions/mcp.ts
+++ b/notfair-cmo/src/server/actions/mcp.ts
@@ -10,6 +10,7 @@ import { disconnectMcp as runDisconnect } from "@/server/mcp/state";
import {
insertUserMcpServer,
findUserMcpServer,
+ findUserMcpServerByResourceUrl,
deleteUserMcpServer,
} from "@/server/db/user-mcp-servers";
import { slugify } from "@/lib/slug";
@@ -53,9 +54,16 @@ export async function startMcpConnect(input: {
const origin = await originFromIncomingRequest();
const redirect_uri = `${origin}/api/mcp-oauth/callback`;
+ const auth_method = pickClientAuthMethod(
+ resolved.token_endpoint_auth_methods_supported,
+ );
let dcr: DcrResponse;
try {
- dcr = await dynamicRegister(resolved.registration_endpoint, redirect_uri);
+ dcr = await dynamicRegister(
+ resolved.registration_endpoint,
+ redirect_uri,
+ auth_method,
+ );
} catch (err) {
return { ok: false, error: `Registration failed: ${humanError(err)}` };
}
@@ -232,21 +240,35 @@ export type AddUserMcpServerResult =
| { ok: true; key: string }
| { ok: false; error: string; kind: AddFailureKind };
-type AddFailureKind = ProbeFailureKind | "no_project" | "name_unusable" | "key_in_use";
+type AddFailureKind = ProbeFailureKind | "no_project" | "name_unusable";
+
+const KEY_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
/**
- * Register a user-added MCP server for the active project.
+ * Register an MCP server for the active project — idempotent.
+ *
+ * - If `key` matches a preset (e.g. `notfair-googleads`), the action
+ * only ensures the key is *unhidden* (clears the per-project
+ * hide-list). No row is written; the preset entry surfaces again via
+ * `getMcpCatalog`.
+ * - If a `user_mcp_servers` row for the key already exists, the action
+ * is a no-op success — used by Browse-connectors so re-clicking a
+ * tile after a canceled OAuth simply re-runs `startMcpConnect`
+ * instead of erroring on "already exists".
+ * - Otherwise probes RFC 9728 discovery + DCR; on success, inserts a
+ * new `user_mcp_servers` row.
*
- * Slugs the display name into a stable `key` (also used as
- * `mcp_tokens.server_name` post-connect), probes discovery to confirm the
- * server is OAuth-2.0-with-DCR connectable, and writes a row to
- * `user_mcp_servers`. The user then clicks Connect on the resulting card
- * to drive the existing OAuth flow.
+ * `key` accepts a stable preset/connector identifier to bypass
+ * slugification (e.g. Browse passes `notfair-googleads` directly so it
+ * matches the preset key rather than `slugify("NotFair Google Ads")` =
+ * `notfair-google-ads`). When omitted, the display name is slugified.
*/
export async function addUserMcpServerAction(input: {
display_name: string;
description?: string;
resource_url: string;
+ /** Optional canonical key override (used by Browse connectors). */
+ key?: string;
}): Promise<AddUserMcpServerResult> {
const project = await getActiveProject();
if (!project) {
@@ -256,42 +278,74 @@ export async function addUserMcpServerAction(input: {
error: "No active project. Pick one before adding an MCP server.",
};
}
- const slug = slugify(input.display_name);
- if (!slug.ok) {
- return {
- ok: false,
- kind: "name_unusable",
- error: `Can't derive a key from this name: ${slug.reason}.`,
- };
+
+ let key: string;
+ if (input.key && KEY_PATTERN.test(input.key)) {
+ key = input.key;
+ } else {
+ const slug = slugify(input.display_name);
+ if (!slug.ok) {
+ return {
+ ok: false,
+ kind: "name_unusable",
+ error: `Can't derive a key from this name: ${slug.reason}.`,
+ };
+ }
+ key = slug.slug;
}
- if (isPresetKey(slug.slug) || findUserMcpServer(project.slug, slug.slug)) {
- return {
- ok: false,
- kind: "key_in_use",
- error: `An MCP server named '${slug.slug}' already exists in this project.`,
- };
+
+ // Preset re-add: just un-hide. No row to write, no discovery probe.
+ if (isPresetKey(key)) {
+ const { removeHiddenMcpPresetKey } = await import("@/server/db/projects");
+ removeHiddenMcpPresetKey(project.slug, key);
+ revalidatePath("/", "layout");
+ return { ok: true, key };
+ }
+
+ // User row already exists for this key — Browse "click again" path.
+ if (findUserMcpServer(project.slug, key)) {
+ return { ok: true, key };
}
+
+ // Same MCP server (same URL) is already in this project under a
+ // different key — e.g. NotFair Meta Ads was added pre-canonical-id and
+ // saved as `notfair-meta-ads`, while the tile click would use
+ // `notfair-metaads`. Treat as an idempotent re-pick: return the
+ // existing key so the connect chain reuses it instead of writing a
+ // duplicate row.
+ const existingByUrl = findUserMcpServerByResourceUrl(
+ project.slug,
+ input.resource_url,
+ );
+ if (existingByUrl) {
+ return { ok: true, key: existingByUrl.key };
+ }
+
const probe = await probeMcpDiscovery({ resource_url: input.resource_url });
if (!probe.ok) return probe;
insertUserMcpServer({
project_slug: project.slug,
- key: slug.slug,
+ key,
display_name: input.display_name.trim(),
description: input.description?.trim() ?? "",
resource_url: input.resource_url.trim(),
discovery_url: probe.discovery_url,
});
revalidatePath("/", "layout");
- return { ok: true, key: slug.slug };
+ return { ok: true, key };
}
/**
- * Remove a user-added MCP server from the active project. Drops the
- * stored bearer (if any), unregisters from every agent's harness config,
- * and deletes the catalog row.
+ * Remove an MCP server from the active project. Works on both presets
+ * and user rows:
+ *
+ * - Preset: appends the key to `projects.hidden_mcp_preset_keys_json`
+ * so `getMcpCatalog` filters it out from now on. Token + adapter
+ * cleanup runs the same way.
+ * - User row: deletes the `user_mcp_servers` row.
*
- * Presets cannot be removed this way — the action refuses unknown or
- * preset keys.
+ * Either path also drops the stored bearer and unregisters from every
+ * agent's harness config.
*/
export async function removeUserMcpServerAction(input: {
mcp_key: string;
@@ -300,17 +354,19 @@ export async function removeUserMcpServerAction(input: {
if (!project) {
return { ok: false, error: "No active project." };
}
- if (isPresetKey(input.mcp_key)) {
- return { ok: false, error: "Preset MCP servers can't be removed." };
- }
- const row = findUserMcpServer(project.slug, input.mcp_key);
- if (!row) {
- return { ok: false, error: `Unknown MCP key: ${input.mcp_key}.` };
+ const isPreset = isPresetKey(input.mcp_key);
+ if (!isPreset) {
+ const row = findUserMcpServer(project.slug, input.mcp_key);
+ if (!row) {
+ return { ok: false, error: `Unknown MCP key: ${input.mcp_key}.` };
+ }
}
try {
await runDisconnect(project.slug, input.mcp_key);
const { listProjectAgents } = await import("@/server/agent-meta");
- const { getProject } = await import("@/server/db/projects");
+ const { getProject, addHiddenMcpPresetKey } = await import(
+ "@/server/db/projects"
+ );
const { requireAdapter } = await import("@/server/adapters/registry");
const proj = getProject(project.slug);
if (proj) {
@@ -324,7 +380,11 @@ export async function removeUserMcpServerAction(input: {
}
}
}
- deleteUserMcpServer(project.slug, input.mcp_key);
+ if (isPreset) {
+ addHiddenMcpPresetKey(project.slug, input.mcp_key);
+ } else {
+ deleteUserMcpServer(project.slug, input.mcp_key);
+ }
} catch (err) {
return { ok: false, error: humanError(err) };
}
@@ -339,8 +399,17 @@ type ResolvedAuthServer = {
authorization_endpoint: string;
token_endpoint: string;
registration_endpoint: string;
+ /**
+ * The AS's advertised auth methods for the token endpoint. Drives DCR
+ * registration: we prefer the public-PKCE `none` method when the AS
+ * supports it (MCP spec default), and fall back to `client_secret_post`
+ * for servers like Supabase that don't accept public clients.
+ */
+ token_endpoint_auth_methods_supported: string[];
};
+type ClientAuthMethod = "none" | "client_secret_post";
+
class ProbeError extends Error {
kind: ProbeFailureKind;
constructor(kind: ProbeFailureKind, message: string) {
@@ -406,14 +475,33 @@ async function resolveAuthServer(
"AS metadata is missing registration_endpoint — dynamic client registration is required.",
);
}
+ const advertised = (meta as Record<string, unknown>)
+ .token_endpoint_auth_methods_supported;
return {
issuer,
authorization_endpoint: meta.authorization_endpoint,
token_endpoint: meta.token_endpoint,
registration_endpoint: meta.registration_endpoint,
+ token_endpoint_auth_methods_supported: Array.isArray(advertised)
+ ? advertised.filter((s): s is string => typeof s === "string")
+ : [],
};
}
+/**
+ * Pick a token-endpoint auth method that the AS supports AND we know
+ * how to drive at the callback. We prefer `none` (PKCE-only, MCP-spec
+ * default); when the AS doesn't advertise it (Supabase, some OIDC
+ * providers) we fall back to `client_secret_post`. `client_secret_basic`-
+ * only servers aren't supported — the callback's token exchange sends
+ * the secret in the POST body, not the Authorization header.
+ */
+function pickClientAuthMethod(supported: string[]): ClientAuthMethod {
+ if (supported.length === 0) return "none";
+ if (supported.includes("none")) return "none";
+ return "client_secret_post";
+}
+
/**
* Build the AS-metadata URLs to probe, in priority order, for a given
* issuer. The "inserted" variants are spec-correct (RFC 8414 §3.1 / OIDC
@@ -466,17 +554,19 @@ type DcrResponse = {
async function dynamicRegister(
registration_endpoint: string,
redirect_uri: string,
+ auth_method: ClientAuthMethod,
): Promise<DcrResponse> {
- // Register as `none` (public client) so we drive token exchange with
- // PKCE + no secret per the MCP spec. Servers that don't yet support
- // public clients will still return a client_secret — we keep it for
- // back-compat fallback, but the token handler favors PKCE.
+ // PKCE-only `none` is the MCP-spec default for public clients. Some
+ // OAuth servers (Supabase, certain OIDC providers) reject `none` and
+ // require a confidential client; for those we register as
+ // `client_secret_post` — the AS returns a client_secret which the
+ // callback then sends alongside the code at token exchange.
const body = {
client_name: "notfair-cmo",
redirect_uris: [redirect_uri],
grant_types: ["authorization_code"],
response_types: ["code"],
- token_endpoint_auth_method: "none",
+ token_endpoint_auth_method: auth_method,
};
const res = await fetch(registration_endpoint, {
method: "POST",
@@ -512,10 +602,16 @@ async function originFromIncomingRequest(): Promise<string> {
const h = await headers();
// Next surfaces forwarded headers when behind a proxy; fall back to host.
const proto = h.get("x-forwarded-proto") ?? "http";
- const host = h.get("x-forwarded-host") ?? h.get("host");
- if (!host) {
+ const rawHost = h.get("x-forwarded-host") ?? h.get("host");
+ if (!rawHost) {
throw new Error("Could not derive origin from request headers");
}
+ // RFC 8252 §7.3 says native OAuth clients use the loopback IP (127.0.0.1)
+ // rather than the `localhost` hostname; some providers (Vercel) enforce
+ // this and reject `http://localhost` as an "invalid redirect URL".
+ // Normalize so the registered + exchanged redirect URI is loopback-IP
+ // regardless of which form the user typed into the address bar.
+ const host = rawHost.replace(/^localhost(:|$)/, "127.0.0.1$1");
return `${proto}://${host}`;
}
diff --git a/notfair-cmo/src/server/db/migrations.ts b/notfair-cmo/src/server/db/migrations.ts
index c5040575..3790b7fc 100644
--- a/notfair-cmo/src/server/db/migrations.ts
+++ b/notfair-cmo/src/server/db/migrations.ts
@@ -505,6 +505,21 @@ CREATE TABLE IF NOT EXISTS user_mcp_servers (
UNIQUE(project_slug, key)
);
CREATE INDEX IF NOT EXISTS idx_user_mcp_servers_project ON user_mcp_servers(project_slug);
+`,
+ },
+ {
+ name: "012_hidden_mcp_presets.sql",
+ sql: `
+-- Migration 012: per-project hide-list for preset MCP catalog entries.
+--
+-- Users can now "remove" a preset connector (NotFair Google Ads, etc.)
+-- from a project's Connections page. Since the preset list is hardcoded
+-- in source, removal stores the key in this column and getMcpCatalog
+-- filters it out. Re-adding from "Browse connectors" deletes the key
+-- here, so the preset reappears.
+
+ALTER TABLE projects
+ ADD COLUMN hidden_mcp_preset_keys_json TEXT NOT NULL DEFAULT '[]';
`,
},
];
diff --git a/notfair-cmo/src/server/db/migrations/012_hidden_mcp_presets.sql b/notfair-cmo/src/server/db/migrations/012_hidden_mcp_presets.sql
new file mode 100644
index 00000000..078e0468
--- /dev/null
+++ b/notfair-cmo/src/server/db/migrations/012_hidden_mcp_presets.sql
@@ -0,0 +1,13 @@
+-- Migration 012: per-project hide-list for preset MCP catalog entries.
+--
+-- Users can now "remove" a preset connector (NotFair Google Ads, etc.)
+-- from a project's Connections page. Since the preset list is hardcoded
+-- in source, removal stores the key in this column and getMcpCatalog
+-- filters it out. Re-adding from "Browse connectors" deletes the key
+-- here, so the preset reappears.
+--
+-- JSON-encoded string array, NOT NULL, defaulting to '[]' so existing
+-- rows behave like "no presets hidden".
+
+ALTER TABLE projects
+ ADD COLUMN hidden_mcp_preset_keys_json TEXT NOT NULL DEFAULT '[]';
diff --git a/notfair-cmo/src/server/db/projects.ts b/notfair-cmo/src/server/db/projects.ts
index 0439c981..277f9505 100644
--- a/notfair-cmo/src/server/db/projects.ts
+++ b/notfair-cmo/src/server/db/projects.ts
@@ -257,3 +257,43 @@ export function deleteProjectRow(slug: string): void {
}
db.prepare("DELETE FROM projects WHERE slug = ?").run(slug);
}
+
+/**
+ * Per-project hide-list for preset MCP catalog entries. See migration
+ * 012 — the column stores a JSON-encoded `string[]` so we can grow it
+ * without schema changes.
+ */
+export function getHiddenMcpPresetKeys(slug: string): string[] {
+ const row = getDb()
+ .prepare(
+ "SELECT hidden_mcp_preset_keys_json AS j FROM projects WHERE slug = ?",
+ )
+ .get(slug) as { j: string } | undefined;
+ if (!row?.j) return [];
+ try {
+ const parsed = JSON.parse(row.j);
+ return Array.isArray(parsed)
+ ? parsed.filter((k): k is string => typeof k === "string")
+ : [];
+ } catch {
+ return [];
+ }
+}
+
+export function addHiddenMcpPresetKey(slug: string, key: string): void {
+ const current = getHiddenMcpPresetKeys(slug);
+ if (current.includes(key)) return;
+ const next = [...current, key];
+ getDb()
+ .prepare("UPDATE projects SET hidden_mcp_preset_keys_json = ? WHERE slug = ?")
+ .run(JSON.stringify(next), slug);
+}
+
+export function removeHiddenMcpPresetKey(slug: string, key: string): void {
+ const current = getHiddenMcpPresetKeys(slug);
+ const next = current.filter((k) => k !== key);
+ if (next.length === current.length) return;
+ getDb()
+ .prepare("UPDATE projects SET hidden_mcp_preset_keys_json = ? WHERE slug = ?")
+ .run(JSON.stringify(next), slug);
+}
diff --git a/notfair-cmo/src/server/db/user-mcp-servers.ts b/notfair-cmo/src/server/db/user-mcp-servers.ts
index 2411d2cc..e6dd06a5 100644
--- a/notfair-cmo/src/server/db/user-mcp-servers.ts
+++ b/notfair-cmo/src/server/db/user-mcp-servers.ts
@@ -1,5 +1,6 @@
import { randomUUID } from "node:crypto";
import { getDb } from "@/server/db/db";
+import { normalizeResourceUrl } from "@/server/mcp/discovery-url";
/**
* Project-scoped storage for user-added MCP servers.
@@ -78,6 +79,23 @@ export function findUserMcpServer(
);
}
+/**
+ * Find a row by normalized resource URL. Used to detect "this server is
+ * already in the project" even when the key the caller would create
+ * differs from the stored key (legacy slugification mismatches, etc).
+ */
+export function findUserMcpServerByResourceUrl(
+ project_slug: string,
+ resource_url: string,
+): UserMcpServer | null {
+ const target = normalizeResourceUrl(resource_url);
+ return (
+ listUserMcpServers(project_slug).find(
+ (row) => normalizeResourceUrl(row.resource_url) === target,
+ ) ?? null
+ );
+}
+
export function listUserMcpServers(project_slug: string): UserMcpServer[] {
return getDb()
.prepare(
diff --git a/notfair-cmo/src/server/mcp-catalog.ts b/notfair-cmo/src/server/mcp-catalog.ts
index 15a028fb..e00aa647 100644
--- a/notfair-cmo/src/server/mcp-catalog.ts
+++ b/notfair-cmo/src/server/mcp-catalog.ts
@@ -18,6 +18,7 @@
*/
import { listUserMcpServers } from "@/server/db/user-mcp-servers";
+import { getHiddenMcpPresetKeys } from "@/server/db/projects";
export type McpSpec = {
/** Stable catalog identifier (used by the UI + mcp_tokens.server_name). */
@@ -60,7 +61,8 @@ export function getMcpPresets(): McpSpec[] {
* action prevents at insert time, but we double-check on read too).
*/
export function getMcpCatalog(project_slug: string): McpSpec[] {
- const presets = MCP_CATALOG_PRESETS;
+ const hidden = new Set(getHiddenMcpPresetKeys(project_slug));
+ const presets = MCP_CATALOG_PRESETS.filter((p) => !hidden.has(p.key));
const presetKeys = new Set(presets.map((p) => p.key));
const userRows = listUserMcpServers(project_slug)
.filter((row) => !presetKeys.has(row.key))
diff --git a/notfair-cmo/src/server/mcp/discovery-url.ts b/notfair-cmo/src/server/mcp/discovery-url.ts
index 46cde053..8f567418 100644
--- a/notfair-cmo/src/server/mcp/discovery-url.ts
+++ b/notfair-cmo/src/server/mcp/discovery-url.ts
@@ -1,3 +1,32 @@
+/**
+ * Normalize an MCP resource URL into a stable comparable form: lowercase
+ * scheme + host, preserve case-sensitive path, drop trailing slashes,
+ * and remove any default port. Used to detect "this server is already
+ * in the project" regardless of how the user typed the URL or how it
+ * was slugified into a key historically.
+ *
+ * Returns the input unchanged when it can't be parsed — better to miss
+ * a match than crash a render.
+ */
+export function normalizeResourceUrl(url: string): string {
+ let u: URL;
+ try {
+ u = new URL(url);
+ } catch {
+ return url.trim().toLowerCase().replace(/\/+$/, "");
+ }
+ const scheme = u.protocol.toLowerCase();
+ const host = u.hostname.toLowerCase();
+ const port =
+ (scheme === "https:" && u.port === "443") ||
+ (scheme === "http:" && u.port === "80") ||
+ !u.port
+ ? ""
+ : `:${u.port}`;
+ const path = u.pathname.replace(/\/+$/, "");
+ return `${scheme}//${host}${port}${path}`;
+}
+
/**
* Derive the RFC 9728 protected-resource discovery URL from a resource URL.
*
diff --git a/notfair-cmo/src/server/mcp/rpc.ts b/notfair-cmo/src/server/mcp/rpc.ts
index 5b3c090a..faad8092 100644
--- a/notfair-cmo/src/server/mcp/rpc.ts
+++ b/notfair-cmo/src/server/mcp/rpc.ts
@@ -26,7 +26,7 @@ export interface McpConfig {
export type RpcResult<T> =
| { ok: true; result: T }
- | { ok: false; kind: "http_error"; status: number }
+ | { ok: false; kind: "http_error"; status: number; body?: string }
| { ok: false; kind: "timeout" }
| { ok: false; kind: "aborted" }
| { ok: false; kind: "network_error"; message: string }
@@ -109,6 +109,12 @@ export async function mcpRpc<T = unknown>(
"Content-Type": "application/json",
Accept: "application/json, text/event-stream",
Authorization: `Bearer ${token}`,
+ // MCP Streamable-HTTP 2025-06-18 §3.3: clients SHOULD declare
+ // the intended protocol version on every request, and strict
+ // servers (Supabase, etc.) return HTTP 400 when it's absent.
+ // Lenient servers (Stripe, NotFair) ignore it. Safe to send
+ // unconditionally.
+ "MCP-Protocol-Version": "2025-06-18",
},
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
signal: controller.signal,
@@ -125,8 +131,19 @@ export async function mcpRpc<T = unknown>(
}
if (!res.ok) {
+ // Try to capture the body so callers can surface the real upstream
+ // error (e.g. Supabase's "must initialize first" or a missing-scope
+ // message). Best-effort: if the read fails or the body is huge, fall
+ // back to just the status.
+ let errBody: string | undefined;
+ try {
+ const raw = await res.text();
+ errBody = raw.trim() ? raw.slice(0, 500) : undefined;
+ } catch {
+ // ignore
+ }
cleanup();
- return { ok: false, kind: "http_error", status: res.status };
+ return { ok: false, kind: "http_error", status: res.status, body: errBody };
}
let body: string;
diff --git a/notfair-cmo/src/server/mcp/state.ts b/notfair-cmo/src/server/mcp/state.ts
index fbb2f18a..76fa68c6 100644
--- a/notfair-cmo/src/server/mcp/state.ts
+++ b/notfair-cmo/src/server/mcp/state.ts
@@ -46,18 +46,28 @@ export async function getMcpStatus(
async function probe(url: string, token: string): Promise<McpRuntimeStatus> {
const last_checked_at = new Date().toISOString();
- const r = await mcpRpc<{ tools?: unknown }>(
+ // Use `initialize` — the spec-mandated first call — as the liveness
+ // probe. Some MCP servers (Supabase) reject `tools/list` with HTTP 400
+ // when no prior initialize has happened; `initialize` is universally
+ // accepted as the opening message. We don't track the session ID since
+ // we're not following up with another call in the probe; tool count
+ // gets surfaced on demand via the View tools dialog (its own RPC).
+ const r = await mcpRpc<unknown>(
url,
token,
- "tools/list",
- {},
+ "initialize",
+ {
+ protocolVersion: "2025-06-18",
+ capabilities: {},
+ clientInfo: { name: "notfair-cmo", version: "0.3.1" },
+ },
{ timeoutMs: 2000 },
);
if (r.ok) {
return {
state: "connected",
url,
- tools_count: countToolsFromResult(r.result),
+ tools_count: null,
last_checked_at,
};
}
@@ -65,7 +75,12 @@ async function probe(url: string, token: string): Promise<McpRuntimeStatus> {
return { state: "stale_token", url, http_status: r.status, last_checked_at };
}
if (r.kind === "http_error") {
- return { state: "unreachable", url, error: `HTTP ${r.status}`, last_checked_at };
+ return {
+ state: "unreachable",
+ url,
+ error: r.body ? `HTTP ${r.status}: ${r.body}` : `HTTP ${r.status}`,
+ last_checked_at,
+ };
}
if (r.kind === "timeout") {
return { state: "unreachable", url, error: "timed out", last_checked_at };
@@ -92,12 +107,6 @@ async function probe(url: string, token: string): Promise<McpRuntimeStatus> {
return { state: "unreachable", url, error: r.message, last_checked_at };
}
-function countToolsFromResult(result: { tools?: unknown } | undefined): number | null {
- if (!result || typeof result !== "object") return null;
- if (!Array.isArray(result.tools)) return null;
- return result.tools.length;
-}
-
export async function disconnectMcp(project_slug: string, catalog_key: string): Promise<void> {
const token = findMcpToken(project_slug, catalog_key);
if (token) deleteMcpToken(token.id);
diff --git a/notfair-cmo/src/server/trusted-connectors.ts b/notfair-cmo/src/server/trusted-connectors.ts
new file mode 100644
index 00000000..ca6e87e8
--- /dev/null
+++ b/notfair-cmo/src/server/trusted-connectors.ts
@@ -0,0 +1,74 @@
+/**
+ * Browseable directory of trusted MCP servers shown in the "Browse
+ * connectors" dialog. Distinct from `MCP_CATALOG_PRESETS` (which is
+ * always-visible per project): these are opt-in. Picking one writes a
+ * row to `user_mcp_servers` via `addUserMcpServerAction` and triggers
+ * the usual OAuth probe before persisting.
+ *
+ * The `resource_url`s here are the ones the providers publish; if a
+ * vendor moves their MCP, the probe will surface the error and the
+ * user can paste the correct URL via "Add custom connector" until we
+ * update this list.
+ *
+ * **Why Vercel isn't here:**
+ *
+ * Vercel's DCR endpoint silently returns a single fixed `client_id`
+ * (`cl_WbdtcToDrMR4ZHvXLGAmbfoYCsQjMeS8`) regardless of the request body,
+ * and that client's pre-approved redirect-URI allowlist excludes every
+ * loopback URI — verified with multiple `redirect_uri` shapes. Vercel's
+ * MCP is wired only for their first-party integrations (Claude Desktop,
+ * Cursor, etc., each with hardcoded redirect URIs Vercel approved out
+ * of band); arbitrary OAuth-2.1 + DCR clients can't complete the flow
+ * until Vercel opens up DCR or adds an allowlist entry for us.
+ *
+ * Users can still try via "Add custom connector"; presenting Vercel in
+ * the curated grid would just produce a guaranteed failure toast.
+ */
+
+export type TrustedConnector = {
+ /** Used purely for React keys + stable slugs in tests. */
+ id: string;
+ display_name: string;
+ description: string;
+ /** HTTPS resource URL the OAuth flow targets. */
+ resource_url: string;
+};
+
+export const TRUSTED_CONNECTORS: TrustedConnector[] = [
+ {
+ id: "notfair-googleads",
+ display_name: "NotFair Google Ads",
+ description: "Campaigns, bids, keywords, search terms.",
+ resource_url: "https://notfair.co/api/mcp/google_ads",
+ },
+ {
+ id: "notfair-metaads",
+ display_name: "NotFair Meta Ads",
+ description: "Facebook + Instagram campaigns, ad sets, budgets.",
+ resource_url: "https://notfair.co/api/mcp/meta_ads",
+ },
+ {
+ id: "stripe",
+ display_name: "Stripe",
+ description: "Payments, customers, subscriptions, invoices.",
+ resource_url: "https://mcp.stripe.com/",
+ },
+ {
+ id: "supabase",
+ display_name: "Supabase",
+ description: "Postgres, auth, storage, edge functions.",
+ resource_url: "https://mcp.supabase.com/mcp",
+ },
+ {
+ id: "posthog",
+ display_name: "PostHog",
+ description: "Product analytics, funnels, feature flags.",
+ resource_url: "https://mcp.posthog.com/mcp",
+ },
+ {
+ id: "mixpanel",
+ display_name: "Mixpanel",
+ description: "Event analytics, cohorts, retention.",
+ resource_url: "https://mcp.mixpanel.com/mcp",
+ },
+];