Skip to content

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

Point nested dashboard MCP catalog at the canonical NotFair URL

Yuting Zhong7270136d9887
diff --git a/notfair/src/components/browse-connectors-dialog.test.tsx b/notfair/src/components/browse-connectors-dialog.test.tsx
index 91546796..bf4769a3 100644
--- a/notfair/src/components/browse-connectors-dialog.test.tsx
+++ b/notfair/src/components/browse-connectors-dialog.test.tsx
@@ -58,6 +58,22 @@ describe("BrowseConnectorsDialog", () => {
expect(screen.getByText("NotFair Meta Ads")).toBeInTheDocument();
});
+ it("hides every NotFair tile once the canonical resource URL is connected", () => {
+ render(
+ <BrowseConnectorsDialog
+ open
+ onOpenChange={vi.fn()}
+ onAddCustom={vi.fn()}
+ connectedResourceUrls={["https://notfair.co/api/mcp/notfair"]}
+ />,
+ );
+ expect(screen.queryByText("NotFair Google Ads")).toBeNull();
+ expect(screen.queryByText("NotFair Meta Ads")).toBeNull();
+ expect(screen.queryByText("NotFair Google Search Console")).toBeNull();
+ expect(screen.queryByText("NotFair Google Analytics")).toBeNull();
+ expect(screen.getByText("Stripe")).toBeInTheDocument();
+ });
+
it("shows an empty state when everything is already connected", () => {
render(
<BrowseConnectorsDialog
@@ -118,7 +134,7 @@ describe("BrowseConnectorsDialog", () => {
await waitFor(() => {
expect(addServer).toHaveBeenCalledWith({
display_name: "NotFair Google Ads",
- resource_url: "https://notfair.co/api/mcp/google_ads",
+ resource_url: "https://notfair.co/api/mcp/notfair",
key: "notfair-googleads",
});
expect(startConnect).toHaveBeenCalledWith({
diff --git a/notfair/src/components/mcp-card.more.test.tsx b/notfair/src/components/mcp-card.more.test.tsx
index 04d0845a..73db91af 100644
--- a/notfair/src/components/mcp-card.more.test.tsx
+++ b/notfair/src/components/mcp-card.more.test.tsx
@@ -41,9 +41,9 @@ const xadsSpec: McpSpec = {
key: "notfair-xads",
display_name: "NotFair X Ads",
description: "X Ads campaigns.",
- resource_url: "https://notfair.co/api/mcp/x_ads",
+ resource_url: "https://notfair.co/api/mcp/notfair",
discovery_url:
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/x_ads",
+ "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/notfair",
source: "preset",
};
diff --git a/notfair/src/components/mcp-card.test.tsx b/notfair/src/components/mcp-card.test.tsx
index f14725c9..30319d1f 100644
--- a/notfair/src/components/mcp-card.test.tsx
+++ b/notfair/src/components/mcp-card.test.tsx
@@ -28,9 +28,9 @@ const gscSpec: McpSpec = {
key: "notfair-googlesearchconsole",
display_name: "NotFair Google Search Console",
description: "Organic search performance.",
- resource_url: "https://notfair.co/api/mcp/google_search_console",
+ resource_url: "https://notfair.co/api/mcp/notfair",
discovery_url:
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/google_search_console",
+ "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/notfair",
source: "preset",
};
@@ -38,7 +38,7 @@ const xadsSpec: McpSpec = {
...gscSpec,
key: "notfair-xads",
display_name: "NotFair X Ads",
- resource_url: "https://notfair.co/api/mcp/x_ads",
+ resource_url: "https://notfair.co/api/mcp/notfair",
};
const connected: McpRuntimeStatus = { state: "connected" } as McpRuntimeStatus;
diff --git a/notfair/src/lib/canonical-mcp.ts b/notfair/src/lib/canonical-mcp.ts
new file mode 100644
index 00000000..913e5a38
--- /dev/null
+++ b/notfair/src/lib/canonical-mcp.ts
@@ -0,0 +1,4 @@
+/** The only NotFair MCP resource new connections should advertise. */
+export const CANONICAL_MCP_RESOURCE_URL = "https://notfair.co/api/mcp/notfair";
+export const CANONICAL_MCP_DISCOVERY_URL =
+ "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/notfair";
diff --git a/notfair/src/server/actions/mcp.test.ts b/notfair/src/server/actions/mcp.test.ts
index 89a934b4..9a187fbf 100644
--- a/notfair/src/server/actions/mcp.test.ts
+++ b/notfair/src/server/actions/mcp.test.ts
@@ -463,7 +463,7 @@ describe("addUserMcpServerAction", () => {
addHiddenMcpPresetKey(SLUG, "notfair-googleads");
const r = await addUserMcpServerAction({
display_name: "NotFair Google Ads",
- resource_url: "https://notfair.co/api/mcp/google_ads",
+ resource_url: "https://notfair.co/api/mcp/notfair",
key: "notfair-googleads",
});
expect(r).toEqual({ ok: true, key: "notfair-googleads" });
diff --git a/notfair/src/server/mcp-catalog.test.ts b/notfair/src/server/mcp-catalog.test.ts
index aff25697..e9e5dd6e 100644
--- a/notfair/src/server/mcp-catalog.test.ts
+++ b/notfair/src/server/mcp-catalog.test.ts
@@ -51,6 +51,17 @@ describe("isPresetKey / getMcpPresets", () => {
expect(getMcpPresets()).toBe(MCP_CATALOG_PRESETS);
expect(getMcpPresets().every((p) => p.source === "preset")).toBe(true);
});
+
+ it("points every NotFair preset at the canonical MCP resource", () => {
+ expect(new Set(MCP_CATALOG_PRESETS.map((p) => p.resource_url))).toEqual(
+ new Set(["https://notfair.co/api/mcp/notfair"]),
+ );
+ expect(new Set(MCP_CATALOG_PRESETS.map((p) => p.discovery_url))).toEqual(
+ new Set([
+ "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/notfair",
+ ]),
+ );
+ });
});
describe("getMcpCatalog", () => {
diff --git a/notfair/src/server/mcp-catalog.ts b/notfair/src/server/mcp-catalog.ts
index e03bb614..a05c1e18 100644
--- a/notfair/src/server/mcp-catalog.ts
+++ b/notfair/src/server/mcp-catalog.ts
@@ -19,6 +19,15 @@
import { listUserMcpServers } from "@/server/db/user-mcp-servers";
import { getHiddenMcpPresetKeys } from "@/server/db/projects";
+import {
+ CANONICAL_MCP_DISCOVERY_URL,
+ CANONICAL_MCP_RESOURCE_URL,
+} from "@/lib/canonical-mcp";
+
+export {
+ CANONICAL_MCP_DISCOVERY_URL,
+ CANONICAL_MCP_RESOURCE_URL,
+} from "@/lib/canonical-mcp";
export type McpSpec = {
/** Stable catalog identifier (used by the UI + mcp_tokens.server_name). */
@@ -39,9 +48,8 @@ export const MCP_CATALOG_PRESETS: McpSpec[] = [
display_name: "NotFair Google Ads",
description:
"Live Google Ads operations: campaigns, bids, budgets, keywords, search terms, change history.",
- resource_url: "https://notfair.co/api/mcp/google_ads",
- discovery_url:
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/google_ads",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
+ discovery_url: CANONICAL_MCP_DISCOVERY_URL,
source: "preset",
},
{
@@ -49,9 +57,8 @@ export const MCP_CATALOG_PRESETS: McpSpec[] = [
display_name: "NotFair Meta Ads",
description:
"Live Meta Ads (Facebook + Instagram) operations: campaigns, ad sets, ads, creatives, insights.",
- resource_url: "https://notfair.co/api/mcp/meta_ads",
- discovery_url:
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/meta_ads",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
+ discovery_url: CANONICAL_MCP_DISCOVERY_URL,
source: "preset",
},
{
@@ -59,9 +66,8 @@ export const MCP_CATALOG_PRESETS: McpSpec[] = [
display_name: "NotFair Google Search Console",
description:
"Organic search performance: queries, pages, impressions, clicks, indexing.",
- resource_url: "https://notfair.co/api/mcp/google_search_console",
- discovery_url:
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/google_search_console",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
+ discovery_url: CANONICAL_MCP_DISCOVERY_URL,
source: "preset",
},
{
@@ -69,9 +75,8 @@ export const MCP_CATALOG_PRESETS: McpSpec[] = [
display_name: "NotFair Google Analytics",
description:
"GA4 traffic and conversion analytics: sessions, channels, pages, events, audiences.",
- resource_url: "https://notfair.co/api/mcp/google_analytics",
- discovery_url:
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/google_analytics",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
+ discovery_url: CANONICAL_MCP_DISCOVERY_URL,
source: "preset",
},
{
@@ -79,9 +84,8 @@ export const MCP_CATALOG_PRESETS: McpSpec[] = [
display_name: "NotFair X Ads",
description:
"Live X (Twitter) Ads operations: campaigns, line items, promoted posts, analytics.",
- resource_url: "https://notfair.co/api/mcp/x_ads",
- discovery_url:
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/x_ads",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
+ discovery_url: CANONICAL_MCP_DISCOVERY_URL,
source: "preset",
},
];
diff --git a/notfair/src/server/mcp/catalog-token.test.ts b/notfair/src/server/mcp/catalog-token.test.ts
new file mode 100644
index 00000000..01ea03e0
--- /dev/null
+++ b/notfair/src/server/mcp/catalog-token.test.ts
@@ -0,0 +1,73 @@
+import { beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ getMcpCatalog: vi.fn(),
+ mcpSpecByKey: vi.fn(),
+ findMcpToken: vi.fn(),
+}));
+
+vi.mock("@/server/mcp-catalog", () => ({
+ getMcpCatalog: mocks.getMcpCatalog,
+ mcpSpecByKey: mocks.mcpSpecByKey,
+}));
+vi.mock("@/server/mcp/tokens", () => ({
+ findMcpToken: mocks.findMcpToken,
+}));
+
+import {
+ catalogKeysSharingResource,
+ findCatalogMcpToken,
+} from "./catalog-token";
+
+const CANONICAL = "https://notfair.co/api/mcp/notfair";
+const STRIPE = "https://mcp.stripe.com/mcp";
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.getMcpCatalog.mockReturnValue([
+ { key: "notfair-googleads", resource_url: CANONICAL },
+ { key: "notfair-metaads", resource_url: CANONICAL },
+ { key: "stripe", resource_url: STRIPE },
+ ]);
+ mocks.mcpSpecByKey.mockImplementation((_slug: string, key: string) =>
+ mocks.getMcpCatalog().find((entry: { key: string }) => entry.key === key),
+ );
+ mocks.findMcpToken.mockReturnValue(null);
+});
+
+describe("findCatalogMcpToken", () => {
+ it("returns the direct token when present", () => {
+ mocks.findMcpToken.mockImplementation((_slug: string, key: string) =>
+ key === "notfair-metaads" ? { id: "tok-m" } : null,
+ );
+ expect(findCatalogMcpToken("proj", "notfair-metaads")).toEqual({ id: "tok-m" });
+ });
+
+ it("falls back to a sibling catalog key with the same resource URL", () => {
+ mocks.findMcpToken.mockImplementation((_slug: string, key: string) =>
+ key === "notfair-googleads" ? { id: "tok-g" } : null,
+ );
+ expect(findCatalogMcpToken("proj", "notfair-metaads")).toEqual({ id: "tok-g" });
+ });
+
+ it("does not reuse a token from a different resource URL", () => {
+ mocks.findMcpToken.mockImplementation((_slug: string, key: string) =>
+ key === "stripe" ? { id: "tok-s" } : null,
+ );
+ expect(findCatalogMcpToken("proj", "notfair-googleads")).toBeNull();
+ });
+});
+
+describe("catalogKeysSharingResource", () => {
+ it("returns every catalog key on the same resource, including itself", () => {
+ expect(catalogKeysSharingResource("proj", "notfair-googleads")).toEqual([
+ "notfair-googleads",
+ "notfair-metaads",
+ ]);
+ });
+
+ it("returns the requested key when the spec is unknown", () => {
+ mocks.mcpSpecByKey.mockReturnValue(undefined);
+ expect(catalogKeysSharingResource("proj", "missing")).toEqual(["missing"]);
+ });
+});
diff --git a/notfair/src/server/mcp/catalog-token.ts b/notfair/src/server/mcp/catalog-token.ts
new file mode 100644
index 00000000..7594606f
--- /dev/null
+++ b/notfair/src/server/mcp/catalog-token.ts
@@ -0,0 +1,42 @@
+import { getMcpCatalog, mcpSpecByKey } from "@/server/mcp-catalog";
+import { findMcpToken, type McpToken } from "@/server/mcp/tokens";
+import { normalizeResourceUrl } from "@/server/mcp/discovery-url";
+
+/**
+ * Look up the stored token for a catalog key, then fall back to any other
+ * catalog entry that advertises the same resource URL.
+ *
+ * NotFair presets all point at `/api/mcp/notfair`, so one OAuth grant is
+ * enough for Google Ads, Meta Ads, Search Console, Analytics, and X Ads.
+ */
+export function findCatalogMcpToken(
+ project_slug: string,
+ catalog_key: string,
+): McpToken | null {
+ const direct = findMcpToken(project_slug, catalog_key);
+ if (direct) return direct;
+
+ const spec = mcpSpecByKey(project_slug, catalog_key);
+ if (!spec) return null;
+ const target = normalizeResourceUrl(spec.resource_url);
+ for (const other of getMcpCatalog(project_slug)) {
+ if (other.key === catalog_key) continue;
+ if (normalizeResourceUrl(other.resource_url) !== target) continue;
+ const token = findMcpToken(project_slug, other.key);
+ if (token) return token;
+ }
+ return null;
+}
+
+/** Catalog keys that share this entry's resource URL, including itself. */
+export function catalogKeysSharingResource(
+ project_slug: string,
+ catalog_key: string,
+): string[] {
+ const spec = mcpSpecByKey(project_slug, catalog_key);
+ if (!spec) return [catalog_key];
+ const target = normalizeResourceUrl(spec.resource_url);
+ return getMcpCatalog(project_slug)
+ .filter((entry) => normalizeResourceUrl(entry.resource_url) === target)
+ .map((entry) => entry.key);
+}
diff --git a/notfair/src/server/mcp/discovery-url.test.ts b/notfair/src/server/mcp/discovery-url.test.ts
index 474c6a27..9932cb61 100644
--- a/notfair/src/server/mcp/discovery-url.test.ts
+++ b/notfair/src/server/mcp/discovery-url.test.ts
@@ -44,8 +44,8 @@ describe("normalizeResourceUrl", () => {
describe("deriveDiscoveryUrl", () => {
it("inserts the well-known suffix between origin and path", () => {
- expect(deriveDiscoveryUrl("https://notfair.co/api/mcp/google_ads")).toBe(
- "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/google_ads",
+ expect(deriveDiscoveryUrl("https://notfair.co/api/mcp/notfair")).toBe(
+ "https://notfair.co/.well-known/oauth-protected-resource/api/mcp/notfair",
);
});
diff --git a/notfair/src/server/mcp/rpc.test.ts b/notfair/src/server/mcp/rpc.test.ts
index 982f3714..4cbe3dcf 100644
--- a/notfair/src/server/mcp/rpc.test.ts
+++ b/notfair/src/server/mcp/rpc.test.ts
@@ -29,7 +29,7 @@ import { upsertMcpToken, type McpToken } from "./tokens";
import { getDb } from "@/server/db/db";
const ADS = "notfair-googleads";
-const ADS_URL = "https://notfair.co/api/mcp/google_ads";
+const ADS_URL = "https://notfair.co/api/mcp/notfair";
const fetchMock = vi.fn();
@@ -96,6 +96,19 @@ describe("readMcpConfigRow / getMcpConfig", () => {
});
expect(getMcpConfig(slug, ADS)).toEqual({ url: ADS_URL, token: "secret-bearer" });
});
+
+ it("reuses a token stored under another catalog key that shares the resource URL", () => {
+ const slug = freshProject();
+ upsertMcpToken({
+ project_slug: slug,
+ server_name: "notfair-metaads",
+ access_token: "shared-bearer",
+ });
+ expect(getMcpConfig(slug, ADS)).toEqual({
+ url: ADS_URL,
+ token: "shared-bearer",
+ });
+ });
});
describe("bearerFromHeaders", () => {
diff --git a/notfair/src/server/mcp/rpc.ts b/notfair/src/server/mcp/rpc.ts
index 5ccfbc3e..e1ed318e 100644
--- a/notfair/src/server/mcp/rpc.ts
+++ b/notfair/src/server/mcp/rpc.ts
@@ -1,4 +1,4 @@
-import { findMcpToken } from "@/server/mcp/tokens";
+import { findCatalogMcpToken } from "@/server/mcp/catalog-token";
import { mcpSpecByKey } from "@/server/mcp-catalog";
import { refreshMcpToken, isExpiringSoon } from "./refresh";
@@ -45,7 +45,7 @@ export function readMcpConfigRow(
): McpConfigRow | null {
const spec = mcpSpecByKey(project_slug, catalog_key);
if (!spec) return null;
- const token = findMcpToken(project_slug, catalog_key);
+ const token = findCatalogMcpToken(project_slug, catalog_key);
if (!token) return { url: spec.resource_url };
return {
url: spec.resource_url,
@@ -187,7 +187,7 @@ export async function mcpRpcAutoRefresh<T = unknown>(
if (!spec) {
return { ok: false, kind: "http_error", status: 404, body: "unknown mcp catalog key" };
}
- let token = findMcpToken(project_slug, catalog_key);
+ let token = findCatalogMcpToken(project_slug, catalog_key);
if (!token) {
return { ok: false, kind: "http_error", status: 401, body: "no token stored" };
}
diff --git a/notfair/src/server/mcp/state.test.ts b/notfair/src/server/mcp/state.test.ts
index e55f727a..6f0f0046 100644
--- a/notfair/src/server/mcp/state.test.ts
+++ b/notfair/src/server/mcp/state.test.ts
@@ -9,6 +9,8 @@ const mocks = vi.hoisted(() => ({
getCachedProbe: vi.fn(),
setCachedProbe: vi.fn(),
invalidateProbe: vi.fn(),
+ findCatalogMcpToken: vi.fn(),
+ catalogKeysSharingResource: vi.fn(),
}));
vi.mock("./tokens", () => ({
@@ -19,6 +21,10 @@ vi.mock("./tokens", () => ({
vi.mock("@/server/mcp-catalog", () => ({
mcpSpecByKey: mocks.mcpSpecByKey,
}));
+vi.mock("./catalog-token", () => ({
+ findCatalogMcpToken: mocks.findCatalogMcpToken,
+ catalogKeysSharingResource: mocks.catalogKeysSharingResource,
+}));
vi.mock("./rpc", () => ({
mcpRpcAutoRefresh: mocks.mcpRpcAutoRefresh,
}));
@@ -36,6 +42,8 @@ beforeEach(() => {
vi.clearAllMocks();
mocks.mcpSpecByKey.mockReturnValue(SPEC);
mocks.findMcpToken.mockReturnValue({ id: "tok-1" });
+ mocks.findCatalogMcpToken.mockReturnValue({ id: "tok-1" });
+ mocks.catalogKeysSharingResource.mockImplementation((_slug: string, key: string) => [key]);
mocks.getCachedProbe.mockReturnValue(null);
});
@@ -46,7 +54,7 @@ describe("getMcpStatus short-circuits", () => {
});
it("returns not_configured when no token", async () => {
- mocks.findMcpToken.mockReturnValue(null);
+ mocks.findCatalogMcpToken.mockReturnValue(null);
expect(await getMcpStatus("p", "k")).toEqual({ state: "not_configured" });
});
@@ -138,6 +146,18 @@ describe("disconnectMcp", () => {
expect(mocks.deleteMcpToken).not.toHaveBeenCalled();
expect(mocks.invalidateProbe).toHaveBeenCalledWith("p", "k");
});
+
+ it("disconnects every catalog key that shares the same resource URL", async () => {
+ mocks.catalogKeysSharingResource.mockReturnValue(["notfair-googleads", "notfair-metaads"]);
+ mocks.findMcpToken.mockImplementation((_slug: string, key: string) =>
+ key === "notfair-googleads" ? { id: "tok-g" } : { id: "tok-m" },
+ );
+ await disconnectMcp("p", "notfair-googleads");
+ expect(mocks.deleteMcpToken).toHaveBeenCalledWith("tok-g");
+ expect(mocks.deleteMcpToken).toHaveBeenCalledWith("tok-m");
+ expect(mocks.invalidateProbe).toHaveBeenCalledWith("p", "notfair-googleads");
+ expect(mocks.invalidateProbe).toHaveBeenCalledWith("p", "notfair-metaads");
+ });
});
describe("setMcpBearer", () => {
diff --git a/notfair/src/server/mcp/state.ts b/notfair/src/server/mcp/state.ts
index d4ae10ff..dc6814a5 100644
--- a/notfair/src/server/mcp/state.ts
+++ b/notfair/src/server/mcp/state.ts
@@ -1,5 +1,9 @@
import { findMcpToken, upsertMcpToken, deleteMcpToken } from "./tokens";
import { mcpSpecByKey } from "@/server/mcp-catalog";
+import {
+ catalogKeysSharingResource,
+ findCatalogMcpToken,
+} from "./catalog-token";
import { mcpRpcAutoRefresh } from "./rpc";
import {
getCachedProbe,
@@ -44,7 +48,7 @@ export async function getMcpStatus(
): Promise<McpRuntimeStatus> {
const spec = mcpSpecByKey(project_slug, catalog_key);
if (!spec) return { state: "not_configured" };
- const token = findMcpToken(project_slug, catalog_key);
+ const token = findCatalogMcpToken(project_slug, catalog_key);
if (!token) return { state: "not_configured" };
// Cache short-circuit: only `connected` (60s) and `unreachable` (10s)
@@ -138,9 +142,14 @@ async function probe(
}
export async function disconnectMcp(project_slug: string, catalog_key: string): Promise<void> {
- const token = findMcpToken(project_slug, catalog_key);
- if (token) deleteMcpToken(token.id);
- invalidateProbe(project_slug, catalog_key);
+ const keys = catalogKeysSharingResource(project_slug, catalog_key);
+ const tokenIds = new Set<string>();
+ for (const key of keys) {
+ const token = findMcpToken(project_slug, key);
+ if (token) tokenIds.add(token.id);
+ invalidateProbe(project_slug, key);
+ }
+ for (const id of tokenIds) deleteMcpToken(id);
}
export async function setMcpBearer(
diff --git a/notfair/src/server/onboarding/accounts.test.ts b/notfair/src/server/onboarding/accounts.test.ts
index d07664cc..9d8b266a 100644
--- a/notfair/src/server/onboarding/accounts.test.ts
+++ b/notfair/src/server/onboarding/accounts.test.ts
@@ -98,7 +98,7 @@ describe("listGoogleAdsAccounts", () => {
"acme",
"notfair-googleads",
"tools/call",
- { name: "listConnectedAccounts", arguments: {} },
+ { name: "executeRead", arguments: { capabilityId: "google_ads_listConnectedAccounts", arguments: {} } },
{ timeoutMs: 8_000 },
);
});
@@ -200,6 +200,16 @@ describe("Meta Ads account onboarding", () => {
accounts: [{ id: "act_3", name: "Third" }],
});
expect(await listMetaAdsAccounts("acme")).not.toHaveProperty("default_account_id");
+ expect(mocks.mcpRpcAutoRefresh).toHaveBeenCalledWith(
+ "acme",
+ "notfair-metaads",
+ "tools/call",
+ {
+ name: "executeRead",
+ arguments: { capabilityId: "meta_ads_listAdAccounts", arguments: {} },
+ },
+ { timeoutMs: 8_000 },
+ );
});
it("handles missing config, RPC failure, and malformed payloads", async () => {
@@ -257,6 +267,19 @@ describe("Search Console property onboarding", () => {
{ id: "not a url", name: "Custom" },
],
});
+ expect(mocks.mcpRpcAutoRefresh).toHaveBeenCalledWith(
+ "acme",
+ "notfair-googlesearchconsole",
+ "tools/call",
+ {
+ name: "executeRead",
+ arguments: {
+ capabilityId: "search_console_listProperties",
+ arguments: {},
+ },
+ },
+ { timeoutMs: 8_000 },
+ );
mocks.mcpRpcAutoRefresh.mockResolvedValue(
toolResult({ siteEntry: [{ siteUrl: "https://one.example/" }], defaultPropertyId: "one" }),
);
diff --git a/notfair/src/server/onboarding/accounts.ts b/notfair/src/server/onboarding/accounts.ts
index 59ec4e0b..f2ab04fd 100644
--- a/notfair/src/server/onboarding/accounts.ts
+++ b/notfair/src/server/onboarding/accounts.ts
@@ -41,9 +41,17 @@ type AccountsPayload = {
const MCP_CATALOG_KEY = "notfair-googleads";
const LIST_TIMEOUT_MS = 8_000;
+const GOOGLE_ADS_LIST_CAPABILITY = "google_ads_listConnectedAccounts";
+
+function compactExecuteRead(capabilityId: string) {
+ return {
+ name: "executeRead" as const,
+ arguments: { capabilityId, arguments: {} },
+ };
+}
/**
- * Call the MCP's listConnectedAccounts tool with the project's stored bearer.
+ * Call compact `executeRead` for Google Ads accounts with the project's stored bearer.
* Returns the account list (id + name).
*/
export async function listGoogleAdsAccounts(
@@ -62,7 +70,7 @@ export async function listGoogleAdsAccounts(
project_slug,
MCP_CATALOG_KEY,
"tools/call",
- { name: "listConnectedAccounts", arguments: {} },
+ compactExecuteRead(GOOGLE_ADS_LIST_CAPABILITY),
{ timeoutMs: LIST_TIMEOUT_MS },
);
@@ -163,7 +171,7 @@ export async function setOnboardingAccountAction(
}
const META_ADS_MCP_KEY = "notfair-metaads";
-const META_ADS_LIST_TOOL = "listAdAccounts";
+const META_ADS_LIST_CAPABILITY = "meta_ads_listAdAccounts";
export type MetaAdsAccount = {
/** Numeric ad-account id with the `act_` prefix (e.g. `act_123456`). */
@@ -192,7 +200,7 @@ export async function listMetaAdsAccounts(
project_slug,
META_ADS_MCP_KEY,
"tools/call",
- { name: META_ADS_LIST_TOOL, arguments: {} },
+ compactExecuteRead(META_ADS_LIST_CAPABILITY),
{ timeoutMs: LIST_TIMEOUT_MS },
);
if (!rpcResult.ok) {
@@ -204,7 +212,7 @@ export async function listMetaAdsAccounts(
return {
ok: false,
kind: "shape",
- error: `MCP ${META_ADS_LIST_TOOL} returned an unexpected shape.`,
+ error: `MCP ${META_ADS_LIST_CAPABILITY} returned an unexpected shape.`,
};
}
return { ok: true, ...parsed };
@@ -287,14 +295,14 @@ export async function setOnboardingMetaAdsAccountAction(
// surface them as "properties" in the UI to match what users see in
// Search Console.
//
-// The notfair-googlesearchconsole MCP exposes a `listProperties` tool
-// (verified against the live server) which returns a bare JSON array
-// of `{ siteUrl, permissionLevel }`. We also accept the spec-shaped
+// The compact NotFair MCP exposes `search_console_listProperties` via
+// executeRead (verified against the live server) which returns a bare JSON
+// array of `{ siteUrl, permissionLevel }`. We also accept the spec-shaped
// `{ siteEntry: [...] }` wrap and a defensive `{ sites: [...] }` so a
// future server-side change doesn't break the picker.
const GSC_MCP_KEY = "notfair-googlesearchconsole";
-const GSC_LIST_TOOL = "listProperties";
+const GSC_LIST_CAPABILITY = "search_console_listProperties";
export type GscProperty = {
/** Site URL exactly as Search Console uses it. */
@@ -325,7 +333,7 @@ export async function listGscProperties(
project_slug,
GSC_MCP_KEY,
"tools/call",
- { name: GSC_LIST_TOOL, arguments: {} },
+ compactExecuteRead(GSC_LIST_CAPABILITY),
{ timeoutMs: LIST_TIMEOUT_MS },
);
if (!rpcResult.ok) {
@@ -337,7 +345,7 @@ export async function listGscProperties(
return {
ok: false,
kind: "shape",
- error: `MCP ${GSC_LIST_TOOL} returned an unexpected shape.`,
+ error: `MCP ${GSC_LIST_CAPABILITY} returned an unexpected shape.`,
};
}
return { ok: true, ...parsed };
diff --git a/notfair/src/server/trusted-connectors.ts b/notfair/src/server/trusted-connectors.ts
index 922b7d72..823aaca9 100644
--- a/notfair/src/server/trusted-connectors.ts
+++ b/notfair/src/server/trusted-connectors.ts
@@ -1,3 +1,5 @@
+import { CANONICAL_MCP_RESOURCE_URL } from "@/lib/canonical-mcp";
+
/**
* Browseable directory of trusted MCP servers shown in the "Browse
* connectors" dialog. Distinct from `MCP_CATALOG_PRESETS` (which is
@@ -39,25 +41,25 @@ 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",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
},
{
id: "notfair-metaads",
display_name: "NotFair Meta Ads",
description: "Facebook + Instagram campaigns, ad sets, budgets.",
- resource_url: "https://notfair.co/api/mcp/meta_ads",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
},
{
id: "notfair-googlesearchconsole",
display_name: "NotFair Google Search Console",
description: "Organic search performance, queries, pages, indexing.",
- resource_url: "https://notfair.co/api/mcp/google_search_console",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
},
{
id: "notfair-googleanalytics",
display_name: "NotFair Google Analytics",
description: "GA4 traffic, channels, conversions, audiences.",
- resource_url: "https://notfair.co/api/mcp/google_analytics",
+ resource_url: CANONICAL_MCP_RESOURCE_URL,
},
{
id: "stripe",
diff --git a/notfair/src/types/index.ts b/notfair/src/types/index.ts
index 118b90af..9f38f512 100644
--- a/notfair/src/types/index.ts
+++ b/notfair/src/types/index.ts
@@ -8,7 +8,7 @@ export type Project = {
archived_at: string | null;
/**
* Selected Google Ads customer ID for this project. Bearers from
- * notfair.co/api/mcp/google_ads can grant access to multiple customer
+ * notfair.co/api/mcp/notfair can grant access to multiple customer
* accounts; the onboarding flow asks the user to pick one and persists
* it here so the audit + later automation target the right account.
* Null until the user picks (or until /onboarding gets re-run).