Skip to content

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

fix(notfair-cmo): give MCP liveness probe a realistic timeout

Yuting Zhong91b3c6491759
diff --git a/notfair-cmo/src/app/(app)/[project]/connections/page.tsx b/notfair-cmo/src/app/(app)/[project]/connections/page.tsx
index c74e4a98..1b982b74 100644
--- a/notfair-cmo/src/app/(app)/[project]/connections/page.tsx
+++ b/notfair-cmo/src/app/(app)/[project]/connections/page.tsx
@@ -24,8 +24,11 @@ export default async function ConnectionsPage({
if (!project || project.archived_at) notFound();
const catalog = getMcpCatalog(project.slug);
- // Status probes happen in parallel — each has its own 2s timeout so a
- // flaky upstream doesn't gate the whole page.
+ // Status probes happen in parallel — each goes through the in-process
+ // probe cache (60s for connected, 10s for unreachable), so a hot reload
+ // resolves almost entirely from memory. First-visit cost is bounded by
+ // the per-probe timeout in `getMcpStatus` (6s) since Promise.all waits
+ // for the slowest probe.
const statuses = await Promise.all(
catalog.map((s) => getMcpStatus(project.slug, s.key)),
);
diff --git a/notfair-cmo/src/server/mcp/state.ts b/notfair-cmo/src/server/mcp/state.ts
index 3ddca634..3d34d99b 100644
--- a/notfair-cmo/src/server/mcp/state.ts
+++ b/notfair-cmo/src/server/mcp/state.ts
@@ -75,6 +75,13 @@ async function probe(
// Goes through `mcpRpcAutoRefresh` so an expired access token gets
// silently swapped for a fresh one instead of flapping the status to
// "stale_token" on every page load.
+ //
+ // 6s budget: an OAuth-validated `initialize` across the public internet
+ // typically lands in 0.3–1.5s, but cold serverless starts, SSE buffering
+ // (the parser drains the full body before extracting the JSON-RPC frame),
+ // and an upstream introspection RTT can stack. 2s was too tight and made
+ // healthy connectors flap to "unreachable: timed out". 6s still bounds
+ // page render at ~6s worst-case via Promise.all in the page component.
const r = await mcpRpcAutoRefresh<unknown>(
project_slug,
catalog_key,
@@ -84,7 +91,7 @@ async function probe(
capabilities: {},
clientInfo: { name: "notfair-cmo", version: "0.3.1" },
},
- { timeoutMs: 2000 },
+ { timeoutMs: 6000 },
);
if (r.ok) {
return {